From 01fd47814bab3782337309479b8c30ede049800a Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 19 Feb 2026 14:08:40 -0500 Subject: [PATCH] Various reformats. Changed boolean variables from 1/0 to TRUE/FALSE in multiple files. --- BUGS | 3 +- TODO.txt | 8 +- database-initial.sql | 893 ++++++++++++++++---------- database-update.sql | 62 +- distfiles/about.php | 30 +- distfiles/admin.php | 1160 ++++++++++++++++++---------------- distfiles/functions.php | 509 ++++++++------- distfiles/gpl.php | 30 +- distfiles/logentry.php | 638 ++++++++++--------- distfiles/login.php | 64 +- distfiles/lognotes.php | 217 +++---- distfiles/maintform.php | 180 +++--- distfiles/maintformentry.php | 481 +++++++------- distfiles/partentry.php | 92 ++- distfiles/parts.php | 81 +-- distfiles/profile.php | 185 +++--- distfiles/refchain.php | 98 +-- distfiles/schedmaint.php | 688 ++++++++++---------- distfiles/search.php | 698 ++++++++++---------- distfiles/settings.php | 40 +- distfiles/templates.php | 493 ++++++++------- install.sh | 2 +- 22 files changed, 3502 insertions(+), 3150 deletions(-) diff --git a/BUGS b/BUGS index 39f47d2..26132e5 100644 --- a/BUGS +++ b/BUGS @@ -1,4 +1,5 @@ BUGS 1. Adding a reference to a note using the magnifying glass icon is possible even if not logged in. This results in a blank tech and shift. -SOMEWHAT FIXED. If not logged in and the partview argument is not 1, redirects to login page. (This is not the optimal solution. There needs to be a specific view only state.) +SOMEWHAT FIXED. If not logged in and the partview argument is not 1, redirects to login page. (This is not the optimal solution. There +needs to be a specific view only state.) diff --git a/TODO.txt b/TODO.txt index 3d54569..f5e5795 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,15 +1,15 @@ TODO.txt 1. Create a weblink hot button on the add logbook entry page to insert a weblink. DONE -2. Allow admins to create global templates. +2. Allow admins to create global templates. DONE 3. Create a way to restore the global page colors. (db change reqd) 4. Pick a logbook subject to associate with a scheduled task to populate for the logbook entry. (db change reqd) 5. Add info messages to scheduled task page edits. 6. Allow scheduled tasks to be completed as a group instead of having to complete each member. 7. Implement popup calendars for date entry fields. DONE -8. Improve template management interface. It can be confusing. It needs its own page. -9. Remove refs from templates. (db change reqd) -10. Replace dynamic flag_ table creation with a flagassignment table. (db change reqd) +8. Improve template management interface. It can be confusing. It needs its own page. DONE +9. Remove refs from templates. (db change reqd) DONE +10. Replace dynamic flag_ table creation with a flagassignment table. (db change reqd) DONE 11. allow partids to be autogenerated if user doesn't supply one (db change reqd) 12. If there are no flags, don't offer to set them on reference chain 13. make some flags immutable so they won't be synced on reference chain. diff --git a/database-initial.sql b/database-initial.sql index c1b89c9..8ec8ada 100644 --- a/database-initial.sql +++ b/database-initial.sql @@ -4,46 +4,87 @@ -- ------------------------------------------------------ -- Server version 10.6.18-MariaDB-0ubuntu0.22.04.1 -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */ +; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */ +; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */ +; +/*!40101 SET NAMES utf8mb4 */ +; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */ +; +/*!40103 SET TIME_ZONE='+00:00' */ +; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */ +; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */ +; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */ +; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */ +; -- -- Table structure for table `banners` -- DROP TABLE IF EXISTS `banners`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `banners` ( - `bannerid` int(11) NOT NULL AUTO_INCREMENT, - `bannername` tinytext DEFAULT NULL, - `bannercolor` tinytext DEFAULT NULL, - `textcolor` tinytext DEFAULT NULL, - PRIMARY KEY (`bannerid`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `bannerid` int(11) NOT NULL AUTO_INCREMENT, + `bannername` tinytext DEFAULT NULL, + `bannercolor` tinytext DEFAULT NULL, + `textcolor` tinytext DEFAULT NULL, + PRIMARY KEY (`bannerid`) +) ENGINE = InnoDB AUTO_INCREMENT = 6 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `banners` -- LOCK TABLES `banners` WRITE; -/*!40000 ALTER TABLE `banners` DISABLE KEYS */; -INSERT INTO `banners` VALUES -(1,'no banner','#000000','#000000'), -(2,'UNCLASSIFIED','#009900','#FFFFFF'), -(3,'CONFIDENTIAL','#000099','#FFFFFF'), -(4,'SECRET','#990000','#FFFFFF'), -(5,'TOP SECRET','#FF6600','#FFFFFF'); -/*!40000 ALTER TABLE `banners` ENABLE KEYS */; +/*!40000 ALTER TABLE `banners` DISABLE KEYS */ +; +INSERT INTO + `banners` +VALUES ( + 1, + 'no banner', + '#000000', + '#000000' + ), + ( + 2, + 'UNCLASSIFIED', + '#009900', + '#FFFFFF' + ), + ( + 3, + 'CONFIDENTIAL', + '#000099', + '#FFFFFF' + ), + ( + 4, + 'SECRET', + '#990000', + '#FFFFFF' + ), + ( + 5, + 'TOP SECRET', + '#FF6600', + '#FFFFFF' + ); +/*!40000 ALTER TABLE `banners` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -51,55 +92,109 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `configs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `configs` ( - `confid` int(11) NOT NULL AUTO_INCREMENT, - `confname` text DEFAULT NULL, - `confvalue` text DEFAULT NULL, - PRIMARY KEY (`confid`), - UNIQUE (`confname`) -) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `confid` int(11) NOT NULL AUTO_INCREMENT, + `confname` text DEFAULT NULL, + `confvalue` text DEFAULT NULL, + PRIMARY KEY (`confid`), + UNIQUE (`confname`) +) ENGINE = InnoDB AUTO_INCREMENT = 33 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `configs` -- LOCK TABLES `configs` WRITE; -/*!40000 ALTER TABLE `configs` DISABLE KEYS */; -INSERT INTO `configs` VALUES -(1,'ol_version','5.2.4'), -(2,'log_name','OpenLog'), -(3,'banner','1'), -(4,'background_color','#003333'), -(5,'p_background_color','#FFFFFF'), -(6,'sidebar_color','#336666'), -(7,'p_sidebar_color','#FFFFFF'), -(8,'menubg_color','#000000'), -(9,'p_menubg_color','#FFFFFF'), -(10,'text_color','#FFFFFF'), -(11,'p_text_color','#000000'), -(12,'link_color','#00FF00'), -(13,'p_link_color','#000000'), -(14,'vlink_color','#00FF00'), -(15,'p_vlink_color','#000000'), -(16,'heading_color','#00FFFF'), -(17,'p_heading_color','#000000'), -(18,'footer_message','Please report bugs to software@thermionic.net.'), -(19,'show_ts','1'), -(20,'url_chunk_size','70'), -(21,'tech_alpha','1'), -(22,'subj_alpha','1'), -(23,'unix_server_session_dir','/tmp/openlog/openlog/sessions'), -(24,'win_server_session_dir','c:\\Windows\\Temp\\openlog\\\\openlog\\sessions'), -(25,'session_ttl_days','30'), -(26,'log_style','1'), -(27,'uid_text','Part ID Number'), -(28,'parts_functions','1'), -(29,'schedmaint_functions','1'), -(30,'log_errors','0'); -/*!40000 ALTER TABLE `configs` ENABLE KEYS */; +/*!40000 ALTER TABLE `configs` DISABLE KEYS */ +; +INSERT INTO + `configs` +VALUES (1, 'ol_version', '5.2.4'), + (2, 'log_name', 'OpenLog'), + (3, 'banner', '1'), + ( + 4, + 'background_color', + '#003333' + ), + ( + 5, + 'p_background_color', + '#FFFFFF' + ), + (6, 'sidebar_color', '#336666'), + ( + 7, + 'p_sidebar_color', + '#FFFFFF' + ), + (8, 'menubg_color', '#000000'), + ( + 9, + 'p_menubg_color', + '#FFFFFF' + ), + (10, 'text_color', '#FFFFFF'), + (11, 'p_text_color', '#000000'), + (12, 'link_color', '#00FF00'), + (13, 'p_link_color', '#000000'), + (14, 'vlink_color', '#00FF00'), + ( + 15, + 'p_vlink_color', + '#000000' + ), + ( + 16, + 'heading_color', + '#00FFFF' + ), + ( + 17, + 'p_heading_color', + '#000000' + ), + ( + 18, + 'footer_message', + 'Please report bugs to software@thermionic.net.' + ), + (19, 'show_ts', '1'), + (20, 'url_chunk_size', '70'), + (21, 'tech_alpha', '1'), + (22, 'subj_alpha', '1'), + ( + 23, + 'unix_server_session_dir', + '/tmp/openlog/openlog/sessions' + ), + ( + 24, + 'win_server_session_dir', + 'c:\\Windows\\Temp\\openlog\\\\openlog\\sessions' + ), + (25, 'session_ttl_days', '30'), + (26, 'log_style', '1'), + ( + 27, + 'uid_text', + 'Part ID Number' + ), + (28, 'parts_functions', '1'), + ( + 29, + 'schedmaint_functions', + '1' + ), + (30, 'log_errors', '0'); +/*!40000 ALTER TABLE `configs` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -107,24 +202,29 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `customs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `customs` ( - `customid` int(11) NOT NULL AUTO_INCREMENT, - `customtech` int(11) DEFAULT NULL, - `customconfnum` int(11) DEFAULT NULL, - `customconfvalue` text DEFAULT NULL, - PRIMARY KEY (`customid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `customid` int(11) NOT NULL AUTO_INCREMENT, + `customtech` int(11) DEFAULT NULL, + `customconfnum` int(11) DEFAULT NULL, + `customconfvalue` text DEFAULT NULL, + PRIMARY KEY (`customid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `customs` -- LOCK TABLES `customs` WRITE; -/*!40000 ALTER TABLE `customs` DISABLE KEYS */; -/*!40000 ALTER TABLE `customs` ENABLE KEYS */; +/*!40000 ALTER TABLE `customs` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `customs` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -132,23 +232,28 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `devicegroups`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `devicegroups` ( - `groupid` int(11) NOT NULL AUTO_INCREMENT, - `groupdevice` int(11) DEFAULT NULL, - `memberdevice` int(11) DEFAULT NULL, - PRIMARY KEY (`groupid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `groupid` int(11) NOT NULL AUTO_INCREMENT, + `groupdevice` int(11) DEFAULT NULL, + `memberdevice` int(11) DEFAULT NULL, + PRIMARY KEY (`groupid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `devicegroups` -- LOCK TABLES `devicegroups` WRITE; -/*!40000 ALTER TABLE `devicegroups` DISABLE KEYS */; -/*!40000 ALTER TABLE `devicegroups` ENABLE KEYS */; +/*!40000 ALTER TABLE `devicegroups` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `devicegroups` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -156,25 +261,30 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `devices`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `devices` ( - `deviceid` int(11) NOT NULL AUTO_INCREMENT, - `devicename` tinytext DEFAULT NULL, - `devicedesc` text DEFAULT NULL, - `group_flag` int(11) DEFAULT NULL, - `active_flag` int(11) DEFAULT NULL, - PRIMARY KEY (`deviceid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `deviceid` int(11) NOT NULL AUTO_INCREMENT, + `devicename` tinytext DEFAULT NULL, + `devicedesc` text DEFAULT NULL, + `group_flag` int(11) DEFAULT NULL, + `active_flag` int(11) DEFAULT NULL, + PRIMARY KEY (`deviceid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `devices` -- LOCK TABLES `devices` WRITE; -/*!40000 ALTER TABLE `devices` DISABLE KEYS */; -/*!40000 ALTER TABLE `devices` ENABLE KEYS */; +/*!40000 ALTER TABLE `devices` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `devices` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -182,28 +292,33 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `events`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `events` ( - `eventid` int(11) NOT NULL AUTO_INCREMENT, - `task` int(11) DEFAULT NULL, - `device` int(11) DEFAULT NULL, - `start_date` date DEFAULT NULL, - `last_date` date DEFAULT NULL, - `deferred_flag` int(11) DEFAULT NULL, - `deferred_date` date DEFAULT NULL, - `active_flag` int(11) DEFAULT NULL, - PRIMARY KEY (`eventid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `eventid` int(11) NOT NULL AUTO_INCREMENT, + `task` int(11) DEFAULT NULL, + `device` int(11) DEFAULT NULL, + `start_date` date DEFAULT NULL, + `last_date` date DEFAULT NULL, + `deferred_flag` int(11) DEFAULT NULL, + `deferred_date` date DEFAULT NULL, + `active_flag` int(11) DEFAULT NULL, + PRIMARY KEY (`eventid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `events` -- LOCK TABLES `events` WRITE; -/*!40000 ALTER TABLE `events` DISABLE KEYS */; -/*!40000 ALTER TABLE `events` ENABLE KEYS */; +/*!40000 ALTER TABLE `events` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `events` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -211,25 +326,30 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `flags`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `flags` ( - `flagid` int(11) NOT NULL AUTO_INCREMENT, - `flagname` tinytext DEFAULT NULL, - `flagsym` tinytext DEFAULT NULL, - `flagcolor` tinytext DEFAULT NULL, - `status` int(11) NOT NULL, - PRIMARY KEY (`flagid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `flagid` int(11) NOT NULL AUTO_INCREMENT, + `flagname` tinytext DEFAULT NULL, + `flagsym` tinytext DEFAULT NULL, + `flagcolor` tinytext DEFAULT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`flagid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `flags` -- LOCK TABLES `flags` WRITE; -/*!40000 ALTER TABLE `flags` DISABLE KEYS */; -/*!40000 ALTER TABLE `flags` ENABLE KEYS */; +/*!40000 ALTER TABLE `flags` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `flags` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -237,25 +357,30 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `flagmap`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!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 */; + `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 */; +/*!40000 ALTER TABLE `flagmap` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `flagmap` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -263,25 +388,30 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `links`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `links` ( - `linkid` int(11) NOT NULL AUTO_INCREMENT, - `linkpriority` int(11) NOT NULL, - `displaytxt` text DEFAULT NULL, - `urltxt` text DEFAULT NULL, - `status` int(11) NOT NULL, - PRIMARY KEY (`linkid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `linkid` int(11) NOT NULL AUTO_INCREMENT, + `linkpriority` int(11) NOT NULL, + `displaytxt` text DEFAULT NULL, + `urltxt` text DEFAULT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`linkid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `links` -- LOCK TABLES `links` WRITE; -/*!40000 ALTER TABLE `links` DISABLE KEYS */; -/*!40000 ALTER TABLE `links` ENABLE KEYS */; +/*!40000 ALTER TABLE `links` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `links` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -289,27 +419,32 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `lognotes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `lognotes` ( - `lognoteid` int(11) NOT NULL AUTO_INCREMENT, - `date` date DEFAULT NULL, - `time` time DEFAULT NULL, - `shift` int(11) NOT NULL, - `tech` int(11) NOT NULL, - `subject` int(11) NOT NULL, - `lognote` text DEFAULT NULL, - PRIMARY KEY (`lognoteid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `lognoteid` int(11) NOT NULL AUTO_INCREMENT, + `date` date DEFAULT NULL, + `time` time DEFAULT NULL, + `shift` int(11) NOT NULL, + `tech` int(11) NOT NULL, + `subject` int(11) NOT NULL, + `lognote` text DEFAULT NULL, + PRIMARY KEY (`lognoteid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `lognotes` -- LOCK TABLES `lognotes` WRITE; -/*!40000 ALTER TABLE `lognotes` DISABLE KEYS */; -/*!40000 ALTER TABLE `lognotes` ENABLE KEYS */; +/*!40000 ALTER TABLE `lognotes` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `lognotes` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -317,24 +452,29 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `reflinks`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!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 */; + `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 */; +/*!40000 ALTER TABLE `reflinks` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `reflinks` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -342,30 +482,36 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `logpartactions`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `logpartactions` ( - `lpactionid` int(11) NOT NULL AUTO_INCREMENT, - `lpactionname` tinytext DEFAULT NULL, - `status` int(11) DEFAULT NULL, - PRIMARY KEY (`lpactionid`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `lpactionid` int(11) NOT NULL AUTO_INCREMENT, + `lpactionname` tinytext DEFAULT NULL, + `status` int(11) DEFAULT NULL, + PRIMARY KEY (`lpactionid`) +) ENGINE = InnoDB AUTO_INCREMENT = 7 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `logpartactions` -- LOCK TABLES `logpartactions` WRITE; -/*!40000 ALTER TABLE `logpartactions` DISABLE KEYS */; -INSERT INTO `logpartactions` VALUES -(1,'removed',1), -(2,'installed',1), -(3,'repaired',1), -(4,'replaced',1), -(5,'incoming',1), -(6,'outgoing',1); -/*!40000 ALTER TABLE `logpartactions` ENABLE KEYS */; +/*!40000 ALTER TABLE `logpartactions` DISABLE KEYS */ +; +INSERT INTO + `logpartactions` +VALUES (1, 'removed', 1), + (2, 'installed', 1), + (3, 'repaired', 1), + (4, 'replaced', 1), + (5, 'incoming', 1), + (6, 'outgoing', 1); +/*!40000 ALTER TABLE `logpartactions` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -373,24 +519,29 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `logparts`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `logparts` ( - `logpartid` int(11) NOT NULL AUTO_INCREMENT, - `lognoteid` int(11) DEFAULT NULL, - `partid` int(11) DEFAULT NULL, - `action` int(11) DEFAULT NULL, - PRIMARY KEY (`logpartid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `logpartid` int(11) NOT NULL AUTO_INCREMENT, + `lognoteid` int(11) DEFAULT NULL, + `partid` int(11) DEFAULT NULL, + `action` int(11) DEFAULT NULL, + PRIMARY KEY (`logpartid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `logparts` -- LOCK TABLES `logparts` WRITE; -/*!40000 ALTER TABLE `logparts` DISABLE KEYS */; -/*!40000 ALTER TABLE `logparts` ENABLE KEYS */; +/*!40000 ALTER TABLE `logparts` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `logparts` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -398,26 +549,31 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `maintactions`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `maintactions` ( - `maintactionid` int(11) NOT NULL AUTO_INCREMENT, - `actiondate` date DEFAULT NULL, - `actiontime` time DEFAULT NULL, - `maintformnum` int(11) NOT NULL, - `actiontech` int(11) NOT NULL, - `action` text DEFAULT NULL, - PRIMARY KEY (`maintactionid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `maintactionid` int(11) NOT NULL AUTO_INCREMENT, + `actiondate` date DEFAULT NULL, + `actiontime` time DEFAULT NULL, + `maintformnum` int(11) NOT NULL, + `actiontech` int(11) NOT NULL, + `action` text DEFAULT NULL, + PRIMARY KEY (`maintactionid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `maintactions` -- LOCK TABLES `maintactions` WRITE; -/*!40000 ALTER TABLE `maintactions` DISABLE KEYS */; -/*!40000 ALTER TABLE `maintactions` ENABLE KEYS */; +/*!40000 ALTER TABLE `maintactions` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `maintactions` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -425,31 +581,36 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `maintforms`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `maintforms` ( - `maintformid` int(11) NOT NULL AUTO_INCREMENT, - `mfdate` date DEFAULT NULL, - `mftime` time DEFAULT NULL, - `mftech` int(11) DEFAULT NULL, - `mfpart` int(11) NOT NULL, - `mfpartloc` text DEFAULT NULL, - `mfmalfunction` text DEFAULT NULL, - `nha` tinytext DEFAULT NULL, - `repord` tinytext DEFAULT NULL, - `lognoteid` int(11) DEFAULT NULL, - `pending` int(11) DEFAULT NULL, - PRIMARY KEY (`maintformid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `maintformid` int(11) NOT NULL AUTO_INCREMENT, + `mfdate` date DEFAULT NULL, + `mftime` time DEFAULT NULL, + `mftech` int(11) DEFAULT NULL, + `mfpart` int(11) NOT NULL, + `mfpartloc` text DEFAULT NULL, + `mfmalfunction` text DEFAULT NULL, + `nha` tinytext DEFAULT NULL, + `repord` tinytext DEFAULT NULL, + `lognoteid` int(11) DEFAULT NULL, + `pending` int(11) DEFAULT NULL, + PRIMARY KEY (`maintformid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `maintforms` -- LOCK TABLES `maintforms` WRITE; -/*!40000 ALTER TABLE `maintforms` DISABLE KEYS */; -/*!40000 ALTER TABLE `maintforms` ENABLE KEYS */; +/*!40000 ALTER TABLE `maintforms` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `maintforms` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -457,27 +618,32 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `notetemplates`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `notetemplates` ( - `templateid` int(11) NOT NULL AUTO_INCREMENT, - `templatename` tinytext DEFAULT NULL, - `shift` int(11) NOT NULL, - `tech` int(11) NOT NULL, - `subject` int(11) NOT NULL, - `lognote` text DEFAULT NULL, - `refs` tinytext DEFAULT NULL, - PRIMARY KEY (`templateid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `templateid` int(11) NOT NULL AUTO_INCREMENT, + `templatename` tinytext DEFAULT NULL, + `shift` int(11) NOT NULL, + `tech` int(11) NOT NULL, + `subject` int(11) NOT NULL, + `lognote` text DEFAULT NULL, + `refs` tinytext DEFAULT NULL, + PRIMARY KEY (`templateid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `notetemplates` -- LOCK TABLES `notetemplates` WRITE; -/*!40000 ALTER TABLE `notetemplates` DISABLE KEYS */; -/*!40000 ALTER TABLE `notetemplates` ENABLE KEYS */; +/*!40000 ALTER TABLE `notetemplates` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `notetemplates` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -485,25 +651,30 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `parts`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `parts` ( - `partid` int(11) NOT NULL AUTO_INCREMENT, - `uid` tinytext DEFAULT NULL, - `partnum` tinytext DEFAULT NULL, - `sernum` tinytext DEFAULT NULL, - `partname` tinytext DEFAULT NULL, - PRIMARY KEY (`partid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `partid` int(11) NOT NULL AUTO_INCREMENT, + `uid` tinytext DEFAULT NULL, + `partnum` tinytext DEFAULT NULL, + `sernum` tinytext DEFAULT NULL, + `partname` tinytext DEFAULT NULL, + PRIMARY KEY (`partid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `parts` -- LOCK TABLES `parts` WRITE; -/*!40000 ALTER TABLE `parts` DISABLE KEYS */; -/*!40000 ALTER TABLE `parts` ENABLE KEYS */; +/*!40000 ALTER TABLE `parts` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `parts` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -511,25 +682,29 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `shifts`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `shifts` ( - `shiftid` int(11) NOT NULL AUTO_INCREMENT, - `shiftname` tinytext DEFAULT NULL, - `status` int(11) NOT NULL, - PRIMARY KEY (`shiftid`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `shiftid` int(11) NOT NULL AUTO_INCREMENT, + `shiftname` tinytext DEFAULT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`shiftid`) +) ENGINE = InnoDB AUTO_INCREMENT = 2 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `shifts` -- LOCK TABLES `shifts` WRITE; -/*!40000 ALTER TABLE `shifts` DISABLE KEYS */; -INSERT INTO `shifts` VALUES -(1,'First Shift',1); -/*!40000 ALTER TABLE `shifts` ENABLE KEYS */; +/*!40000 ALTER TABLE `shifts` DISABLE KEYS */ +; +INSERT INTO `shifts` VALUES (1, 'First Shift', 1); +/*!40000 ALTER TABLE `shifts` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -537,26 +712,32 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `styles`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `styles` ( - `styleid` int(11) NOT NULL AUTO_INCREMENT, - `styletype` tinytext DEFAULT NULL, - `stylename` tinytext DEFAULT NULL, - PRIMARY KEY (`styleid`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `styleid` int(11) NOT NULL AUTO_INCREMENT, + `styletype` tinytext DEFAULT NULL, + `stylename` tinytext DEFAULT NULL, + PRIMARY KEY (`styleid`) +) ENGINE = InnoDB AUTO_INCREMENT = 3 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `styles` -- LOCK TABLES `styles` WRITE; -/*!40000 ALTER TABLE `styles` DISABLE KEYS */; -INSERT INTO `styles` VALUES -(1,'logdisplay','classic'), -(2,'logdisplay','clean'); -/*!40000 ALTER TABLE `styles` ENABLE KEYS */; +/*!40000 ALTER TABLE `styles` DISABLE KEYS */ +; +INSERT INTO + `styles` +VALUES (1, 'logdisplay', 'classic'), + (2, 'logdisplay', 'clean'); +/*!40000 ALTER TABLE `styles` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -564,25 +745,29 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `subjects`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `subjects` ( - `subjectid` int(11) NOT NULL AUTO_INCREMENT, - `subjectname` tinytext DEFAULT NULL, - `status` int(11) NOT NULL, - PRIMARY KEY (`subjectid`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `subjectid` int(11) NOT NULL AUTO_INCREMENT, + `subjectname` tinytext DEFAULT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`subjectid`) +) ENGINE = InnoDB AUTO_INCREMENT = 2 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `subjects` -- LOCK TABLES `subjects` WRITE; -/*!40000 ALTER TABLE `subjects` DISABLE KEYS */; -INSERT INTO `subjects` VALUES -(1,'Miscellaneous',1); -/*!40000 ALTER TABLE `subjects` ENABLE KEYS */; +/*!40000 ALTER TABLE `subjects` DISABLE KEYS */ +; +INSERT INTO `subjects` VALUES (1, 'Miscellaneous', 1); +/*!40000 ALTER TABLE `subjects` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -590,30 +775,35 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `tasks`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `tasks` ( - `taskid` int(11) NOT NULL AUTO_INCREMENT, - `taskname` tinytext DEFAULT NULL, - `taskdesc` text DEFAULT NULL, - `frequency` int(11) DEFAULT NULL, - `period` tinytext DEFAULT NULL, - `weekdays_only` int(11) DEFAULT NULL, - `nextdue_relative` int(11) DEFAULT NULL, - `refdoc_name` tinytext DEFAULT NULL, - `refdoc_url` tinytext DEFAULT NULL, - `active_flag` int(11) DEFAULT NULL, - PRIMARY KEY (`taskid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `taskid` int(11) NOT NULL AUTO_INCREMENT, + `taskname` tinytext DEFAULT NULL, + `taskdesc` text DEFAULT NULL, + `frequency` int(11) DEFAULT NULL, + `period` tinytext DEFAULT NULL, + `weekdays_only` int(11) DEFAULT NULL, + `nextdue_relative` int(11) DEFAULT NULL, + `refdoc_name` tinytext DEFAULT NULL, + `refdoc_url` tinytext DEFAULT NULL, + `active_flag` int(11) DEFAULT NULL, + PRIMARY KEY (`taskid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `tasks` -- LOCK TABLES `tasks` WRITE; -/*!40000 ALTER TABLE `tasks` DISABLE KEYS */; -/*!40000 ALTER TABLE `tasks` ENABLE KEYS */; +/*!40000 ALTER TABLE `tasks` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `tasks` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -621,37 +811,58 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `techs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `techs` ( - `techid` int(11) NOT NULL AUTO_INCREMENT, - `techname` tinytext DEFAULT NULL, - `admin` int(11) DEFAULT NULL, - `shift` int(11) DEFAULT NULL, - `techpass` text DEFAULT NULL, - `status` int(11) NOT NULL, - PRIMARY KEY (`techid`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `techid` int(11) NOT NULL AUTO_INCREMENT, + `techname` tinytext DEFAULT NULL, + `admin` int(11) DEFAULT NULL, + `shift` int(11) DEFAULT NULL, + `techpass` text DEFAULT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`techid`) +) ENGINE = InnoDB AUTO_INCREMENT = 3 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `techs` -- LOCK TABLES `techs` WRITE; -/*!40000 ALTER TABLE `techs` DISABLE KEYS */; -INSERT INTO `techs` VALUES -(1,'OpenLogAdmin',1,1,'$2y$10$6eCxUFNzoAkycMJpZ.zvaOfoByYhqi0YicQbut3XGc/TRxyxiUwcm',1); -/*!40000 ALTER TABLE `techs` ENABLE KEYS */; +/*!40000 ALTER TABLE `techs` DISABLE KEYS */ +; +INSERT INTO + `techs` +VALUES ( + 1, + 'OpenLogAdmin', + 1, + 1, + '$2y$10$6eCxUFNzoAkycMJpZ.zvaOfoByYhqi0YicQbut3XGc/TRxyxiUwcm', + 1 + ); +/*!40000 ALTER TABLE `techs` ENABLE KEYS */ +; UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */ +; -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */ +; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */ +; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */ +; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */ +; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */ +; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */ +; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */ +; --- Dump completed on 2024-07-09 14:36:00 +-- Dump completed on 2024-07-09 14:36:00 \ No newline at end of file diff --git a/database-update.sql b/database-update.sql index c96da54..a5d096e 100644 --- a/database-update.sql +++ b/database-update.sql @@ -2,81 +2,85 @@ -- ---------- version 5.2.1 ------------- -- Make confname a unique column -ALTER TABLE configs ADD UNIQUE(confname); +ALTER TABLE configs ADD UNIQUE (confname); -- Delete db name, user, and password configs -DELETE FROM configs where confname="ol_dbname"; -DELETE FROM configs where confname="ol_dbuser"; -DELETE FROM configs where confname="ol_dbpass"; +DELETE FROM configs where confname = "ol_dbname"; + +DELETE FROM configs where confname = "ol_dbuser"; + +DELETE FROM configs where confname = "ol_dbpass"; -- Add config option for server side error logging -INSERT IGNORE INTO configs(confname,confvalue) values('log_errors','0') +INSERT IGNORE INTO + configs (confname, confvalue) +values ('log_errors', '0') -- Update version number -UPDATE configs SET confvalue="5.2.1" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.1" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.2 ------------- -- Update version number -UPDATE configs SET confvalue="5.2.2" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.2" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.3 ------------- -- Update version number -UPDATE configs SET confvalue="5.2.3" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.3" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.4 ------------- -- Update version number -UPDATE configs SET confvalue="5.2.4" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.4" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.4.1 ----------- -- Update version number -UPDATE configs SET confvalue="5.2.4.1" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.4.1" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.4.2 ----------- -- Update version number -UPDATE configs SET confvalue="5.2.4.2" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.4.2" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.4.3 ----------- -- Update version number -UPDATE configs SET confvalue="5.2.4.3" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.4.3" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.4.4 ----------- -- Update version number -UPDATE configs SET confvalue="5.2.4.4" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.4.4" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.5 ------------- -- Update version number -UPDATE configs SET confvalue="5.2.5" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.5" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.3.0 ------------- -- Update version number -UPDATE configs SET confvalue="5.3.0" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.3.0" WHERE confname = "ol_version"; -- Create the flagmap table CREATE TABLE IF NOT EXISTS `flagmap` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `flagid` int(11) NOT NULL, - `lognoteid` int(11) DEFAULT NULL, - `maintformid` int(11) DEFAULT NULL, - `notetemplateid` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + `id` int(11) NOT NULL AUTO_INCREMENT, + `flagid` int(11) NOT NULL, + `lognoteid` int(11) DEFAULT NULL, + `maintformid` int(11) DEFAULT NULL, + `notetemplateid` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; -- Create the reflinks table CREATE TABLE IF NOT EXISTS `reflinks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `noteid` int(11) DEFAULT NULL, - `templateid` int(11) DEFAULT NULL, - `target` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + `id` int(11) NOT NULL AUTO_INCREMENT, + `noteid` int(11) DEFAULT NULL, + `templateid` int(11) DEFAULT NULL, + `target` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; --- -------------------------------------- +-- -------------------------------------- \ No newline at end of file diff --git a/distfiles/about.php b/distfiles/about.php index ccdb1d7..9ebfa31 100644 --- a/distfiles/about.php +++ b/distfiles/about.php @@ -8,27 +8,27 @@ */ include("functions.php"); -$version=OL_VERSION; +$version = OL_VERSION; -$print=$_REQUEST['print'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","About OpenLog","About OpenLog",$print); +framework("begin", "About OpenLog", "About OpenLog", $print); pagetable("begin"); -if(!$print){ - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); echo "

OpenLog $version @@ -87,10 +87,8 @@ border=0>Fugue
Icons
The icons used in OpenLog ar

-"; -pageblock("right","end"); +"; +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/admin.php b/distfiles/admin.php index dd5959c..8d89dbe 100644 --- a/distfiles/admin.php +++ b/distfiles/admin.php @@ -10,710 +10,723 @@ include("functions.php"); if (!isset($_SESSION['login'])) { - header ("Location: login.php"); + header("Location: login.php"); } // get user's admin status -$loginid=$_SESSION['login'] ?? NULL; -$isadmin=dblookup($db,"techs","techid","admin",$loginid); -$print=$_REQUEST['print'] ?? NULL; -$table=$_REQUEST['table'] ?? NULL; -$edit=$_REQUEST['edit'] ?? NULL; -$add=$_REQUEST['add'] ?? NULL; -$update=$_REQUEST['update'] ?? NULL; -$delete=$_REQUEST['delete'] ?? NULL; -$id=$_REQUEST['id'] ?? NULL; -$name=$_REQUEST['name'] ?? NULL; -$admin=$_REQUEST['admin'] ?? NULL; -$shift=$_REQUEST['shift'] ?? NULL; -$pass=$_REQUEST['pass'] ?? NULL; -$passconf=$_REQUEST['passconf'] ?? NULL; -$belowlink=$_REQUEST['belowlink'] ?? NULL; -$url=$_REQUEST['url'] ?? NULL; -$flagsym=$_REQUEST['flagsym'] ?? NULL; -$flagcolor=$_REQUEST['flagcolor'] ?? NULL; -$bnrcolor=$_REQUEST['bnrcolor'] ?? NULL; -$bnrtxtcolor=$_REQUEST['bnrtxtcolor'] ?? NULL; -$active=$_REQUEST['active'] ?? NULL; -$type=$_REQUEST['type'] ?? NULL; -$display_logname=$_REQUEST['display_logname'] ?? NULL; -$display_urlchunk=$_REQUEST['display_urlchunk'] ?? NULL; -$display_banner=$_REQUEST['display_banner'] ?? NULL; -$display_footer=$_REQUEST['display_footer'] ?? NULL; -$display_showts=$_REQUEST['display_showts'] ?? NULL; -$display_techalpha=$_REQUEST['display_techalpha'] ?? NULL; -$display_subjalpha=$_REQUEST['display_subjalpha'] ?? NULL; -$display_logstyle=$_REQUEST['display_logstyle'] ?? NULL; -$display_uidtext=$_REQUEST['display_uidtext'] ?? NULL; -$modcolor=$_REQUEST['modcolor'] ?? NULL; -$hexcolor=$_REQUEST['hexcolor'] ?? NULL; -$db_dbname=$_REQUEST['db_dbname'] ?? NULL; -$misc_sessttl=$_REQUEST['misc_sessttl'] ?? NULL; -$misc_sessdir=$_REQUEST['misc_sessdir'] ?? NULL; -$misc_logoutall=$_REQUEST['misc_logoutall'] ?? NULL; -$misc_partfuncs=$_REQUEST['misc_partfuncs'] ?? NULL; -$misc_schedmaintfuncs=$_REQUEST['misc_schedmaintfuncs'] ?? NULL; +$loginid = $_SESSION['login'] ?? NULL; +$isadmin = dblookup($db, "techs", "techid", "admin", $loginid); +$print = $_REQUEST['print'] ?? NULL; +$table = $_REQUEST['table'] ?? NULL; +$edit = $_REQUEST['edit'] ?? NULL; +$add = $_REQUEST['add'] ?? NULL; +$update = $_REQUEST['update'] ?? NULL; +$delete = $_REQUEST['delete'] ?? NULL; +$id = $_REQUEST['id'] ?? NULL; +$name = $_REQUEST['name'] ?? NULL; +$admin = $_REQUEST['admin'] ?? NULL; +$shift = $_REQUEST['shift'] ?? NULL; +$pass = $_REQUEST['pass'] ?? NULL; +$passconf = $_REQUEST['passconf'] ?? NULL; +$belowlink = $_REQUEST['belowlink'] ?? NULL; +$url = $_REQUEST['url'] ?? NULL; +$flagsym = $_REQUEST['flagsym'] ?? NULL; +$flagcolor = $_REQUEST['flagcolor'] ?? NULL; +$bnrcolor = $_REQUEST['bnrcolor'] ?? NULL; +$bnrtxtcolor = $_REQUEST['bnrtxtcolor'] ?? NULL; +$active = $_REQUEST['active'] ?? NULL; +$type = $_REQUEST['type'] ?? NULL; +$display_logname = $_REQUEST['display_logname'] ?? NULL; +$display_urlchunk = $_REQUEST['display_urlchunk'] ?? NULL; +$display_banner = $_REQUEST['display_banner'] ?? NULL; +$display_footer = $_REQUEST['display_footer'] ?? NULL; +$display_showts = $_REQUEST['display_showts'] ?? NULL; +$display_techalpha = $_REQUEST['display_techalpha'] ?? NULL; +$display_subjalpha = $_REQUEST['display_subjalpha'] ?? NULL; +$display_logstyle = $_REQUEST['display_logstyle'] ?? NULL; +$display_uidtext = $_REQUEST['display_uidtext'] ?? NULL; +$modcolor = $_REQUEST['modcolor'] ?? NULL; +$hexcolor = $_REQUEST['hexcolor'] ?? NULL; +$db_dbname = $_REQUEST['db_dbname'] ?? NULL; +$misc_sessttl = $_REQUEST['misc_sessttl'] ?? NULL; +$misc_sessdir = $_REQUEST['misc_sessdir'] ?? NULL; +$misc_logoutall = $_REQUEST['misc_logoutall'] ?? NULL; +$misc_partfuncs = $_REQUEST['misc_partfuncs'] ?? NULL; +$misc_schedmaintfuncs = $_REQUEST['misc_schedmaintfuncs'] ?? NULL; -$logname=LOG_NAME; +$logname = LOG_NAME; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname","Administration",$print); +framework("begin", "$logname", "Administration", $print); //var_dump($_REQUEST); pagetable("begin"); -if(!$print){ - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); if ($isadmin) { // ******** begin database manipulation ******** if ($add) { - switch($table) { + switch ($table) { case "techs": - if ($admin) $admin=1; else $admin=0; - if ($active) $active=1; else $active=0; + if ($admin) $admin = 1; + else $admin = 0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Tech name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) { + $nameunique = FALSE; echo " Tech name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } // test for matching passwords - if ($pass==$passconf) { - $passmatch=1; - $passhash=password_hash($pass,PASSWORD_DEFAULT); + if ($pass == $passconf) { + $passmatch = TRUE; + $passhash = password_hash($pass, PASSWORD_DEFAULT); } else { - $passmatch=0; + $passmatch = FALSE; echo " The passwords you supplied don't match.
"; } if ($namesuppld && $nameunique && $passmatch) { // modify the table - $addqry=("insert into techs(techname,admin,shift,techpass,status) values(\"$name\",\"$admin\",\"$shift\",\"$passhash\",\"$active\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into techs(techname,admin,shift,techpass,status) values(\"$name\",\"$admin\",\"$shift\",\"$passhash\",\"$active\")"); + mysqli_query($db, $addqry); } break; case "shifts": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Shift name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select shiftid from shifts where shiftname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\""))) { + $nameunique = FALSE; echo " Shift name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into shifts(shiftname,status) values(\"$name\",\"$active\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into shifts(shiftname,status) values(\"$name\",\"$active\")"); + mysqli_query($db, $addqry); } break; case "subjects": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Subject name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select subjectid from subjects where subjectname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\""))) { + $nameunique = FALSE; echo " Subject name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into subjects(subjectname,status) values(\"$name\",\"$active\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into subjects(subjectname,status) values(\"$name\",\"$active\")"); + mysqli_query($db, $addqry); } break; case "links": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Display text cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select linkid from links where displaytxt=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\""))) { + $nameunique = FALSE; echo " Display text already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } // test for urltxt supplied if (strlen(trim($url))) { - $urlsuppld=1; + $urlsuppld = TRUE; } else { - $urlsuppld=0; + $urlsuppld = FALSE; echo " URL text cannot be blank.
"; } if ($namesuppld && $nameunique && $urlsuppld) { // bump entries with linkpriority higher than belowlink up by one if necessary - $mypriority=$belowlink+1; - if (mysqli_num_rows(mysqli_query($db,"select linkpriority from links where linkpriority=\"$mypriority\""))) { - mysqli_query($db,"update links set linkpriority=linkpriority+1 where linkpriority>\"$belowlink\""); + $mypriority = $belowlink + 1; + if (mysqli_num_rows(mysqli_query($db, "select linkpriority from links where linkpriority=\"$mypriority\""))) { + mysqli_query($db, "update links set linkpriority=linkpriority+1 where linkpriority>\"$belowlink\""); } // insert the link - mysqli_query($db,"insert into links(linkpriority,displaytxt,urltxt,status) values(\"$mypriority\",\"$name\",\"$url\",\"$active\")"); + mysqli_query($db, "insert into links(linkpriority,displaytxt,urltxt,status) values(\"$mypriority\",\"$name\",\"$url\",\"$active\")"); } break; case "flags": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Flag name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\""))) { + $nameunique = FALSE; echo " Flag name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } // test for symbol supplied if (strlen(trim($flagsym))) { - $symsuppld=1; + $symsuppld = TRUE; } else { - $symsuppld=0; + $symsuppld = FALSE; echo " Flag symbol cannot be blank.
"; } // test for symbol unique - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagsym=\"$flagsym\""))) { - $symunique=0; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\""))) { + $symunique = FALSE; echo " Flag symbol already exists.
"; } else { - $symunique=1; + $symunique = TRUE; } if ($namesuppld && $nameunique && $symsuppld && $symunique) { - // insert record in links table - mysqli_query($db,"insert into flags(flagname,flagsym,flagcolor,status) values(\"$name\",\"$flagsym\",\"$flagcolor\",\"$active\")"); - // create sub tables for this link - $lastflagid=mysqli_insert_id($db); - mysqli_query($db,"create table flag_$lastflagid(target tinytext,id int not null)"); + // insert record in flags table + mysqli_query($db, "insert into flags(flagname,flagsym,flagcolor,status) values(\"$name\",\"$flagsym\",\"$flagcolor\",\"$active\")"); } break; case "logpartactions": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Part Action name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select lpactionid from logpartactions where lpactionname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\""))) { + $nameunique = FALSE; echo " Part Action name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into logpartactions(lpactionname,status) values(\"$name\",\"$active\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into logpartactions(lpactionname,status) values(\"$name\",\"$active\")"); + mysqli_query($db, $addqry); } break; case "banners": // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Banner name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select bannerid from banners where bannername=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\""))) { + $nameunique = FALSE; echo " Banner name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into banners(bannername,bannercolor,textcolor) values(\"$name\",\"$bnrcolor\",\"$bnrtxtcolor\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into banners(bannername,bannercolor,textcolor) values(\"$name\",\"$bnrcolor\",\"$bnrtxtcolor\")"); + mysqli_query($db, $addqry); } break; - default : - framework("begin","$logname Administration","Error",$print); - echo "unknown table"; - framework("end","","",$print); - exit(); + default: + framework("begin", "$logname Administration", "Error", $print); + echo "unknown table"; + framework("end", "", "", $print); + exit(); } } if ($edit) { - switch($table) { + switch ($table) { case "techs": - if ($admin) $admin=1; else $admin=0; - if ($active) $active=1; else $active=0; + if ($admin) $admin = 1; + else $admin = 0; + if ($active) $active = 1; + else $active = 0; if ($delete) { // check for log notes by this tech - if (mysqli_num_rows(mysqli_query($db,"select lognoteid from lognotes where tech=\"$id\""))) { - $hasnotes=1; + if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where tech=\"$id\""))) { + $hasnotes = TRUE; echo " Tech has notes in logbook and cannot be deleted.
"; } else { - $hasnotes=0; + $hasnotes = FALSE; } // check for maintenance forms by this tech - if (mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mftech=\"$id\""))) { - $hasmfs=1; + if (mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mftech=\"$id\""))) { + $hasmfs = TRUE; echo " Tech has maintenance forms and cannot be deleted.
"; } else { - $hasmfs=0; + $hasmfs = FALSE; } // check for maintenance actions by this tech - if (mysqli_num_rows(mysqli_query($db,"select maintactionid from maintactions where actiontech=\"$id\""))) { - $hasmas=1; + if (mysqli_num_rows(mysqli_query($db, "select maintactionid from maintactions where actiontech=\"$id\""))) { + $hasmas = TRUE; echo " Tech has maintenance actions and cannot be deleted.
"; } else { - $hasmas=0; + $hasmas = FALSE; } if (!$hasnotes && !$hasmfs && !$hasmas) { // delete entity - mysqli_query($db,"delete from techs where techid=\"$id\""); + mysqli_query($db, "delete from techs where techid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Tech name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\" and techid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\" and techid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) { + $nameunique = FALSE; echo " Tech name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } // test for matching passwords - if ($pass!="password_is_unchanged") { - if ($pass==$passconf) { - $passmatch=1; - $passhash=password_hash($pass,PASSWORD_DEFAULT); - $updqry=("update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",techpass=\"$passhash\",status=\"$active\" where techid=\"$id\""); + if ($pass != "password_is_unchanged") { + if ($pass == $passconf) { + $passmatch = TRUE; + $passhash = password_hash($pass, PASSWORD_DEFAULT); + $updqry = ("update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",techpass=\"$passhash\",status=\"$active\" where techid=\"$id\""); } else { - $passmatch=0; + $passmatch = FALSE; echo " The passwords you supplied don't match.
"; } } else { - $passmatch=1; - $updqry="update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",status=\"$active\" where techid=\"$id\""; + $passmatch = TRUE; + $updqry = "update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",status=\"$active\" where techid=\"$id\""; } if ($namesuppld && $nameunique && $passmatch) { // modify the table - mysqli_query($db,$updqry); + mysqli_query($db, $updqry); } } break; case "shifts": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; if ($delete) { // check for log notes with this shift - if (mysqli_num_rows(mysqli_query($db,"select lognoteid from lognotes where shift=\"$id\""))) { - $hasnotes=1; + if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where shift=\"$id\""))) { + $hasnotes = TRUE; echo " Shift has notes in logbook and cannot be deleted.
"; } else { - $hasnotes=0; + $hasnotes = FALSE; } if (!$hasnotes) { // delete entity - mysqli_query($db,"delete from shifts where shiftid=\"$id\""); + mysqli_query($db, "delete from shifts where shiftid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Shift name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select shiftid from shifts where shiftname=\"$name\" and shiftid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select shiftid from shifts where shiftname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\" and shiftid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\""))) { + $nameunique = FALSE; echo " Shift name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - mysqli_query($db,"update shifts set shiftname=\"$name\",status=\"$active\" where shiftid=\"$id\""); + mysqli_query($db, "update shifts set shiftname=\"$name\",status=\"$active\" where shiftid=\"$id\""); } } break; case "subjects": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; if ($delete) { // check for log notes with this subject - if (mysqli_num_rows(mysqli_query($db,"select lognoteid from lognotes where subject=\"$id\""))) { - $hasnotes=1; + if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where subject=\"$id\""))) { + $hasnotes = TRUE; echo " Subject has notes in logbook and cannot be deleted.
"; } else { - $hasnotes=0; + $hasnotes = FALSE; } if (!$hasnotes) { // delete entity - mysqli_query($db,"delete from subjects where subjectid=\"$id\""); + mysqli_query($db, "delete from subjects where subjectid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Subject name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select subjectid from subjects where subjectname=\"$name\" and subjectid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select subjectid from subjects where subjectname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\" and subjectid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\""))) { + $nameunique = FALSE; echo " Subject name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - mysqli_query($db,"update subjects set subjectname=\"$name\",status=\"$active\" where subjectid=\"$id\""); + mysqli_query($db, "update subjects set subjectname=\"$name\",status=\"$active\" where subjectid=\"$id\""); } } break; case "links": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; if ($delete) { - mysqli_query($db,"delete from links where linkid=\"$id\""); + mysqli_query($db, "delete from links where linkid=\"$id\""); } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Display text cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select linkid from links where displaytxt=\"$name\" and linkid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select linkid from links where displaytxt=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\" and linkid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\""))) { + $nameunique = FALSE; echo " Display text already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } // test for urltxt supplied if (strlen(trim($url))) { - $urlsuppld=1; + $urlsuppld = TRUE; } else { - $urlsuppld=0; + $urlsuppld = FALSE; echo " URL text cannot be blank.
"; } if ($namesuppld && $nameunique && $urlsuppld) { // bump entries with linkpriority higher than belowlink up by one if necessary - $mypriority=$belowlink+1; - if (mysqli_num_rows(mysqli_query($db,"select linkpriority from links where linkpriority=\"$mypriority\""))) { - mysqli_query($db,"update links set linkpriority=linkpriority+1 where linkpriority>\"$belowlink\""); + $mypriority = $belowlink + 1; + if (mysqli_num_rows(mysqli_query($db, "select linkpriority from links where linkpriority=\"$mypriority\""))) { + mysqli_query($db, "update links set linkpriority=linkpriority+1 where linkpriority>\"$belowlink\""); } // update the link - mysqli_query($db,"update links set linkpriority=\"$mypriority\",displaytxt=\"$name\",urltxt=\"$url\",status=\"$active\" where linkid=\"$id\""); + mysqli_query($db, "update links set linkpriority=\"$mypriority\",displaytxt=\"$name\",urltxt=\"$url\",status=\"$active\" where linkid=\"$id\""); } } break; case "flags": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; if ($delete) { // check for things using this flag - if (mysqli_num_rows(mysqli_query($db,"select * from flag_$id"))) { - $used=1; + if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$id\""))) { + $used = TRUE; echo " Flag is used by other tables and cannot be deleted.
"; } else { - $used=0; + $used = FALSE; } if (!$used) { // delete entity - mysqli_query($db,"delete from flags where flagid=\"$id\""); - mysqli_query($db,"drop table flag_$id"); + mysqli_query($db, "delete from flags where flagid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Flag name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagname=\"$name\" and flagid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\" and flagid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\""))) { + $nameunique = FALSE; echo " Flag name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } // test for symbol supplied if (strlen(trim($flagsym))) { - $symsuppld=1; + $symsuppld = TRUE; } else { - $symsuppld=0; + $symsuppld = FALSE; echo " Flag symbol cannot be blank.
"; } // test for symbol unique - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagsym=\"$flagsym\" and flagid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagsym=\"$flagsym\""))) { - $symunique=0; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\" and flagid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\""))) { + $symunique = FALSE; echo " Flag symbol already exists.
"; } else { - $symunique=1; + $symunique = TRUE; } } else { - $symunique=1; + $symunique = TRUE; } if ($namesuppld && $nameunique && $symsuppld && $symunique) { // modify the table - mysqli_query($db,"update flags set flagname=\"$name\",flagsym=\"$flagsym\",flagcolor=\"$flagcolor\",status=\"$active\" where flagid=\"$id\""); + mysqli_query($db, "update flags set flagname=\"$name\",flagsym=\"$flagsym\",flagcolor=\"$flagcolor\",status=\"$active\" where flagid=\"$id\""); } } break; case "logpartactions": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; if ($delete) { // check for logparts with this part action - if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where action=\"$id\""))) { - $hasparts=1; + if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where action=\"$id\""))) { + $hasparts = TRUE; echo " Action is assigned to parts in logbook notes and cannot be deleted.
"; } else { - $hasparts=0; + $hasparts = FALSE; } if (!$hasparts) { // delete entity - mysqli_query($db,"delete from logpartactions where lpactionid=\"$id\""); + mysqli_query($db, "delete from logpartactions where lpactionid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Part Action name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select lpactionid from logpartactions where lpactionname=\"$name\" and lpactionid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select lpactionid from logpartactions where lpactionname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\" and lpactionid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\""))) { + $nameunique = FALSE; echo " Part Action name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - mysqli_query($db,"update logpartactions set lpactionname=\"$name\",status=\"$active\" where lpactionid=\"$id\""); + mysqli_query($db, "update logpartactions set lpactionname=\"$name\",status=\"$active\" where lpactionid=\"$id\""); } } break; case "banners": if ($delete) { // delete entity - mysqli_query($db,"delete from banners where bannerid=\"$id\""); + mysqli_query($db, "delete from banners where bannerid=\"$id\""); } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Banner name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select bannerid from banners where bannername=\"$name\" and bannerid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select bannerid from banners where bannername=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\" and bannerid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\""))) { + $nameunique = FALSE; echo " Banner name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - mysqli_query($db,"update banners set bannername=\"$name\",bannercolor=\"$bnrcolor\",textcolor=\"$bnrtxtcolor\" where bannerid=\"$id\""); + mysqli_query($db, "update banners set bannername=\"$name\",bannercolor=\"$bnrcolor\",textcolor=\"$bnrtxtcolor\" where bannerid=\"$id\""); } } break; - case "configs" : - switch($type) { - case "display" : - if ($display_showts) $display_showts=1; else $display_showts=0; - if ($display_techalpha=="a") $display_techalpha=1; else $display_techalpha=0; - if ($display_subjalpha=="a") $display_subjalpha=1; else $display_subjalpha=0; + case "configs": + switch ($type) { + case "display": + if ($display_showts) $display_showts = 1; + else $display_showts = 0; + if ($display_techalpha == "a") $display_techalpha = 1; + else $display_techalpha = 0; + if ($display_subjalpha == "a") $display_subjalpha = 1; + else $display_subjalpha = 0; // test for logname supplied if (strlen(trim($display_logname))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Log name cannot be blank.
"; } // test for urlchunk supplied if (strlen(trim($display_urlchunk))) { - $chunksuppld=1; + $chunksuppld = TRUE; } else { - $chunksuppld=0; + $chunksuppld = FALSE; echo " URL chunk size cannot be blank.
"; } if ($namesuppld && $chunksuppld) { - mysqli_query($db,"update configs set confvalue=\"$display_logname\" where confname=\"log_name\""); - mysqli_query($db,"update configs set confvalue=\"$display_urlchunk\" where confname=\"url_chunk_size\""); - mysqli_query($db,"update configs set confvalue=\"$display_banner\" where confname=\"banner\""); - mysqli_query($db,"update configs set confvalue=\"$display_footer\" where confname=\"footer_message\""); - mysqli_query($db,"update configs set confvalue=\"$display_showts\" where confname=\"show_ts\""); - mysqli_query($db,"update configs set confvalue=\"$display_techalpha\" where confname=\"tech_alpha\""); - mysqli_query($db,"update configs set confvalue=\"$display_subjalpha\" where confname=\"subj_alpha\""); - mysqli_query($db,"update configs set confvalue=\"$display_logstyle\" where confname=\"log_style\""); - mysqli_query($db,"update configs set confvalue=\"$display_uidtext\" where confname=\"uid_text\""); - } + mysqli_query($db, "update configs set confvalue=\"$display_logname\" where confname=\"log_name\""); + mysqli_query($db, "update configs set confvalue=\"$display_urlchunk\" where confname=\"url_chunk_size\""); + mysqli_query($db, "update configs set confvalue=\"$display_banner\" where confname=\"banner\""); + mysqli_query($db, "update configs set confvalue=\"$display_footer\" where confname=\"footer_message\""); + mysqli_query($db, "update configs set confvalue=\"$display_showts\" where confname=\"show_ts\""); + mysqli_query($db, "update configs set confvalue=\"$display_techalpha\" where confname=\"tech_alpha\""); + mysqli_query($db, "update configs set confvalue=\"$display_subjalpha\" where confname=\"subj_alpha\""); + mysqli_query($db, "update configs set confvalue=\"$display_logstyle\" where confname=\"log_style\""); + mysqli_query($db, "update configs set confvalue=\"$display_uidtext\" where confname=\"uid_text\""); + } break; - case "color" : - $hexcolor="#".ltrim($hexcolor); - mysqli_query($db,"update configs set confvalue=\"$hexcolor\" where confname=\"$modcolor\""); + case "color": + $hexcolor = "#" . ltrim($hexcolor); + mysqli_query($db, "update configs set confvalue=\"$hexcolor\" where confname=\"$modcolor\""); break; case "misc": if ($misc_partfuncs) { - mysqli_query($db,"update configs set confvalue=\"1\" where confname=\"parts_functions\""); + mysqli_query($db, "update configs set confvalue=\"1\" where confname=\"parts_functions\""); } else { - mysqli_query($db,"update configs set confvalue=\"0\" where confname=\"parts_functions\""); + mysqli_query($db, "update configs set confvalue=\"0\" where confname=\"parts_functions\""); } if ($misc_logoutall) { if ($ostype == 'WIN') { - $sessfileloc=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"win_server_session_dir\""))[0]; + $sessfileloc = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"win_server_session_dir\""))[0]; } else { - $sessfileloc=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"unix_server_session_dir\""))[0]; + $sessfileloc = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"unix_server_session_dir\""))[0]; } - foreach (glob($sessfileloc."/*") as $sessfile) { + foreach (glob($sessfileloc . "/*") as $sessfile) { unlink($sessfile); } } if ($misc_schedmaintfuncs) { - mysqli_query($db,"update configs set confvalue=\"1\" where confname=\"schedmaint_functions\""); + mysqli_query($db, "update configs set confvalue=\"1\" where confname=\"schedmaint_functions\""); } else { - mysqli_query($db,"update configs set confvalue=\"0\" where confname=\"schedmaint_functions\""); + mysqli_query($db, "update configs set confvalue=\"0\" where confname=\"schedmaint_functions\""); } // test for sessttl supplied if (strlen(trim($misc_sessttl))) { - $ttlsuppld=1; + $ttlsuppld = TRUE; } else { - $ttlsuppld=0; + $ttlsuppld = FALSE; echo " Session expiration time cannot be blank.
"; } // test for sessdir supplied if (strlen(trim($misc_sessdir))) { - $dirsuppld=1; + $dirsuppld = TRUE; } else { - $dirsuppld=0; + $dirsuppld = FALSE; echo " Server session file directory cannot be blank.
"; } if ($ttlsuppld && $dirsuppld) { - mysqli_query($db,"update configs set confvalue=\"$misc_sessttl\" where confname=\"session_ttl_days\""); + mysqli_query($db, "update configs set confvalue=\"$misc_sessttl\" where confname=\"session_ttl_days\""); if ($ostype == 'WIN') { - mysqli_query($db,"update configs set confvalue=\"$misc_sessdir\" where confname=\"win_server_session_dir\""); + mysqli_query($db, "update configs set confvalue=\"$misc_sessdir\" where confname=\"win_server_session_dir\""); } else { - mysqli_query($db,"update configs set confvalue=\"$misc_sessdir\" where confname=\"unix_server_session_dir\""); + mysqli_query($db, "update configs set confvalue=\"$misc_sessdir\" where confname=\"unix_server_session_dir\""); } } break; - default : + default: echo "Unknown config type!"; break; } break; - default : - framework("begin","$logname Administration","Error",$print); + default: + framework("begin", "$logname Administration", "Error", $print); echo "unknown table"; - framework("end","","",$print); + framework("end", "", "", $print); exit(); } } // ******** end database manipulation ******** } - + // show help echo "
Changes made here are global and affect all users. You must have admin privileges to make changes to these settings. To set your personal preferences, you should use the My Profile page. "; - + sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); -banner($print); +pageblock("right", "begin"); +banner($print); // show the menu of tables echo " @@ -735,47 +748,47 @@ echo "

"; -switch($table) { - case "techs" : - if ($isadmin) { +switch ($table) { + case "techs": + if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Tech

"; - $formtag="
"; - $buttontags=" + $sectiontitle = "Modify Tech

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from techs where techid=$id")); - $name=$currentvalues["techname"]; - $pass=$passconf="password_is_unchanged"; - $shift=$currentvalues["shift"]; - if ($currentvalues["admin"]==1) { - $admintag=""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from techs where techid=$id")); + $name = $currentvalues["techname"]; + $pass = $passconf = "password_is_unchanged"; + $shift = $currentvalues["shift"]; + if ($currentvalues["admin"] == 1) { + $admintag = ""; } else { - $admintag=""; + $admintag = ""; } - if ($currentvalues["status"]==1) { - $activetag=""; + if ($currentvalues["status"] == 1) { + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Tech

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Tech

"; + $formtag = ""; + $buttontags = " "; // set default values - $admintag=""; - $activetag=""; + $admintag = ""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -786,18 +799,18 @@ switch($table) { Repeat Password:  

Need a random password?   "; - $rpw=substr(str_shuffle(password_hash(microtime(),PASSWORD_DEFAULT)), 10, 12); + $rpw = substr(str_shuffle(password_hash(microtime(), PASSWORD_DEFAULT)), 10, 12); echo "  $rpw

Shift:            
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from shifts where shiftid=$id")); - $name=$currentvalues["shiftname"]; - if ($currentvalues["status"]==1) { - $activetag=""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from shifts where shiftid=$id")); + $name = $currentvalues["shiftname"]; + if ($currentvalues["status"] == 1) { + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Shift

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Shift

"; + $formtag = ""; + $buttontags = " "; // set default values - $activetag=""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -894,62 +910,65 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select shiftid,shiftname,status from shifts order by shiftid asc"); + $existingdata = mysqli_query($db, "select shiftid,shiftname,status from shifts order by shiftid asc"); echo " Existing Shifts   Click on the Shift ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { if ($tablerow["status"]) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " ", - $tablerow["shiftid"],$tablerow["shiftid"], - $tablerow["shiftname"], - $statdef); + $tablerow["shiftid"], + $tablerow["shiftid"], + $tablerow["shiftname"], + $statdef + ); } echo "
Shift IDShift NameActive
%s %s %s
"; break; - case "subjects" : + case "subjects": if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Subject

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Subject

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from subjects where subjectid=$id")); - $name=$currentvalues["subjectname"]; - if ($currentvalues["status"]==1) { - $activetag=""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from subjects where subjectid=$id")); + $name = $currentvalues["subjectname"]; + if ($currentvalues["status"] == 1) { + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Subject

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Subject

"; + $formtag = ""; + $buttontags = " "; // set default values - $activetag=""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -965,100 +984,103 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select subjectid,subjectname,status from subjects order by subjectid asc"); + $existingdata = mysqli_query($db, "select subjectid,subjectname,status from subjects order by subjectid asc"); echo " Existing Subjects   Click on the Subject ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { if ($tablerow["status"]) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " ", - $tablerow["subjectid"],$tablerow["subjectid"], - $tablerow["subjectname"], - $statdef); + $tablerow["subjectid"], + $tablerow["subjectid"], + $tablerow["subjectname"], + $statdef + ); } echo "
Subject IDSubject NameActive
%s %s %s
"; break; - case "links" : + case "links": if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Link

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Link

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from links where linkid=$id")); - $name=$currentvalues["displaytxt"]; - $priority=$currentvalues["linkpriority"]; - $url=$currentvalues["urltxt"]; - if ($currentvalues["status"]==1) { - $activetag=""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from links where linkid=$id")); + $name = $currentvalues["displaytxt"]; + $priority = $currentvalues["linkpriority"]; + $url = $currentvalues["urltxt"]; + if ($currentvalues["status"] == 1) { + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } // determine where we are in the priority stack - $prow=mysqli_fetch_assoc(mysqli_query($db,"select min(linkpriority) as highest from links")); - if ($prow["highest"]==$priority) { - $belowselection=0; + $prow = mysqli_fetch_assoc(mysqli_query($db, "select min(linkpriority) as highest from links")); + if ($prow["highest"] == $priority) { + $belowselection = 0; } else { - $abovelink=mysqli_fetch_row(mysqli_query($db,"select max(linkpriority) from links where linkpriority<\"$priority\"")); - $belowselection=$abovelink[0]; + $abovelink = mysqli_fetch_row(mysqli_query($db, "select max(linkpriority) from links where linkpriority<\"$priority\"")); + $belowselection = $abovelink[0]; } - $priorselect=""; + if ($belowselection == 0) { + $priorselect = $priorselect . ""; } else { - $priorselect=$priorselect . ""; + $priorselect = $priorselect . ""; } - $linkrow=mysqli_query($db,"select linkpriority,displaytxt from links order by linkpriority asc"); - while ($linkitem=mysqli_fetch_assoc($linkrow)) { - if ($belowselection==$linkitem["linkpriority"]) { - $priorselect=$priorselect . "\n"; + $linkrow = mysqli_query($db, "select linkpriority,displaytxt from links order by linkpriority asc"); + while ($linkitem = mysqli_fetch_assoc($linkrow)) { + if ($belowselection == $linkitem["linkpriority"]) { + $priorselect = $priorselect . "\n"; } else { - $priorselect=$priorselect . "\n"; + $priorselect = $priorselect . "\n"; } } - $priorselect=$priorselect . ""; + $priorselect = $priorselect . ""; } else { // set form options for add - $sectiontitle="Add New Link

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Link

"; + $formtag = ""; + $buttontags = " "; // set default values - $abovelink=mysqli_fetch_row(mysqli_query($db,"select max(linkpriority) from links")); - $belowselection=$abovelink[0]; - $priorselect=""; + $priorselect = $priorselect . ""; + $linkrow = mysqli_query($db, "select linkpriority,displaytxt from links order by linkpriority asc"); + while ($linkitem = mysqli_fetch_assoc($linkrow)) { + if ($belowselection == $linkitem["linkpriority"]) { + $priorselect = $priorselect . "\n"; } else { - $priorselect=$priorselect . "\n"; + $priorselect = $priorselect . "\n"; } } - $priorselect=$priorselect . ""; - $activetag=""; + $priorselect = $priorselect . ""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -1078,83 +1100,87 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select linkid,displaytxt,urltxt,status from links order by linkpriority asc"); + $existingdata = mysqli_query($db, "select linkid,displaytxt,urltxt,status from links order by linkpriority asc"); echo " Existing Links   Click on the Link ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { if ($tablerow["status"]) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " ", - $tablerow["linkid"],$tablerow["linkid"], - $tablerow["displaytxt"], - $tablerow["urltxt"],$tablerow["urltxt"], - $statdef); + $tablerow["linkid"], + $tablerow["linkid"], + $tablerow["displaytxt"], + $tablerow["urltxt"], + $tablerow["urltxt"], + $statdef + ); } echo "
Link IDDisplay TextURLActive
%s %s %s %s
"; break; - case "flags" : + case "flags": if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Flag

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Flag

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=$id")); - $name=$currentvalues["flagname"]; - $flagsym=$currentvalues["flagsym"]; - $flagcolor=$currentvalues["flagcolor"]; - $flagcoloropts=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$flagcolor) { - $flagcoloropts=$flagcoloropts . ""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=$id")); + $name = $currentvalues["flagname"]; + $flagsym = $currentvalues["flagsym"]; + $flagcolor = $currentvalues["flagcolor"]; + $flagcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $flagcolor) { + $flagcoloropts = $flagcoloropts . ""; } else { - $flagcoloropts=$flagcoloropts . ""; + $flagcoloropts = $flagcoloropts . ""; } } - if ($currentvalues["status"]==1) { - $activetag=""; + if ($currentvalues["status"] == 1) { + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Flag

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Flag

"; + $formtag = ""; + $buttontags = " "; // set default values - $flagcolor="#FFFFFF"; - $flagcoloropts=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$flagcolor) { - $flagcoloropts=$flagcoloropts . ""; + $flagcolor = "#FFFFFF"; + $flagcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $flagcolor) { + $flagcoloropts = $flagcoloropts . ""; } else { - $flagcoloropts=$flagcoloropts . ""; + $flagcoloropts = $flagcoloropts . ""; } } - $activetag=""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -1175,64 +1201,68 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select * from flags order by flagid asc"); + $existingdata = mysqli_query($db, "select * from flags order by flagid asc"); echo " Existing Flags   Click on the Flag ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { if ($tablerow["status"]) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " ", - $tablerow["flagid"],$tablerow["flagid"], - $tablerow["flagname"], - $tablerow["flagcolor"],$tablerow["flagsym"], - $statdef); + $tablerow["flagid"], + $tablerow["flagid"], + $tablerow["flagname"], + $tablerow["flagcolor"], + $tablerow["flagsym"], + $statdef + ); } echo "
Flag IDFlag NameFlag SymbolActive
%s %s %s %s
"; break; - case "logpartactions" : + case "logpartactions": if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Part Action

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Part Action

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from logpartactions where lpactionid=$id")); - $name=$currentvalues["lpactionname"]; - if ($currentvalues["status"]==1) { - $activetag=""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from logpartactions where lpactionid=$id")); + $name = $currentvalues["lpactionname"]; + if ($currentvalues["status"] == 1) { + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Part Action

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Part Action

"; + $formtag = ""; + $buttontags = " "; // set default values - $activetag=""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -1248,92 +1278,95 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select * from logpartactions order by lpactionid asc"); + $existingdata = mysqli_query($db, "select * from logpartactions order by lpactionid asc"); echo " Existing Part Actions   Click on the Action ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { if ($tablerow["status"]) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " ", - $tablerow["lpactionid"],$tablerow["lpactionid"], - $tablerow["lpactionname"], - $statdef); + $tablerow["lpactionid"], + $tablerow["lpactionid"], + $tablerow["lpactionname"], + $statdef + ); } echo "
Part Action IDPart Action NameActive
%s %s %s
"; break; - case "banners" : + case "banners": if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Banner

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Banner

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from banners where bannerid=$id")); - $name=$currentvalues["bannername"]; - $bnrcolor=$currentvalues["bannercolor"]; - $bnrtextcolor=$currentvalues["textcolor"]; - $bnrcoloropts=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$bnrcolor) { - $bnrcoloropts=$bnrcoloropts . ""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from banners where bannerid=$id")); + $name = $currentvalues["bannername"]; + $bnrcolor = $currentvalues["bannercolor"]; + $bnrtextcolor = $currentvalues["textcolor"]; + $bnrcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $bnrcolor) { + $bnrcoloropts = $bnrcoloropts . ""; } else { - $bnrcoloropts=$bnrcoloropts . ""; + $bnrcoloropts = $bnrcoloropts . ""; } } - $bnrtextcoloropts=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$bnrtextcolor) { - $bnrtextcoloropts=$bnrtextcoloropts . ""; + $bnrtextcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $bnrtextcolor) { + $bnrtextcoloropts = $bnrtextcoloropts . ""; } else { - $bnrtextcoloropts=$bnrtextcoloropts . ""; + $bnrtextcoloropts = $bnrtextcoloropts . ""; } } } else { // set form options for add - $sectiontitle="Add New Banner

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Banner

"; + $formtag = ""; + $buttontags = " "; // set default values - $bnrcolor="#000000"; - $bnrtextcolor="#FFFFFF"; - $bnrcoloropts=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$bnrcolor) { - $bnrcoloropts=$bnrcoloropts . ""; + $bnrcolor = "#000000"; + $bnrtextcolor = "#FFFFFF"; + $bnrcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $bnrcolor) { + $bnrcoloropts = $bnrcoloropts . ""; } else { - $bnrcoloropts=$bnrcoloropts . ""; + $bnrcoloropts = $bnrcoloropts . ""; } } - $bnrtextcoloropts=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$bnrtextcolor) { - $bnrtextcoloropts=$bnrtextcoloropts . ""; + $bnrtextcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $bnrtextcolor) { + $bnrtextcoloropts = $bnrtextcoloropts . ""; } else { - $bnrtextcoloropts=$bnrtextcoloropts . ""; + $bnrtextcoloropts = $bnrtextcoloropts . ""; } } } - + echo " $sectiontitle $formtag @@ -1356,47 +1389,52 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select * from banners where bannerid!=1 order by bannerid asc"); + $existingdata = mysqli_query($db, "select * from banners where bannerid!=1 order by bannerid asc"); echo " Existing Banners   Click on the Banner ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { - printf(" + while ($tablerow = mysqli_fetch_assoc($existingdata)) { + printf( + " ", - $tablerow["bannerid"],$tablerow["bannerid"], - $tablerow["bannercolor"],$tablerow["textcolor"],$tablerow["bannername"]); + $tablerow["bannerid"], + $tablerow["bannerid"], + $tablerow["bannercolor"], + $tablerow["textcolor"], + $tablerow["bannername"] + ); } echo "
Banner IDBanner
%s %s
"; break; - case "configs" : - switch($type) { - case "display" : - $curlname=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"log_name\""))[0]; - $curlchunk=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"url_chunk_size\""))[0]; - $curbnr=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"banner\""))[0]; - $curftr=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"footer_message\""))[0]; - $curts=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"show_ts\""))[0]; - $curtdo=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"tech_alpha\""))[0]; - $cursdo=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"subj_alpha\""))[0]; - $curlogstyle=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"log_style\""))[0]; - $curuidtxt=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"uid_text\""))[0]; + case "configs": + switch ($type) { + case "display": + $curlname = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"log_name\""))[0]; + $curlchunk = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"url_chunk_size\""))[0]; + $curbnr = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"banner\""))[0]; + $curftr = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"footer_message\""))[0]; + $curts = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"show_ts\""))[0]; + $curtdo = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"tech_alpha\""))[0]; + $cursdo = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"subj_alpha\""))[0]; + $curlogstyle = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"log_style\""))[0]; + $curuidtxt = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"uid_text\""))[0]; echo "
Display Configuration Parameters


Log Name (will appear at the top of pages and in the titlebar):  

Banner (will appear at the top and bottom of pages):  

Log style (the look of the log notes display):    "; - $templaterow=mysqli_query($db,"select * from notetemplates where tech=\"$techid\" order by templatename asc"); - printf("","0","Select user template"); - while ($templateitem=mysqli_fetch_assoc($templaterow)) { - printf("",$templateitem["templateid"],$templateitem["templatename"]); + $templaterow = mysqli_query($db, "select * from notetemplates where tech=\"$techid\" order by templatename asc"); + printf("", "0", "Select user template"); + while ($templateitem = mysqli_fetch_assoc($templaterow)) { + printf("", $templateitem["templateid"], $templateitem["templatename"]); } echo "  or  @@ -959,10 +979,10 @@ function templateselect($techid,$operation) { echo "    @@ -980,4 +1000,3 @@ function templateselect($techid,$operation) {
"; } -?> diff --git a/distfiles/gpl.php b/distfiles/gpl.php index 3991153..aa66594 100644 --- a/distfiles/gpl.php +++ b/distfiles/gpl.php @@ -10,25 +10,25 @@ include("functions.php"); -$print=$_REQUEST['print'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","OpenLog License","OpenLog License",$print); +framework("begin", "OpenLog License", "OpenLog License", $print); pagetable("begin"); -if(!$print){ - pageblock("left","begin"); - sidemenu(); - pageblock("left","end"); +if (!$print) { + pageblock("left", "begin"); + sidemenu(); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); echo "
             GNU GENERAL PUBLIC LICENSE
@@ -375,10 +375,8 @@ Public License instead of this License.
 
 
"; - -pageblock("right","end"); + +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/logentry.php b/distfiles/logentry.php index 3b11a3b..babe693 100644 --- a/distfiles/logentry.php +++ b/distfiles/logentry.php @@ -10,72 +10,72 @@ include("functions.php"); if (!$_SESSION['login'] && !$_REQUEST['partview']) { - header ("Location: login.php"); + header("Location: login.php"); } -$techid=$_SESSION['login'] ?? NULL; -$isadmin=dblookup($db,"techs","techid","admin",$techid); -$efftechid=$_REQUEST['efftechid'] ?? NULL; -$noteid=$_REQUEST['noteid'] ?? NULL; -$print=$_REQUEST['print'] ?? NULL; -$date=$_REQUEST['date'] ?? NULL; -$time=$_REQUEST['time'] ?? NULL; -$note=$_REQUEST['note'] ?? NULL; -$shift=$_REQUEST['shift'] ?? NULL; -$subject=$_REQUEST['subject'] ?? 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; -$usertemplateid=$_REQUEST['usertemplateid'] ?? NULL; -$globaltemplateid=$_REQUEST['globaltemplateid'] ?? NULL; -$loadtemplate=$_REQUEST['loadtemplate'] ?? NULL; -$templatename=$_REQUEST['templatename'] ?? NULL; -$removepart=$_REQUEST['removepart'] ?? NULL; -$syncflags=$_REQUEST['syncflags'] ?? NULL; -$flags=$_POST['flags'] ?? []; -$uids=$_POST['uids'] ?? []; -$partnums=$_POST['partnums'] ?? []; -$sernums=$_POST['sernums'] ?? []; -$actions=$_POST['actions'] ?? []; -$mfreqs=$_POST['mfreqs'] ?? []; -$schedmaintcomplete=$_REQUEST['schedmaintcomplete'] ?? NULL; -$partview=$_REQUEST['partview'] ?? NULL; +$techid = $_SESSION['login'] ?? NULL; +$isadmin = dblookup($db, "techs", "techid", "admin", $techid); +$efftechid = $_REQUEST['efftechid'] ?? NULL; +$noteid = $_REQUEST['noteid'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$date = $_REQUEST['date'] ?? NULL; +$time = $_REQUEST['time'] ?? NULL; +$note = $_REQUEST['note'] ?? NULL; +$shift = $_REQUEST['shift'] ?? NULL; +$subject = $_REQUEST['subject'] ?? 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; +$usertemplateid = $_REQUEST['usertemplateid'] ?? NULL; +$globaltemplateid = $_REQUEST['globaltemplateid'] ?? NULL; +$loadtemplate = $_REQUEST['loadtemplate'] ?? NULL; +$templatename = $_REQUEST['templatename'] ?? NULL; +$removepart = $_REQUEST['removepart'] ?? NULL; +$syncflags = $_REQUEST['syncflags'] ?? NULL; +$flags = $_POST['flags'] ?? []; +$uids = $_POST['uids'] ?? []; +$partnums = $_POST['partnums'] ?? []; +$sernums = $_POST['sernums'] ?? []; +$actions = $_POST['actions'] ?? []; +$mfreqs = $_POST['mfreqs'] ?? []; +$schedmaintcomplete = $_REQUEST['schedmaintcomplete'] ?? NULL; +$partview = $_REQUEST['partview'] ?? NULL; -$doparts=PARTS_FUNCTIONS; -$logname=LOG_NAME; -$techalpha=TECH_ALPHA; -$subjalpha=SUBJ_ALPHA; -$uidtext=UID_TEXT; +$doparts = PARTS_FUNCTIONS; +$logname = LOG_NAME; +$techalpha = TECH_ALPHA; +$subjalpha = SUBJ_ALPHA; +$uidtext = UID_TEXT; -$defaultshift=dblookup($db,"techs","techid","shift",$techid); +$defaultshift = dblookup($db, "techs", "techid", "shift", $techid); -if ($print=="Printer Friendly") { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; +if ($print == "Printer Friendly") { + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -if ($partview) $edit=1; -if (!$add && !$edit && !$delete && !$submit) $add=1; +if ($partview) $edit = 1; +if (!$add && !$edit && !$delete && !$submit) $add = 1; if ($isadmin) { - $authorized=TRUE; + $authorized = TRUE; } else { - $authorized=FALSE; + $authorized = FALSE; } if ($add) { - framework("begin","$logname","Note Entry",$print); - $authorized=TRUE; + framework("begin", "$logname", "Note Entry", $print); + $authorized = TRUE; } if ($edit || $delete) { - framework("begin","$logname","Note Edit",$print); - $owner=dblookup($db,"lognotes","lognoteid","tech",$noteid); - if ($techid==$owner) $authorized=TRUE; + framework("begin", "$logname", "Note Edit", $print); + $owner = dblookup($db, "lognotes", "lognoteid", "tech", $noteid); + if ($techid == $owner) $authorized = TRUE; } // var_dump($_REQUEST); @@ -83,163 +83,162 @@ if ($edit || $delete) { // ******** begin database manipulation ******** if ($usertemplateid) { - $templateid=$usertemplateid; + $templateid = $usertemplateid; } else if ($globaltemplateid) { - $templateid=$globaltemplateid; + $templateid = $globaltemplateid; } else { - $templateid=NULL; - $loadtemplate=NULL; + $templateid = NULL; + $loadtemplate = NULL; } -if ($add) { - if ($submit) { +if ($add) { + if ($submit) { // add the entry if submit is pressed if ($note) { // sanitize and fix blank date and time - $date=mysqli_real_escape_string($db,$date); - $time=mysqli_real_escape_string($db,$time); - if (!$date) $date=$today; - if (!$time) $time=$now; + $date = mysqli_real_escape_string($db, $date); + $time = mysqli_real_escape_string($db, $time); + if (!$date) $date = $today; + if (!$time) $time = $now; // determine whether supplied date is future or past - $datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$date\",CURRENT_DATE)")); + $datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$date\",CURRENT_DATE)")); // if future, set time to 00:00:01, if past, set to 23:59:59 - if ($datediff[0]<0) { - $time="23:59:59"; + if ($datediff[0] < 0) { + $time = "23:59:59"; } - if ($datediff[0]>0) { - $time="00:00:01"; + if ($datediff[0] > 0) { + $time = "00:00:01"; } - + // remove html tags from note text and sanitize - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - + $note = strip_tags($note, ""); + $note = mysqli_real_escape_string($db, $note); + 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); + $refstring = preg_replace("#[^\d ]{1,}#", " ", $refstring); + $refstring = mysqli_real_escape_string($db, $refstring); + $refstring = trim($refstring); } - - if ($doparts==1) { + + if ($doparts == 1) { // inspect part data - $maxplidx=max( - max(array_keys($uids)), - max(array_keys($partnums)), - max(array_keys($sernums)) + $maxplidx = max( + max(array_keys($uids)), + max(array_keys($partnums)), + max(array_keys($sernums)) ); - for ($plidx=0;$plidx<=$maxplidx;$plidx++) { + for ($plidx = 0; $plidx <= $maxplidx; $plidx++) { // for each part line, see what info is available // if uid or pn/sn supplied, pull other info from parts if ($uids[$plidx] != "") { // see if this uid is in parts table. - $uidqry=mysqli_query($db,"select * from parts where uid=\"$uids[$plidx]\""); + $uidqry = mysqli_query($db, "select * from parts where uid=\"$uids[$plidx]\""); if (mysqli_num_rows($uidqry)) { // if so, populate pn/sn - $uiddata=mysqli_fetch_assoc($uidqry); - $partnums[$plidx]=$uiddata['partnum']; - $sernums[$plidx]=$uiddata['sernum']; + $uiddata = mysqli_fetch_assoc($uidqry); + $partnums[$plidx] = $uiddata['partnum']; + $sernums[$plidx] = $uiddata['sernum']; } } if ($partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if this pn/sn is in parts table. - $pnsnqry=mysqli_query($db,"select * from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""); + $pnsnqry = mysqli_query($db, "select * from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""); if (mysqli_num_rows($pnsnqry)) { // if so, populate uid - $pnsndata=mysqli_fetch_assoc($pnsnqry); - $uids[$plidx]=$pnsndata['uid']; + $pnsndata = mysqli_fetch_assoc($pnsnqry); + $uids[$plidx] = $pnsndata['uid']; } } } } if ($authorized) { // add the record to lognotes - mysqli_query($db,"insert into lognotes(date,time,shift,tech,subject,lognote) values (\"$date\", \"$time\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")"); - $newnoteid=mysqli_insert_id($db); - + 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 references to the reflinks table if (strlen($refstring)) { - $refstring=trim($refstring); - $refarray=explode(" ",$refstring); + $refstring = trim($refstring); + $refarray = explode(" ", $refstring); foreach ($refarray as $target) { - mysqli_query($db,"insert into reflinks(noteid,target) values($newnoteid,$target)"); + mysqli_query($db, "insert into reflinks(noteid,target) values($newnoteid,$target)"); } } - $chainmembers=generate_chain($newnoteid); - + $chainmembers = generate_chain($newnoteid); + // update the flagmap table foreach ($flags as $thisflag) { // set flag for this note - mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$newnoteid\")"); + mysqli_query($db, "insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$newnoteid\")"); if ($syncflags) { //set flag for reference chain notes foreach ($chainmembers as $refdnote) { if ($refdnote != $newnoteid) { - mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")"); + mysqli_query($db, "insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")"); } } } } - - if ($doparts==1) { + + if ($doparts == 1) { // now run through the part lines - for ($plidx=0;$plidx<=$maxplidx;$plidx++) { + for ($plidx = 0; $plidx <= $maxplidx; $plidx++) { // update the parts table - + // if this line includes a uid and a pn/sn if ($uids[$plidx] != "" && $partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if it's in the parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { // if not, add it to parts - mysqli_query($db,"insert into parts(uid,partnum,sernum) values(\"$uids[$plidx]\",\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(uid,partnum,sernum) values(\"$uids[$plidx]\",\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); } - - // if this line includes a uid only + + // if this line includes a uid only } else if ($uids[$plidx] != "" && $partnums[$plidx] == "" && $sernums[$plidx] == "") { // see if this uid is in parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum is NULL and sernum is NULL"))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum is NULL and sernum is NULL"))) { // if not, add it to parts - mysqli_query($db,"insert into parts(uid) values(\"$uids[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(uid) values(\"$uids[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); } - - // if this line includes a pn/sn only + + // if this line includes a pn/sn only } else if ($uids[$plidx] == "" && $partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if this pn/sn is in the parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid is NULL and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid is NULL and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { // if not, add it to parts - mysqli_query($db,"insert into parts(partnum,sernum) values(\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(partnum,sernum) values(\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); } - } else { // no part info was entered } @@ -249,58 +248,58 @@ if ($add) { } } 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]; - } + $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]; + } } } } if ($edit) { - if ($removepart && $authorized) mysqli_query($db,"delete from logparts where lognoteid=\"$noteid\" and logpartid=\"$removepart\""); + if ($removepart && $authorized) mysqli_query($db, "delete from logparts where lognoteid=\"$noteid\" and logpartid=\"$removepart\""); if ($submit) { if ($note) { // remove cruft from note text - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - + $note = strip_tags($note, ""); + $note = mysqli_real_escape_string($db, $note); + // remove cruft from references if (strlen($refstring)) { - $refstring=trim($refstring); - $refstring=preg_replace("#[a-zA-Z]{1,}#","",$refstring); + $refstring = trim($refstring); + $refstring = preg_replace("#[a-zA-Z]{1,}#", "", $refstring); } - - if ($doparts==1) { + + if ($doparts == 1) { // inspect part data - $maxplidx=max( - max(array_keys($uids)), - max(array_keys($partnums)), - max(array_keys($sernums)) + $maxplidx = max( + max(array_keys($uids)), + max(array_keys($partnums)), + max(array_keys($sernums)) ); - for ($plidx=0;$plidx<=$maxplidx;$plidx++) { + for ($plidx = 0; $plidx <= $maxplidx; $plidx++) { // for each part line, see what info is available // if uid or pn/sn supplied, pull other info from parts if ($uids[$plidx] != "") { // see if this uid is in parts table. - $uidqry=mysqli_query($db,"select * from parts where uid=\"$uids[$plidx]\""); + $uidqry = mysqli_query($db, "select * from parts where uid=\"$uids[$plidx]\""); if (mysqli_num_rows($uidqry)) { // if so, populate pn/sn - $uiddata=mysqli_fetch_assoc($uidqry); - $partnums[$plidx]=$uiddata['partnum']; - $sernums[$plidx]=$uiddata['sernum']; + $uiddata = mysqli_fetch_assoc($uidqry); + $partnums[$plidx] = $uiddata['partnum']; + $sernums[$plidx] = $uiddata['sernum']; } } if ($partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if this pn/sn is in parts table. - $pnsnqry=mysqli_query($db,"select * from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""); + $pnsnqry = mysqli_query($db, "select * from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""); if (mysqli_num_rows($pnsnqry)) { // if so, populate uid - $pnsndata=mysqli_fetch_assoc($pnsnqry); - $uids[$plidx]=$pnsndata['uid']; + $pnsndata = mysqli_fetch_assoc($pnsnqry); + $uids[$plidx] = $pnsndata['uid']; } } } @@ -308,102 +307,101 @@ 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\" 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 reflinks table - mysqli_query($db,"delete from reflinks where noteid=\"$noteid\""); + 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\")"); + $refstring = trim($refstring); + $refarray = explode(" ", $refstring); + foreach ($refarray as $thisref) { + mysqli_query($db, "insert into reflinks(noteid,target) values(\"$noteid\",\"$thisref\")"); } } - $chainmembers=generate_chain($noteid); - + $chainmembers = generate_chain($noteid); + // update the flagmap table - mysqli_query($db,"delete from flagmap where lognoteid=\"$noteid\""); + 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\""); + mysqli_query($db, "delete from flagmap where lognoteid=\"$refdnote\""); } } } foreach ($flags as $thisflag) { // set flag for this note - mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$noteid\")"); + 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\")"); + mysqli_query($db, "insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")"); } } } } - - if ($doparts==1) { + + if ($doparts == 1) { // run through the new part lines - for ($plidx=0;$plidx<=$maxplidx;$plidx++) { + for ($plidx = 0; $plidx <= $maxplidx; $plidx++) { // update the parts table - + // if this line includes a uid and a pn/sn if ($uids[$plidx] != "" && $partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if it's in the parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { // if not, add it to parts - mysqli_query($db,"insert into parts(uid,partnum,sernum) values(\"$uids[$plidx]\",\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(uid,partnum,sernum) values(\"$uids[$plidx]\",\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); } - - // if this line includes a uid only + + // if this line includes a uid only } else if ($uids[$plidx] != "" && $partnums[$plidx] == "" && $sernums[$plidx] == "") { // see if this uid is in parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum is NULL and sernum is NULL"))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum is NULL and sernum is NULL"))) { // if not, add it to parts - mysqli_query($db,"insert into parts(uid) values(\"$uids[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(uid) values(\"$uids[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); } - - // if this line includes a pn/sn only + + // if this line includes a pn/sn only } else if ($uids[$plidx] == "" && $partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if this pn/sn is in the parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid is NULL and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid is NULL and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { // if not, add it to parts - mysqli_query($db,"insert into parts(partnum,sernum) values(\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(partnum,sernum) values(\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); } - } else { - // no part info was entered + // no part info was entered ; } } @@ -413,95 +411,95 @@ if ($edit) { } if ($loadtemplate) { // get the note in question from the selected template - $getnote=mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\""); + $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\""); + $getnote = mysqli_query($db, "select * from lognotes where lognoteid=\"$noteid\""); } - $notetoedit=mysqli_fetch_assoc($getnote); + $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"]; + $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"]; + $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\")"); + 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\")"); - + 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\""); - + mysqli_query($db, "delete from lognotes where lognoteid=\"$noteid\""); + // delete occurances from the flagmap table - mysqli_query($db,"delete from flagmap where lognoteid=\"$noteid\""); - + mysqli_query($db, "delete from flagmap where lognoteid=\"$noteid\""); + // delete occurances from the logparts table - mysqli_query($db,"delete from logparts where lognoteid=\"$noteid\""); + mysqli_query($db, "delete from logparts where lognoteid=\"$noteid\""); } // ******** end database manipulation ******** pagetable("begin"); if (!$print) { - pageblock("left","begin"); + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); // display the form if ($add) { - $notedate=$today; - $notetime=$now; + $notedate = $today; + $notetime = $now; } if ($edit || $delete) { - $notedate=$notetoedit["date"] ?? $today; - $notetime=$notetoedit["time"] ?? $now; - $defaultshift=$notetoedit["shift"]; - $defaultsubject=$notetoedit["subject"]; - - $note=$notetoedit["lognote"]; + $notedate = $notetoedit["date"] ?? $today; + $notetime = $notetoedit["time"] ?? $now; + $defaultshift = $notetoedit["shift"]; + $defaultsubject = $notetoedit["subject"]; + + $note = $notetoedit["lognote"]; // generate reference string for this note if ($submit) { - $refstring=NULL; + $refstring = NULL; } - $refstringqry=mysqli_query($db,"select target from reflinks where noteid=\"$noteid\""); - while ($thistgt=mysqli_fetch_row($refstringqry)) { - $refstring=$refstring." ".$thistgt[0]; + $refstringqry = mysqli_query($db, "select target from reflinks where noteid=\"$noteid\""); + while ($thistgt = mysqli_fetch_row($refstringqry)) { + $refstring = $refstring . " " . $thistgt[0]; } - $techid=$notetoedit["tech"]; + $techid = $notetoedit["tech"]; } -$techname=dblookup($db,"techs","techid","techname",$techid); +$techname = dblookup($db, "techs", "techid", "techname", $techid); if ($submit) { if ($note) { if ($add) { - format_message(0,"Note added. You may enter another note or return to main page."); + format_message(0, "Note added. You may enter another note or return to main page."); } if ($edit) { - format_message(0,"Note changed. Return to main page."); + format_message(0, "Note changed. Return to main page."); } } else { - format_message(1,"You didn't enter any note text. Please try again."); + format_message(1, "You didn't enter any note text. Please try again."); } } if ($delete) { - format_message(0,"Note deleted. Return to main page."); + format_message(0, "Note deleted. Return to main page."); } if ($_SESSION['login']) { // show the template selection line - templateselect($techid,NULL); + templateselect($techid, NULL); } // start note entry section @@ -520,14 +518,15 @@ if ($isadmin) { Tech:   "; -$shiftrow=mysqli_query($db,"select * from shifts"); -while ($shiftitem=mysqli_fetch_assoc($shiftrow)) { +$shiftrow = mysqli_query($db, "select * from shifts"); +while ($shiftitem = mysqli_fetch_assoc($shiftrow)) { if ($shiftitem["status"] == 1) { - if ($shiftitem["shiftid"]==$defaultshift) { - printf("",$shiftitem["shiftid"],$shiftitem["shiftname"]); + if ($shiftitem["shiftid"] == $defaultshift) { + printf("", $shiftitem["shiftid"], $shiftitem["shiftname"]); } else { - printf("",$shiftitem["shiftid"],$shiftitem["shiftname"]); + printf("", $shiftitem["shiftid"], $shiftitem["shiftname"]); } } } @@ -563,15 +562,16 @@ echo " Subject:   %s", - $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); +while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { + + if (in_array($flagcheckbox["flagid"], $theseflags)) { + printf( + "%s", + $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("%s", - $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( + "%s", + $flagcheckbox["flagid"], + $flagcheckbox["flagcolor"], + $flagcheckbox["flagname"], + $flagcheckbox["flagsym"] + ); } } - if ($flagcount<$flagsperline) { + if ($flagcount < $flagsperline) { echo "   "; $flagcount++; } else { echo "
"; - $flagcount=1; + $flagcount = 1; } } echo "
Set flags on reference chain "; -if ($add && $refto) $refstring=$refto; +if ($add && $refto) $refstring = $refto; echo "

References:            @@ -652,13 +662,13 @@ if ($add) { "; } if ($doparts) { - $defaultaction=0; + $defaultaction = 0; echo "

"; - for ($partline=0;$partline <=5;$partline++) { + for ($partline = 0; $partline <= 5; $partline++) { echo " @@ -667,13 +677,13 @@ if ($add) { "; // populate the existing part lines - $linekey=0; - $elineqry=mysqli_query($db,"select logpartid, partid, action from logparts where lognoteid=\"$noteid\""); - while ($eline=mysqli_fetch_assoc($elineqry)) { - $iconpartid=$eline['logpartid']; - $lpidvar=$eline['partid']; - $eparts=mysqli_fetch_assoc(mysqli_query($db,"select uid,partnum,sernum from parts where partid=\"$lpidvar\"")); - $epuid=$eparts['uid']; - $eppn=$eparts['partnum']; - $epsn=$eparts['sernum']; - $defaultaction=$eline['action']; - + $linekey = 0; + $elineqry = mysqli_query($db, "select logpartid, partid, action from logparts where lognoteid=\"$noteid\""); + while ($eline = mysqli_fetch_assoc($elineqry)) { + $iconpartid = $eline['logpartid']; + $lpidvar = $eline['partid']; + $eparts = mysqli_fetch_assoc(mysqli_query($db, "select uid,partnum,sernum from parts where partid=\"$lpidvar\"")); + $epuid = $eparts['uid']; + $eppn = $eparts['partnum']; + $epsn = $eparts['sernum']; + $defaultaction = $eline['action']; + echo " "; // find maint form for this line and show link - $mflinknum=mysqli_fetch_assoc(mysqli_query($db,"select maintformid from maintforms where lognoteid=\"$noteid\" and mfpart=\"$lpidvar\""))["maintformid"]; + $mflinknum = mysqli_fetch_assoc(mysqli_query($db, "select maintformid from maintforms where lognoteid=\"$noteid\" and mfpart=\"$lpidvar\""))["maintformid"]; echo " "; } // add six empty part lines - $defaultaction=0; - for ($partline=$linekey;$partline <=$linekey+5;$partline++) { + $defaultaction = 0; + for ($partline = $linekey; $partline <= $linekey + 5; $partline++) { echo " @@ -753,13 +763,13 @@ if ($edit) { "; } else { - $authorized=TRUE; + $authorized = TRUE; echo " "; @@ -416,13 +418,13 @@ if ($operation=="delete") {
$uidtextPart NumberSerial NumberActionMaint Form
$uidtextPart NumberSerial NumberActionMaint Form
@@ -726,9 +736,9 @@ if ($edit) { $epsn "; - $actrow=mysqli_query($db,"select * from logpartactions"); - while ($actitem=mysqli_fetch_assoc($actrow)) { - if ($actitem["lpactionid"]==$defaultaction) { + $actrow = mysqli_query($db, "select * from logpartactions"); + while ($actitem = mysqli_fetch_assoc($actrow)) { + if ($actitem["lpactionid"] == $defaultaction) { echo "$actitem[lpactionname]"; } } @@ -736,15 +746,15 @@ if ($edit) { $mflinknum
"; - if ($techalpha) $torder="techname"; else $torder="techid"; - $techrow=mysqli_query($db,"select * from techs order by $torder asc"); - while ($techitem=mysqli_fetch_assoc($techrow)) { - if ($techitem["status"]==1) { - printf("",$techitem["techid"],$techitem["techname"]); + if ($techalpha) $torder = "techname"; + else $torder = "techid"; + $techrow = mysqli_query($db, "select * from techs order by $torder asc"); + while ($techitem = mysqli_fetch_assoc($techrow)) { + if ($techitem["status"] == 1) { + printf("", $techitem["techid"], $techitem["techname"]); } } echo "

@@ -87,16 +87,14 @@ if ($login) {

"; } else { - $loginid=$_SESSION['login']; - $loggedinas=mysqli_fetch_row(mysqli_query($db,"select techname from techs where techid=\"$loginid\""))[0]; + $loginid = $_SESSION['login']; + $loggedinas = mysqli_fetch_row(mysqli_query($db, "select techname from techs where techid=\"$loginid\""))[0]; echo " You are already logged in as $loggedinas. Please select a menu option at the left to continue.

"; } } -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/lognotes.php b/distfiles/lognotes.php index 13365ca..d1d80d6 100644 --- a/distfiles/lognotes.php +++ b/distfiles/lognotes.php @@ -12,103 +12,107 @@ include("functions.php"); //$tgt_year=$_REQUEST['y']; //$tgt_month=$_REQUEST['m']; //$tgt_day=$_REQUEST['d']; -$tgt_date=$_REQUEST['tgt_date'] ?? ""; -$print=$_REQUEST['print'] ?? ""; -if (isset($_SESSION['login'])) $techid=$_SESSION['login']; +$tgt_date = $_REQUEST['tgt_date'] ?? ""; +$print = $_REQUEST['print'] ?? ""; +if (isset($_SESSION['login'])) $techid = $_SESSION['login']; -$logname=LOG_NAME; -$tablestyle=LOG_STYLE; +$logname = LOG_NAME; +$tablestyle = LOG_STYLE; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } // use default date values if not supplied -if ($tgt_date=="") $tgt_date=$today; +if ($tgt_date == "") $tgt_date = $today; // define shifttable_classic function -function shifttable_classic($shift, $tgt_date, $db) { +function shifttable_classic($shift, $tgt_date, $db) +{ // convert the shift number to a name for display - $doparts=PARTS_FUNCTIONS; - $showtime=SHOW_TS; - $shname=dblookup($db,"shifts","shiftid","shiftname",$shift); - $dshdrdata=mysqli_query($db,"select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\""); - $dshdr=mysqli_fetch_row($dshdrdata); + $doparts = PARTS_FUNCTIONS; + $showtime = SHOW_TS; + $shname = dblookup($db, "shifts", "shiftid", "shiftname", $shift); + $dshdrdata = mysqli_query($db, "select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\""); + $dshdr = mysqli_fetch_row($dshdrdata); if ($dshdr) { // print the shift header - printf("%s\n",$shname); - $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); + printf("%s\n", $shname); + $note = mysqli_query($db, "select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); echo "
\n"; echo "\n"; while ($tablerow = mysqli_fetch_assoc($note)) { - $thisnote=$tablerow["lognoteid"]; - $refs="    \"Add"; + $thisnote = $tablerow["lognoteid"]; + $refs = "    \"Add"; if (islink($thisnote)) { - $refs=$refs."      \"View"; + $refs = $refs . "      \"View"; } // convert tech number to name - $tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]); + $tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]); //convert subject number to name - $subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]); + $subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]); // create links of urls in note - $fmtnote=convertweblinks($tablerow["lognote"]); + $fmtnote = convertweblinks($tablerow["lognote"]); // generate the flags string - $flagstring=""; - $flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote"); - while ($flagid=mysqli_fetch_row($flagqry)) { - $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); - $flagcolor=$flagparams["flagcolor"]; - $flagsym=$flagparams["flagsym"]; - $flagname=$flagparams["flagname"]; - $flagstring=$flagstring."$flagsym  "; + $flagstring = ""; + $flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote"); + while ($flagid = mysqli_fetch_row($flagqry)) { + $flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor = $flagparams["flagcolor"]; + $flagsym = $flagparams["flagsym"]; + $flagname = $flagparams["flagname"]; + $flagstring = $flagstring . "$flagsym  "; } if ($flagstring) { - $fmtnote=$fmtnote."
".$flagstring."     "; - } else { - $fmtnote=$fmtnote."
"; + $fmtnote = $fmtnote . "
" . $flagstring . "     "; + } else { + $fmtnote = $fmtnote . "
"; } - + if ($doparts) { // turn on the parts indicator if parts were entered with the note - if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) { - $fmtnote=$fmtnote."PARTS"; + if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) { + $fmtnote = $fmtnote . "PARTS"; } } // now print the line in the table if ($showtime) { printf( - " + "\n", - $tablerow["lognoteid"],$tablerow["lognoteid"],$tablerow["time"], - $tname, - $subjname, - $fmtnote, - $refs + $tablerow["lognoteid"], + $tablerow["lognoteid"], + $tablerow["time"], + $tname, + $subjname, + $fmtnote, + $refs ); } else { printf( - " + "\n", - $tablerow["lognoteid"],$tablerow["lognoteid"], - $tname, - $subjname, - $fmtnote, - $refs + $tablerow["lognoteid"], + $tablerow["lognoteid"], + $tname, + $subjname, + $fmtnote, + $refs ); } } @@ -121,82 +125,85 @@ function shifttable_classic($shift, $tgt_date, $db) { } // define the shifttable_clean function -function shifttable_clean($shift, $tgt_date, $db) { +function shifttable_clean($shift, $tgt_date, $db) +{ // convert the shift number to a name for display - $doparts=PARTS_FUNCTIONS; - $showtime=SHOW_TS; - $shname=dblookup($db,"shifts","shiftid","shiftname",$shift); - $dshdrdata=mysqli_query($db,"select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\""); - $dshdr=mysqli_fetch_row($dshdrdata); + $doparts = PARTS_FUNCTIONS; + $showtime = SHOW_TS; + $shname = dblookup($db, "shifts", "shiftid", "shiftname", $shift); + $dshdrdata = mysqli_query($db, "select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\""); + $dshdr = mysqli_fetch_row($dshdrdata); if ($dshdr) { // print the shift header - printf("%s\n",$shname); - $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); + printf("%s\n", $shname); + $note = mysqli_query($db, "select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); echo "

"; echo "
Note IDTechSubjectNoteReferences
%s  %s %s %s %s %s
%s %s %s %s %s
", - $def_eventid,$def_deferred_date, - $devicedata_devicedesc,$devicedata_devicename, - $taskdata_taskdesc,$taskdata_taskname, - $lastdatestrg + $def_eventid, + $def_deferred_date, + $devicedata_devicedesc, + $devicedata_devicename, + $taskdata_taskdesc, + $taskdata_taskname, + $lastdatestrg ); } echo " @@ -886,9 +908,7 @@ if ($action) { banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/search.php b/distfiles/search.php index dbae96d..2c63907 100644 --- a/distfiles/search.php +++ b/distfiles/search.php @@ -9,50 +9,50 @@ include("functions.php"); -$noprint=1; +$noprint = TRUE; if (isset($_SESSION['login'])) { - $loggedin=1; + $loggedin = TRUE; } else { - unset($loggedin); + $loggedin = FALSE; } -$print=$_REQUEST['print'] ?? NULL; -$search=$_REQUEST['search'] ?? NULL; -$srchnoteid=$_REQUEST['srchnoteid'] ?? NULL; -$srchmfid=$_REQUEST['srchmfid'] ?? NULL; -$srchbdate=$_REQUEST['srchbdate'] ?? NULL; -$srchedate=$_REQUEST['srchedate'] ?? NULL; -$srchshift=$_REQUEST['srchshift'] ?? NULL; -$srchtech=$_REQUEST['srchtech'] ?? NULL; -$srchsubj=$_REQUEST['srchsubj'] ?? NULL; -$srchtext=$_REQUEST['srchtext'] ?? NULL; -$srchuid=$_REQUEST['srchuid'] ?? NULL; -$srchpn=$_REQUEST['srchpn'] ?? NULL; -$srchsn=$_REQUEST['srchsn'] ?? NULL; -$srchpname=$_REQUEST['srchpname'] ?? NULL; -$srchploc=$_REQUEST['srchploc'] ?? NULL; -$srchnha=$_REQUEST['srchnha'] ?? NULL; -$srchrepord=$_REQUEST['srchrepord'] ?? NULL; -$srchflags=$_POST['srchflags'] ?? []; -$target=$_REQUEST['target'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$search = $_REQUEST['search'] ?? NULL; +$srchnoteid = $_REQUEST['srchnoteid'] ?? NULL; +$srchmfid = $_REQUEST['srchmfid'] ?? NULL; +$srchbdate = $_REQUEST['srchbdate'] ?? NULL; +$srchedate = $_REQUEST['srchedate'] ?? NULL; +$srchshift = $_REQUEST['srchshift'] ?? NULL; +$srchtech = $_REQUEST['srchtech'] ?? NULL; +$srchsubj = $_REQUEST['srchsubj'] ?? NULL; +$srchtext = $_REQUEST['srchtext'] ?? NULL; +$srchuid = $_REQUEST['srchuid'] ?? NULL; +$srchpn = $_REQUEST['srchpn'] ?? NULL; +$srchsn = $_REQUEST['srchsn'] ?? NULL; +$srchpname = $_REQUEST['srchpname'] ?? NULL; +$srchploc = $_REQUEST['srchploc'] ?? NULL; +$srchnha = $_REQUEST['srchnha'] ?? NULL; +$srchrepord = $_REQUEST['srchrepord'] ?? NULL; +$srchflags = $_POST['srchflags'] ?? []; +$target = $_REQUEST['target'] ?? NULL; -$doparts=PARTS_FUNCTIONS; -$logname=LOG_NAME; -$techalpha=TECH_ALPHA; -$subjalpha=SUBJ_ALPHA; -$uidtext=UID_TEXT; +$doparts = PARTS_FUNCTIONS; +$logname = LOG_NAME; +$techalpha = TECH_ALPHA; +$subjalpha = SUBJ_ALPHA; +$uidtext = UID_TEXT; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname Search","Search",$print); +framework("begin", "$logname Search", "Search", $print); // echo "REQUEST variables:
"; // var_dump($_REQUEST); @@ -61,273 +61,273 @@ framework("begin","$logname Search","Search",$print); // ******** begin database manipulation ******** // define the arrays -$logfromtables=[]; -$mffromtables=[]; -$pfromtables=[]; -$logconstraints=[]; -$mfconstraints=[]; -$pconstraints=[]; +$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); -$logmindate=$logdateresults[0]; +$logdateqry = mysqli_query($db, "select min(date), max(date) from lognotes"); +$logdateresults = mysqli_fetch_row($logdateqry); +$logmindate = $logdateresults[0]; if ($logmindate == "") $logmindate = $today; -$logmaxdate=$logdateresults[1]; +$logmaxdate = $logdateresults[1]; if ($logmaxdate == "") $logmaxdate = $today; // get the date range of maintenance forms -$mfdateqry=mysqli_query($db,"select min(mfdate), max(mfdate) from maintforms"); -$mfdateresults=mysqli_fetch_row($mfdateqry); -$mfmindate=$mfdateresults[0]; +$mfdateqry = mysqli_query($db, "select min(mfdate), max(mfdate) from maintforms"); +$mfdateresults = mysqli_fetch_row($mfdateqry); +$mfmindate = $mfdateresults[0]; if ($mfmindate == "") $mfmindate = $today; -$mfmaxdate=$mfdateresults[1]; +$mfmaxdate = $mfdateresults[1]; if ($mfmaxdate == "") $mfmaxdate = $today; // determine entire date range -$mindate=min($logmindate, $mfmindate); -$maxdate=max($logmaxdate, $mfmaxdate); +$mindate = min($logmindate, $mfmindate); +$maxdate = max($logmaxdate, $mfmaxdate); if ($search) { // strip whitespace from beginning and end of text fields - $srchtext=trim($srchtext); - $srchpname=trim($srchpname); - $srchploc=trim($srchploc); - $srchnha=trim($srchnha); - if ($target[0]=="") $target=[]; - if (in_array("log",$target)) { + $srchtext = trim($srchtext); + $srchpname = trim($srchpname); + $srchploc = trim($srchploc); + $srchnha = trim($srchnha); + if ($target[0] == "") $target = []; + if (in_array("log", $target)) { // define the query constraints // log note id if ($srchnoteid != "any" && $srchnoteid != "") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.lognoteid=\"$srchnoteid\""; + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.lognoteid=\"$srchnoteid\""; } // maint form id if ($srchmfid != "any" && $srchmfid != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="maintforms"; - $logconstraints[]="lognotes.lognoteid=maintforms.lognoteid and maintforms.maintformid=\"$srchmfid\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "maintforms"; + $logconstraints[] = "lognotes.lognoteid=maintforms.lognoteid and maintforms.maintformid=\"$srchmfid\""; } // date range if ($srchbdate != "" && $srchedate != "") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.date between \"$srchbdate\" and \"$srchedate\""; + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.date between \"$srchbdate\" and \"$srchedate\""; } // shift - if ($srchshift !="0") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.shift=\"$srchshift\""; + if ($srchshift != "0") { + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.shift=\"$srchshift\""; } // tech - if ($srchtech !="0") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.tech=\"$srchtech\""; + if ($srchtech != "0") { + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.tech=\"$srchtech\""; } // subject - if ($srchsubj !="0") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.subject=\"$srchsubj\""; + if ($srchsubj != "0") { + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.subject=\"$srchsubj\""; } // search text - if ($srchtext !="") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.lognote like \"%$srchtext%\""; + if ($srchtext != "") { + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.lognote like \"%$srchtext%\""; } // flags if (!empty($srchflags)) { unset($flagconstraints); - $flagcount=count($srchflags); - $logfromtables[]="lognotes"; - $logfromtables[]="flagmap"; - $flagconstraints[]="flagmap.lognoteid=lognotes.lognoteid and flagmap.flagid in ("; + $flagcount = count($srchflags); + $logfromtables[] = "lognotes"; + $logfromtables[] = "flagmap"; + $flagconstraints[] = "flagmap.lognoteid=lognotes.lognoteid and flagmap.flagid in ("; foreach ($srchflags as $flagid) { - $flagconstraints[]="\"$flagid\""; - $flagconstraints[]=","; + $flagconstraints[] = "\"$flagid\""; + $flagconstraints[] = ","; } // remove final comma array_splice($flagconstraints, -1, 1); - $flagconstraints[]=") group by flagmap.lognoteid having count(distinct flagmap.flagid)=$flagcount"; + $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); + $logconstraints[] = join('', $flagconstraints); } // uid if ($srchuid != "any" && $srchuid != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.uid=\"{$srchuid}\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.uid=\"{$srchuid}\""; } // part number if ($srchpn != "any" && $srchpn != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.partnum=\"{$srchpn}\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.partnum=\"{$srchpn}\""; } // serial number if ($srchsn != "any" && $srchsn != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.sernum=\"{$srchsn}\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.sernum=\"{$srchsn}\""; } // part name if ($srchpname != "any" && $srchpname != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.partname like \"%{$srchpname}%\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.partname like \"%{$srchpname}%\""; } // part location if ($srchploc != "any" && $srchploc != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logfromtables[]="maintforms"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logfromtables[] = "maintforms"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; } // next higher assembly if ($srchnha != "any" && $srchnha != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logfromtables[]="maintforms"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logfromtables[] = "maintforms"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; } // repair order if ($srchrepord != "any" && $srchrepord != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logfromtables[]="maintforms"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logfromtables[] = "maintforms"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; } // build the clauses and run the query - $logfromclause=implode(",",array_unique($logfromtables)); - $logwhereclause=implode(" and ",$logconstraints); - $logrowqry=mysqli_query($db,"select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc"); + $logfromclause = implode(",", array_unique($logfromtables)); + $logwhereclause = implode(" and ", $logconstraints); + $logrowqry = mysqli_query($db, "select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc"); } - if ($target[0]=="") $target=[]; - if (in_array("maintform",$target)) { + if ($target[0] == "") $target = []; + if (in_array("maintform", $target)) { // maintforms search // define the query constraints // log note id if ($srchnoteid != "any" && $srchnoteid != "") { - $mffromtables[]="maintforms"; - $mffromtables[]="lognotes"; - $mfconstraints[]="maintforms.lognoteid=lognotes.lognoteid and lognotes.lognoteid=\"$srchnoteid\""; + $mffromtables[] = "maintforms"; + $mffromtables[] = "lognotes"; + $mfconstraints[] = "maintforms.lognoteid=lognotes.lognoteid and lognotes.lognoteid=\"$srchnoteid\""; } // maint form id if ($srchmfid != "any" && $srchmfid != "") { - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.maintformid=\"$srchmfid\""; + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.maintformid=\"$srchmfid\""; } // date range if ($srchbdate != "" && $srchedate != "") { - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.mfdate between \"$srchbdate\" and \"$srchedate\""; + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.mfdate between \"$srchbdate\" and \"$srchedate\""; } // shift - if ($srchshift !="0") { - $mffromtables[]="maintforms"; - $mffromtables[]="lognotes"; - $mfconstraints[]="maintforms.lognoteid=lognotes.lognoteid and lognotes.shift=\"$srchshift\""; + if ($srchshift != "0") { + $mffromtables[] = "maintforms"; + $mffromtables[] = "lognotes"; + $mfconstraints[] = "maintforms.lognoteid=lognotes.lognoteid and lognotes.shift=\"$srchshift\""; } // tech - if ($srchtech !="0") { - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.mftech=\"$srchtech\""; + if ($srchtech != "0") { + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.mftech=\"$srchtech\""; } // subject - if ($srchsubj !="0") { - $mffromtables[]="maintforms"; - $mffromtables[]="lognotes"; - $mfconstraints[]="maintforms.lognoteid=lognotes.lognoteid and lognotes.subject=\"$srchsubj\""; + if ($srchsubj != "0") { + $mffromtables[] = "maintforms"; + $mffromtables[] = "lognotes"; + $mfconstraints[] = "maintforms.lognoteid=lognotes.lognoteid and lognotes.subject=\"$srchsubj\""; } // search text - if ($srchtext !="") { - $mffromtables[]="maintforms"; - $mffromtables[]="maintactions"; - $mfconstraints[]="maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)"; + if ($srchtext != "") { + $mffromtables[] = "maintforms"; + $mffromtables[] = "maintactions"; + $mfconstraints[] = "maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)"; } // flags if (!empty($srchflags)) { unset($flagconstraints); - $flagcount=count($srchflags); - $mffromtables[]="maintforms"; - $mffromtables[]="flagmap"; - $flagconstraints[]="flagmap.maintformid=maintforms.maintformid and flagmap.flagid in ("; + $flagcount = count($srchflags); + $mffromtables[] = "maintforms"; + $mffromtables[] = "flagmap"; + $flagconstraints[] = "flagmap.maintformid=maintforms.maintformid and flagmap.flagid in ("; foreach ($srchflags as $thisflagid) { - $flagconstraints[]="\"$thisflagid\""; - $flagconstraints[]=","; + $flagconstraints[] = "\"$thisflagid\""; + $flagconstraints[] = ","; } // remove final comma array_splice($flagconstraints, -1, 1); - $flagconstraints[]=") group by flagmap.maintformid having count(distinct flagmap.flagid)=$flagcount"; + $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); + $mfconstraints[] = join('', $flagconstraints); } // uid if ($srchuid != "any" && $srchuid != "") { - $mffromtables[]="maintforms"; - $mffromtables[]="parts"; - $mfconstraints[]="maintforms.mfpart=parts.partid and parts.uid=\"{$srchuid}\""; + $mffromtables[] = "maintforms"; + $mffromtables[] = "parts"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and parts.uid=\"{$srchuid}\""; } // part number if ($srchpn != "any" && $srchpn != "") { - $mffromtables[]="maintforms"; - $mffromtables[]="parts"; - $mfconstraints[]="maintforms.mfpart=parts.partid and parts.partnum=\"{$srchpn}\""; + $mffromtables[] = "maintforms"; + $mffromtables[] = "parts"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and parts.partnum=\"{$srchpn}\""; } // serial number if ($srchsn != "any" && $srchsn != "") { - $mffromtables[]="maintforms"; - $mffromtables[]="parts"; - $mfconstraints[]="maintforms.mfpart=parts.partid and parts.sernum=\"{$srchsn}\""; + $mffromtables[] = "maintforms"; + $mffromtables[] = "parts"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and parts.sernum=\"{$srchsn}\""; } // part name if ($srchpname != "any" && $srchpname != "") { - $mffromtables[]="maintforms"; - $mffromtables[]="parts"; - $mfconstraints[]="maintforms.mfpart=parts.partid and parts.partname like \"%{$srchpname}%\""; + $mffromtables[] = "maintforms"; + $mffromtables[] = "parts"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and parts.partname like \"%{$srchpname}%\""; } // part location if ($srchploc != "any" && $srchploc != "") { - $mffromtables[]="parts"; - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; + $mffromtables[] = "parts"; + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; } // next higher assembly if ($srchnha != "any" && $srchnha != "") { - $mffromtables[]="parts"; - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; + $mffromtables[] = "parts"; + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; } // repair order if ($srchrepord != "any" && $srchrepord != "") { - $mffromtables[]="parts"; - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; + $mffromtables[] = "parts"; + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; } // build the clauses and run the query - $mffromclause=implode(",",array_unique($mffromtables)); - $mfwhereclause=implode(" and ",$mfconstraints); - $mfrowqry=mysqli_query($db,"select maintforms.* from $mffromclause where $mfwhereclause order by maintforms.mfdate asc, maintforms.mftime asc"); + $mffromclause = implode(",", array_unique($mffromtables)); + $mfwhereclause = implode(" and ", $mfconstraints); + $mfrowqry = mysqli_query($db, "select maintforms.* from $mffromclause where $mfwhereclause order by maintforms.mfdate asc, maintforms.mftime asc"); } - if ($target[0]=="") $target=[]; - if (in_array("part",$target)) { + if ($target[0] == "") $target = []; + if (in_array("part", $target)) { // parts search // define the query constraints // log note id if ($srchnoteid != "any" && $srchnoteid != "") { - $pfromtables[]="parts"; - $pfromtables[]="logparts"; - $pfromtables[]="lognotes"; - $pconstraints[]="parts.partid=logparts.partid and logparts.lognoteid=lognotes.lognoteid and lognotes.lognoteid=\"$srchnoteid\""; + $pfromtables[] = "parts"; + $pfromtables[] = "logparts"; + $pfromtables[] = "lognotes"; + $pconstraints[] = "parts.partid=logparts.partid and logparts.lognoteid=lognotes.lognoteid and lognotes.lognoteid=\"$srchnoteid\""; } // maint form id if ($srchmfid != "any" && $srchmfid != "") { - $pfromtables[]="parts"; - $pfromtables[]="maintforms"; - $pconstraints[]="parts.partid=maintforms.mfpart and maintforms.maintformid=\"$srchmfid\""; + $pfromtables[] = "parts"; + $pfromtables[] = "maintforms"; + $pconstraints[] = "parts.partid=maintforms.mfpart and maintforms.maintformid=\"$srchmfid\""; } // date range doesn't apply to parts // shift doesn't apply to parts @@ -337,74 +337,89 @@ if ($search) { // flags doesn't apply to parts // uid if ($srchuid != "any" && $srchuid != "") { - $pfromtables[]="parts"; - $pconstraints[]="parts.uid=\"{$srchuid}\""; + $pfromtables[] = "parts"; + $pconstraints[] = "parts.uid=\"{$srchuid}\""; } // part number if ($srchpn != "any" && $srchpn != "") { - $pfromtables[]="parts"; - $pconstraints[]="parts.partnum=\"{$srchpn}\""; + $pfromtables[] = "parts"; + $pconstraints[] = "parts.partnum=\"{$srchpn}\""; } // serial number if ($srchsn != "any" && $srchsn != "") { - $pfromtables[]="parts"; - $pconstraints[]="parts.sernum=\"{$srchsn}\""; + $pfromtables[] = "parts"; + $pconstraints[] = "parts.sernum=\"{$srchsn}\""; } // part name if ($srchpname != "any" && $srchpname != "") { - $pfromtables[]="parts"; - $pconstraints[]="parts.partname like \"%{$srchpname}%\""; + $pfromtables[] = "parts"; + $pconstraints[] = "parts.partname like \"%{$srchpname}%\""; } // part location if ($srchploc != "any" && $srchploc != "") { - $pfromtables[]="parts"; - $pfromtables[]="maintforms"; - $pconstraints[]="maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; + $pfromtables[] = "parts"; + $pfromtables[] = "maintforms"; + $pconstraints[] = "maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; } // next higher assembly if ($srchnha != "any" && $srchnha != "") { - $pfromtables[]="parts"; - $pfromtables[]="maintforms"; - $pconstraints[]="maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; + $pfromtables[] = "parts"; + $pfromtables[] = "maintforms"; + $pconstraints[] = "maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; } // repair order if ($srchrepord != "any" && $srchrepord != "") { - $pfromtables[]="parts"; - $pfromtables[]="maintforms"; - $pconstraints[]="maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; + $pfromtables[] = "parts"; + $pfromtables[] = "maintforms"; + $pconstraints[] = "maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; } // build the clauses and run the query - $pfromclause=implode(",",array_unique($pfromtables)); - $pwhereclause=implode(" and ",$pconstraints); - $prowqry=mysqli_query($db,"select parts.* from $pfromclause where $pwhereclause order by parts.uid asc"); + $pfromclause = implode(",", array_unique($pfromtables)); + $pwhereclause = implode(" and ", $pconstraints); + $prowqry = mysqli_query($db, "select parts.* from $pfromclause where $pwhereclause order by parts.uid asc"); } } // ******** end database manipulation ******** pagetable("begin"); -if(!$print){ - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); // display the form -if ($srchnoteid) $noteidval=$srchnoteid; else $noteidval="any"; -if ($srchmfid) $mfidval=$srchmfid; else $mfidval="any"; -if ($srchbdate) $bdateval=$srchbdate; else $bdateval=$mindate; -if ($srchedate) $edateval=$srchedate; else $edateval=$maxdate; -if ($srchshift) $shiftval=$srchshift; else $shiftval=0; -if ($srchtech) $techval=$srchtech; else $techval=0; -if ($srchsubj) $subjval=$srchsubj; else $subjval=0; -if ($srchtext) $textval=$srchtext; else $textval=""; -if ($srchuid) $uidval=$srchuid; else $uidval="any"; -if ($srchpn) $pnval=$srchpn; else $pnval="any"; -if ($srchsn) $snval=$srchsn; else $snval="any"; -if ($srchpname) $pnameval=$srchpname; else $pnameval="any"; -if ($srchploc) $plocval=$srchploc; else $plocval="any"; -if ($srchnha) $nhaval=$srchnha; else $nhaval="any"; -if ($srchrepord) $repordval=$srchrepord; else $repordval="any"; +if ($srchnoteid) $noteidval = $srchnoteid; +else $noteidval = "any"; +if ($srchmfid) $mfidval = $srchmfid; +else $mfidval = "any"; +if ($srchbdate) $bdateval = $srchbdate; +else $bdateval = $mindate; +if ($srchedate) $edateval = $srchedate; +else $edateval = $maxdate; +if ($srchshift) $shiftval = $srchshift; +else $shiftval = 0; +if ($srchtech) $techval = $srchtech; +else $techval = 0; +if ($srchsubj) $subjval = $srchsubj; +else $subjval = 0; +if ($srchtext) $textval = $srchtext; +else $textval = ""; +if ($srchuid) $uidval = $srchuid; +else $uidval = "any"; +if ($srchpn) $pnval = $srchpn; +else $pnval = "any"; +if ($srchsn) $snval = $srchsn; +else $snval = "any"; +if ($srchpname) $pnameval = $srchpname; +else $pnameval = "any"; +if ($srchploc) $plocval = $srchploc; +else $plocval = "any"; +if ($srchnha) $nhaval = $srchnha; +else $nhaval = "any"; +if ($srchrepord) $repordval = $srchrepord; +else $repordval = "any"; if (!$print) { echo " @@ -417,53 +432,55 @@ if (!$print) {

Shift:         Tech:         Subject:  Logbook  "; } else { @@ -556,7 +573,7 @@ if (!$print) { "; if ($search) { - $allvars=http_build_query($_REQUEST); + $allvars = http_build_query($_REQUEST); echo "       Print Search Results "; @@ -575,30 +592,30 @@ if (!$print) {

Shift:   "; - if ($shiftval==0) { + if ($shiftval == 0) { echo "any"; } else { - $shiftname=dblookup($db,"shifts","shiftid","shiftname",$shiftval); + $shiftname = dblookup($db, "shifts", "shiftid", "shiftname", $shiftval); echo "$shiftname"; } echo "        Tech:   "; - if ($techval==0) { + if ($techval == 0) { echo "any"; } else { - $techname=dblookup($db,"techs","techid","techname",$techval); + $techname = dblookup($db, "techs", "techid", "techname", $techval); echo "$techname"; } echo "        Subject:   "; - if ($subjval==0) { + if ($subjval == 0) { echo "any"; } else { - $subjname=dblookup($db,"subjects","subjectid","subjectname",$subjval); + $subjname = dblookup($db, "subjects", "subjectid", "subjectname", $subjval); echo "$subjname"; } echo " @@ -625,30 +642,33 @@ if (!$print) {

Flags: "; - $flagslist=mysqli_query($db,"select * from flags"); - $flagsperline=8; - $flagcount=1; - while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { + $flagslist = mysqli_query($db, "select * from flags"); + $flagsperline = 8; + $flagcount = 1; + while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { if ($srchflags) { - if ($srchflags[0]=="") $srchflags=[]; - if (in_array($flagcheckbox["flagid"],$srchflags)) { - printf("%s", - $flagcheckbox["flagcolor"],$flagcheckbox["flagsym"]); + if ($srchflags[0] == "") $srchflags = []; + if (in_array($flagcheckbox["flagid"], $srchflags)) { + printf( + "%s", + $flagcheckbox["flagcolor"], + $flagcheckbox["flagsym"] + ); } } - if ($flagcount<$flagsperline) { + if ($flagcount < $flagsperline) { echo "   "; $flagcount++; } else { echo "
"; - $flagcount=1; + $flagcount = 1; } } echo "

"; if ($doparts) { - if ($target[0]=="") $target=[]; + if ($target[0] == "") $target = []; echo " Search in:   "; @@ -671,47 +691,48 @@ if (!$print) { } if ($search) { - if ($target[0]=="") $target=[]; - if (in_array("log",$target)) { + if ($target[0] == "") $target = []; + if (in_array("log", $target)) { // run lognotes query and show results - $log_num_results=mysqli_num_rows($logrowqry); - if($log_num_results) { + $log_num_results = mysqli_num_rows($logrowqry); + if ($log_num_results) { echo " Results from Logbook: $log_num_results

\n"; while ($tablerow = mysqli_fetch_assoc($note)) { - $thisnote=$tablerow["lognoteid"]; - $refs="    \"Add"; + $thisnote = $tablerow["lognoteid"]; + $refs = "    \"Add"; if (islink($tablerow["lognoteid"])) { - $refs=$refs."      \"View"; + $refs = $refs . "      \"View"; } // convert tech number to name - $tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]); + $tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]); //convert subject number to name - $subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]); + $subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]); // create links of urls in note - $fmtnote=convertweblinks($tablerow["lognote"]); + $fmtnote = convertweblinks($tablerow["lognote"]); // generate the flags string - $flagstring=""; - $flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote"); - while ($flagid=mysqli_fetch_row($flagqry)) { - $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); - $flagcolor=$flagparams["flagcolor"]; - $flagsym=$flagparams["flagsym"]; - $flagname=$flagparams["flagname"]; - $flagstring=$flagstring."$flagsym  "; + $flagstring = ""; + $flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote"); + while ($flagid = mysqli_fetch_row($flagqry)) { + $flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor = $flagparams["flagcolor"]; + $flagsym = $flagparams["flagsym"]; + $flagname = $flagparams["flagname"]; + $flagstring = $flagstring . "$flagsym  "; } if ($flagstring) { - $fmtnote=$fmtnote."
".$flagstring."     "; - } else { - $fmtnote=$fmtnote."
"; + $fmtnote = $fmtnote . "
" . $flagstring . "     "; + } else { + $fmtnote = $fmtnote . "
"; } if ($doparts) { // turn on the parts indicator if parts were entered with the note - if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) { - $fmtnote=$fmtnote."PARTS"; + if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) { + $fmtnote = $fmtnote . "PARTS"; } } // now print the line in the table if ($showtime) { printf( - "%s   + "%s   %s      %s      %s      %s
%s

\n", - $tablerow["lognoteid"],$tablerow["lognoteid"], - $tablerow["time"], - $tname, - $subjname, - $refs, - $fmtnote + $tablerow["lognoteid"], + $tablerow["lognoteid"], + $tablerow["time"], + $tname, + $subjname, + $refs, + $fmtnote ); } else { printf( - "%s   + "%s   %s      %s      %s
%s

\n", - $tablerow["lognoteid"],$tablerow["lognoteid"], - $tname, - $subjname, - $refs, - $fmtnote + $tablerow["lognoteid"], + $tablerow["lognoteid"], + $tname, + $subjname, + $refs, + $fmtnote ); } } @@ -208,11 +215,11 @@ function shifttable_clean($shift, $tgt_date, $db) { echo "

\n"; } -framework("begin","$logname","Online Logbook",$print); +framework("begin", "$logname", "Online Logbook", $print); pagetable("begin"); -if(!$print) { - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); //calendar($tgt_year,$tgt_month,$tgt_day,"lognotes.php"); echo "
"; echo htmlspecialchars($tgt_date); @@ -225,29 +232,27 @@ if(!$print) { sidemenu(); echo "

"; showlinklist($print); - pageblock("left","end"); + pageblock("left", "end"); } else { echo "
$tgt_year-$tgt_month-$tgt_day

"; } -pageblock("right","begin"); -banner($print); +pageblock("right", "begin"); +banner($print); if (isset($techid)) nag($techid); //$date=date("Y-m-d",mktime(0,0,0,$tgt_month,$tgt_day,$tgt_year)); -$qry=mysqli_query($db,"select shiftid from shifts where status=1 order by shiftid asc"); -while ($shnum=mysqli_fetch_row($qry)) { - if ($tablestyle==1) { - shifttable_classic($shnum[0],$tgt_date,$db); - } else if ($tablestyle==2) { - shifttable_clean($shnum[0],$tgt_date,$db); +$qry = mysqli_query($db, "select shiftid from shifts where status=1 order by shiftid asc"); +while ($shnum = mysqli_fetch_row($qry)) { + if ($tablestyle == 1) { + shifttable_classic($shnum[0], $tgt_date, $db); + } else if ($tablestyle == 2) { + shifttable_clean($shnum[0], $tgt_date, $db); } } banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/maintform.php b/distfiles/maintform.php index 2263e21..44dcde0 100644 --- a/distfiles/maintform.php +++ b/distfiles/maintform.php @@ -9,39 +9,40 @@ include("functions.php"); -if (isset($_SESSION['login'])) $techid=$_SESSION['login']; +if (isset($_SESSION['login'])) $techid = $_SESSION['login']; -$print=$_REQUEST['print'] ?? NULL; -$histdays=$_REQUEST['histdays'] ?? NULL; -$submit=$_REQUEST['submit'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$histdays = $_REQUEST['histdays'] ?? NULL; +$submit = $_REQUEST['submit'] ?? NULL; -$logname=LOG_NAME; -$uidtext=UID_TEXT; +$logname = LOG_NAME; +$uidtext = UID_TEXT; -if ($histdays=="") $histdays=30; +if ($histdays == "") $histdays = 30; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } // define pendtable function -function pendtable($tech_id, $db) { - $uidtext=UID_TEXT; +function pendtable($tech_id, $db) +{ + $uidtext = UID_TEXT; // print section header if ($tech_id) { echo " Your Pending Maintenance Forms
"; - $pmf=mysqli_query($db,"select * from maintforms where mftech=\"$tech_id\" and pending=\"1\" order by mfdate desc, mftime desc"); + $pmf = mysqli_query($db, "select * from maintforms where mftech=\"$tech_id\" and pending=\"1\" order by mfdate desc, mftime desc"); } else { echo " All Pending Maintenance Forms
"; - $pmf=mysqli_query($db,"select * from maintforms where pending=\"1\" order by mfdate desc, mftime desc"); + $pmf = mysqli_query($db, "select * from maintforms where pending=\"1\" order by mfdate desc, mftime desc"); } echo "
@@ -60,26 +61,26 @@ function pendtable($tech_id, $db) { "; while ($pendrow = mysqli_fetch_assoc($pmf)) { // look up part data - $uid=dblookup($db,"parts","partid","uid",$pendrow["mfpart"]); - if ($uid=="") $uid=" "; - $partno=dblookup($db,"parts","partid","partnum",$pendrow["mfpart"]); - if ($partno=="") $partno=" "; - $serno=dblookup($db,"parts","partid","sernum",$pendrow["mfpart"]); - if ($serno=="") $serno=" "; - $partname=dblookup($db,"parts","partid","partname",$pendrow["mfpart"]); - if ($partname=="") $partname=" "; + $uid = dblookup($db, "parts", "partid", "uid", $pendrow["mfpart"]); + if ($uid == "") $uid = " "; + $partno = dblookup($db, "parts", "partid", "partnum", $pendrow["mfpart"]); + if ($partno == "") $partno = " "; + $serno = dblookup($db, "parts", "partid", "sernum", $pendrow["mfpart"]); + if ($serno == "") $serno = " "; + $partname = dblookup($db, "parts", "partid", "partname", $pendrow["mfpart"]); + if ($partname == "") $partname = " "; // look up tech name - $tname=dblookup($db,"techs","techid","techname",$pendrow["mftech"]); - if ($pendrow["lognoteid"]==0) { - $noteidval=" "; - $notetag="%s%s"; + $tname = dblookup($db, "techs", "techid", "techname", $pendrow["mftech"]); + if ($pendrow["lognoteid"] == 0) { + $noteidval = " "; + $notetag = "%s%s"; } else { - $noteidval=$pendrow["lognoteid"]; - $notetag="%s"; + $noteidval = $pendrow["lognoteid"]; + $notetag = "%s"; } if (!$tech_id) { printf( - " + " @@ -89,18 +90,20 @@ function pendtable($tech_id, $db) { ", - $pendrow["maintformid"],$pendrow["maintformid"], - $pendrow["mfdate"], - $tname, - $uid, - $partno, - $serno, - $partname, - $noteidval,$noteidval + $pendrow["maintformid"], + $pendrow["maintformid"], + $pendrow["mfdate"], + $tname, + $uid, + $partno, + $serno, + $partname, + $noteidval, + $noteidval ); } else { printf( - " + " @@ -109,13 +112,15 @@ function pendtable($tech_id, $db) { ", - $pendrow["maintformid"],$pendrow["maintformid"], - $pendrow["mfdate"], - $uid, - $partno, - $serno, - $partname, - $noteidval,$noteidval + $pendrow["maintformid"], + $pendrow["maintformid"], + $pendrow["mfdate"], + $uid, + $partno, + $serno, + $partname, + $noteidval, + $noteidval ); } } @@ -125,9 +130,10 @@ function pendtable($tech_id, $db) { } // define histtable function -function histtable($hist_days,$db) { - $uidtext=UID_TEXT; - $dayopts=array(30,90,180,365); +function histtable($hist_days, $db) +{ + $uidtext = UID_TEXT; + $dayopts = array(30, 90, 180, 365); // print section header echo " @@ -135,13 +141,13 @@ function histtable($hist_days,$db) { Days      @@ -160,24 +166,24 @@ function histtable($hist_days,$db) { "; while ($histrow = mysqli_fetch_assoc($histqry)) { // look up part data - $uid=dblookup($db,"parts","partid","uid",$histrow["mfpart"]); - $partno=dblookup($db,"parts","partid","partnum",$histrow["mfpart"]); - if ($partno=="") $partno=" "; - $serno=dblookup($db,"parts","partid","sernum",$histrow["mfpart"]); - if ($serno=="") $serno=" "; - $partname=dblookup($db,"parts","partid","partname",$histrow["mfpart"]); - if ($partname=="") $partname=" "; + $uid = dblookup($db, "parts", "partid", "uid", $histrow["mfpart"]); + $partno = dblookup($db, "parts", "partid", "partnum", $histrow["mfpart"]); + if ($partno == "") $partno = " "; + $serno = dblookup($db, "parts", "partid", "sernum", $histrow["mfpart"]); + if ($serno == "") $serno = " "; + $partname = dblookup($db, "parts", "partid", "partname", $histrow["mfpart"]); + if ($partname == "") $partname = " "; // look up tech name - $tname=dblookup($db,"techs","techid","techname",$histrow["mftech"]); - if ($histrow["lognoteid"]==0) { - $noteidval=" "; - $notetag="%s%s"; + $tname = dblookup($db, "techs", "techid", "techname", $histrow["mftech"]); + if ($histrow["lognoteid"] == 0) { + $noteidval = " "; + $notetag = "%s%s"; } else { - $noteidval=$histrow["lognoteid"]; - $notetag="%s"; + $noteidval = $histrow["lognoteid"]; + $notetag = "%s"; } printf( - " + " @@ -187,14 +193,16 @@ function histtable($hist_days,$db) { ", - $histrow["maintformid"],$histrow["maintformid"], - $histrow["mfdate"], - $tname, - $uid, - $partno, - $serno, - $partname, - $noteidval,$noteidval + $histrow["maintformid"], + $histrow["maintformid"], + $histrow["mfdate"], + $tname, + $uid, + $partno, + $serno, + $partname, + $noteidval, + $noteidval ); } echo " @@ -202,30 +210,28 @@ function histtable($hist_days,$db) { "; } -framework("begin","$logname","Maintenance Forms",$print); +framework("begin", "$logname", "Maintenance Forms", $print); pagetable("begin"); -if(!$print) { - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); -banner($print); +pageblock("right", "begin"); +banner($print); echo "
"; -$haspending=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mftech=\"$techid\" and pending=\"1\"")); +$haspending = mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mftech=\"$techid\" and pending=\"1\"")); if ($haspending) { - pendtable($techid,$db); + pendtable($techid, $db); echo "


"; } -pendtable(0,$db); +pendtable(0, $db); echo "


"; -histtable($histdays,$db); +histtable($histdays, $db); echo "

"; banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/maintformentry.php b/distfiles/maintformentry.php index 45e3601..fdd2ff8 100644 --- a/distfiles/maintformentry.php +++ b/distfiles/maintformentry.php @@ -11,121 +11,123 @@ include("functions.php"); if (!$_SESSION['login'] && ($_REQUEST['mfadd'] || $_REQUEST['actionadd'])) { - header ("Location: login.php"); + header("Location: login.php"); } -$loggedinas=$_SESSION['login']; -$isadmin=dblookup($db,"techs","techid","admin",$loggedinas); +$loggedinas = $_SESSION['login']; +$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas); -function getmfdata($maintformid) { +function getmfdata($maintformid) +{ // pull maintenance form data from maintforms table global $db; - $mfdata=mysqli_fetch_assoc(mysqli_query($db,"select * from maintforms where maintformid=\"$maintformid\"")); + $mfdata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintforms where maintformid=\"$maintformid\"")); return $mfdata; } -function getactiondata($maintactionid) { +function getactiondata($maintactionid) +{ // pull maintenance action data from maintactions table global $db; - $actiondata=mysqli_fetch_assoc(mysqli_query($db,"select * from maintactions where maintactionid=\"$maintactionid\"")); + $actiondata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintactions where maintactionid=\"$maintactionid\"")); return $actiondata; } -$print=$_REQUEST['print'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; -$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'] ?? []; +$maintformid = $_REQUEST['maintformid'] ?? NULL; +$lognoteid = $_REQUEST['lognoteid'] ?? NULL; +$mfdate = $_REQUEST['date'] ?? NULL; +$mftime = $_REQUEST['time'] ?? NULL; +$mfsubmit = $_REQUEST['mfsubmit'] ?? NULL; +$mfadd = $_REQUEST['mfadd'] ?? NULL; +$mfedit = $_REQUEST['mfedit'] ?? NULL; +$mfdelete = $_REQUEST['mfdelete'] ?? NULL; +$mfpartloc = $_REQUEST['mfpartloc'] ?? NULL; +$mfmalfunction = $_REQUEST['mfmalfunction'] ?? NULL; +$nha = $_REQUEST['nha'] ?? NULL; +$repord = $_REQUEST['repord'] ?? NULL; +$mfpart = $_REQUEST['mfpart'] ?? NULL; +$uid = $_REQUEST['uid'] ?? NULL; +$partnum = $_REQUEST['partnum'] ?? NULL; +$sernum = $_REQUEST['sernum'] ?? NULL; +$partname = $_REQUEST['partname'] ?? NULL; +$actionadd = $_REQUEST['actionadd'] ?? NULL; +$actionedit = $_REQUEST['actionedit'] ?? NULL; +$actiondelete = $_REQUEST['actiondelete'] ?? NULL; +$maintactionid = $_REQUEST['maintactionid'] ?? NULL; +$actiondate = $_REQUEST['actiondate'] ?? NULL; +$actiontime = $_REQUEST['actiontime'] ?? NULL; +$actiontech = $_REQUEST['actiontech'] ?? NULL; +$action = $_REQUEST['action'] ?? NULL; +$actionaddsubmit = $_REQUEST['actionaddsubmit'] ?? NULL; +$actioneditsubmit = $_REQUEST['actioneditsubmit'] ?? NULL; +$printfmt = $_REQUEST['printfmt'] ?? NULL; +if ($printfmt) $print = TRUE; +$flags = $_POST['flags'] ?? []; -$logname=LOG_NAME; -$uidtext=UID_TEXT; +$logname = LOG_NAME; +$uidtext = UID_TEXT; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } if ($printfmt) { - framework("begin","","",$print); + framework("begin", "", "", $print); } else if ($mfedit) { - framework("begin","$logname","Maintenance Form Edit",$print); - if ($loggedinas) $mfauthorized=TRUE; + framework("begin", "$logname", "Maintenance Form Edit", $print); + if ($loggedinas) $mfauthorized = TRUE; } else if ($mfdelete) { - framework("begin","$logname","Maintenance Form Edit",$print); - $mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); - if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=TRUE; + framework("begin", "$logname", "Maintenance Form Edit", $print); + $mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid); + if (($loggedinas == $mfowner) || $isadmin) $mfauthorized = TRUE; } else if ($actionadd) { - framework("begin","$logname","Maintenance Action Entry",$print); - $mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); + framework("begin", "$logname", "Maintenance Action Entry", $print); + $mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid); if ($loggedinas) { - $mfauthorized=TRUE; - $actionauthorized=TRUE; + $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=TRUE; - $actionowner=dblookup($db,"maintactions","maintactionid","actiontech",$maintactionid); - if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=TRUE; + framework("begin", "$logname", "Maintenance Action Edit", $print); + $mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid); + if ($loggedinas) $mfauthorized = TRUE; + $actionowner = dblookup($db, "maintactions", "maintactionid", "actiontech", $maintactionid); + if (($loggedinas == $actionowner) || $isadmin) $actionauthorized = TRUE; } else { - $mfadd=TRUE; - framework("begin","$logname","Maintenance Form Entry",$print); - $mftech=$loggedinas; - $mfauthorized=TRUE; + $mfadd = TRUE; + framework("begin", "$logname", "Maintenance Form Entry", $print); + $mftech = $loggedinas; + $mfauthorized = TRUE; } // ******** begin database manipulation ******** //var_dump($_REQUEST); -$pdatamismatch=NULL; +$pdatamismatch = NULL; if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) { // pull mf data from database - $mftoedit=getmfdata($maintformid); - $partdatainput=[]; - if ($mftoedit['mfpart']) $partdatainput['partid']=$mftoedit['mfpart']; - if ($uid) $partdatainput['uid']=$uid; - if ($partnum) $partdatainput['partnum']=$partnum; - if ($sernum) $partdatainput['sernum']=$sernum; - $partinfo=get_part_data($partdatainput); - if ($partinfo['result']==2) { - $pdatamismatch=TRUE; + $mftoedit = getmfdata($maintformid); + $partdatainput = []; + if ($mftoedit['mfpart']) $partdatainput['partid'] = $mftoedit['mfpart']; + if ($uid) $partdatainput['uid'] = $uid; + if ($partnum) $partdatainput['partnum'] = $partnum; + if ($sernum) $partdatainput['sernum'] = $sernum; + $partinfo = get_part_data($partdatainput); + if ($partinfo['result'] == 2) { + $pdatamismatch = TRUE; } else { - $pdatamismatch=FALSE; - if ($partinfo['partid']) $mfpart=$partinfo['partid']; - if ($partinfo['uid']) $uid=$partinfo['uid']; - if ($partinfo['partnum']) $partnum=$partinfo['partnum']; - if ($partinfo['sernum']) $sernum=$partinfo['sernum']; - if ($partinfo['partname']) $partname=$partinfo['partname']; + $pdatamismatch = FALSE; + if ($partinfo['partid']) $mfpart = $partinfo['partid']; + if ($partinfo['uid']) $uid = $partinfo['uid']; + if ($partinfo['partnum']) $partnum = $partinfo['partnum']; + if ($partinfo['sernum']) $sernum = $partinfo['sernum']; + if ($partinfo['partname']) $partname = $partinfo['partname']; } } @@ -134,54 +136,54 @@ if ($mfadd) { // add the entry if submit is pressed if ($mfmalfunction && ($uid || ($partnum && $sernum))) { // determine whether supplied date is future or past - $datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$mfdate\",CURRENT_DATE)")); + $datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$mfdate\",CURRENT_DATE)")); // if future, set time to 00:00:01, if past, set to 23:59:59 - if ($datediff[0]<0) { - $mftime="23:59:59:"; + if ($datediff[0] < 0) { + $mftime = "23:59:59:"; } - if ($datediff[0]>0) { - $mftime="00:00:01:"; + if ($datediff[0] > 0) { + $mftime = "00:00:01:"; } // remove cruft from malfunction text - $mfmalfunction=htmlentities($mfmalfunction); - $mfmalfunction=addslashes($mfmalfunction); - + $mfmalfunction = htmlentities($mfmalfunction); + $mfmalfunction = addslashes($mfmalfunction); + if ($mfauthorized) { - $partdatainput=array(); - if ($uid) $partdatainput['uid']=$uid; - if ($partnum) $partdatainput['partnum']=$partnum; - if ($sernum) $partdatainput['sernum']=$sernum; - $partinfo=get_part_data($partdatainput); + $partdatainput = array(); + if ($uid) $partdatainput['uid'] = $uid; + if ($partnum) $partdatainput['partnum'] = $partnum; + if ($sernum) $partdatainput['sernum'] = $sernum; + $partinfo = get_part_data($partdatainput); // add to parts table - if ($partinfo['result']==1) { + if ($partinfo['result'] == 1) { // if this part has not been seen before, add it to the parts table and get partid - mysqli_query($db,"insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")"); - $mfpart=mysqli_insert_id($db); - } else if ($partinfo['result']==2) { - $pdatamismatch=TRUE; + mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")"); + $mfpart = mysqli_insert_id($db); + } else if ($partinfo['result'] == 2) { + $pdatamismatch = TRUE; } else { // if it is in parts table, get partid for this record - $pdatamismatch=FALSE; - $mfpart=$partinfo['partid']; + $pdatamismatch = FALSE; + $mfpart = $partinfo['partid']; } - if ($uid =="" || $partnum == "" || $sernum == "") { + if ($uid == "" || $partnum == "" || $sernum == "") { // have the maintenance form stay pending due to incomplete part data - $pending=1; + $pending = 1; } else { - $pending=0; + $pending = 0; } - + // add the record to maintforms if (! $pdatamismatch) { - mysqli_query($db,"insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending) + mysqli_query($db, "insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending) values (\"$mfdate\", \"$mftime\",\"$loggedinas\",\"$mfpart\",\"$mfpartloc\",\"$mfmalfunction\",\"$nha\",\"$repord\",\"$lognoteid\",\"$pending\")"); - $newmaintformid=mysqli_insert_id($db); - $mfidtoprint=$newmaintformid; + $newmaintformid = mysqli_insert_id($db); + $mfidtoprint = $newmaintformid; // update the flagmap table foreach ($flags as $thisflag) { // set flag for this maintenance form - mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$newmaintformid\")"); + mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$newmaintformid\")"); } } } @@ -189,66 +191,66 @@ if ($mfadd) { } } if ($mfedit) { - $mfidtoprint=$maintformid; + $mfidtoprint = $maintformid; if ($mfsubmit && $mfauthorized) { if ($mfmalfunction && ($uid || ($partnum && $sernum))) { // remove cruft from malfunction text - $mfmalfunction=htmlentities($mfmalfunction); - $mfmalfunction=addslashes($mfmalfunction); - + $mfmalfunction = htmlentities($mfmalfunction); + $mfmalfunction = addslashes($mfmalfunction); + // update parts table - if ($uid =="" || $partnum == "" || $sernum == "") { + if ($uid == "" || $partnum == "" || $sernum == "") { // have the maintenance form stay pending due to incomplete part data - $pending=1; + $pending = 1; } else { - $pending=0; + $pending = 0; } if (! $pdatamismatch) { - mysqli_query($db,"update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$mfpart\""); + mysqli_query($db, "update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$mfpart\""); } - + // update the record in maintforms if (! $pdatamismatch) { - mysqli_query($db,"update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\", + mysqli_query($db, "update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\", mfmalfunction=\"$mfmalfunction\", nha=\"$nha\", repord=\"$repord\", lognoteid=\"$lognoteid\", pending=\"$pending\" where maintformid=\"$maintformid\""); - + // update the flagmap table - mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\""); + mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\""); foreach ($flags as $thisflag) { // set flag for this maintenance form - mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$maintformid\")"); + mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$maintformid\")"); } } } } // refresh the maintenance form in question from the database - $mftoedit=getmfdata($maintformid); + $mftoedit = getmfdata($maintformid); } if ($mfdelete && $mfauthorized) { // delete from maintforms table - mysqli_query($db,"delete from maintforms where maintformid=\"$maintformid\""); + mysqli_query($db, "delete from maintforms where maintformid=\"$maintformid\""); // delete occurances from the flagmap table - mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\""); + mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\""); } if ($actionadd) { if ($actionaddsubmit) { if ($action) { // determine whether supplied date is future or past - $datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$actiondate\",CURRENT_DATE)")); + $datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$actiondate\",CURRENT_DATE)")); // if future, set time to 00:00:01, if past, set to 23:59:59 - if ($datediff[0]<0) { - $actiontime="23:59:59:"; + if ($datediff[0] < 0) { + $actiontime = "23:59:59:"; } - if ($datediff[0]>0) { - $actiontime="00:00:01:"; + if ($datediff[0] > 0) { + $actiontime = "00:00:01:"; } // remove cruft from action text - $action=htmlentities($action); - $action=addslashes($action); - + $action = htmlentities($action); + $action = addslashes($action); + // add to maintactions table - mysqli_query($db,"insert into maintactions (actiondate,actiontime,maintformnum,actiontech,action) + mysqli_query($db, "insert into maintactions (actiondate,actiontime,maintformnum,actiontech,action) values (\"$actiondate\",\"$actiontime\",\"$maintformid\",\"$loggedinas\",\"$action\")"); echo mysqli_error($db); } @@ -259,19 +261,19 @@ if ($actionedit) { if ($actioneditsubmit && $actionauthorized) { // update the action // remove cruft from action text - $action=htmlentities($action); - $action=addslashes($action); - + $action = htmlentities($action); + $action = addslashes($action); + // update maintactions table - mysqli_query($db,"update maintactions set actiondate=\"$actiondate\", actiontime=\"$actiontime\", action=\"$action\" where maintactionid=\"$maintactionid\""); + mysqli_query($db, "update maintactions set actiondate=\"$actiondate\", actiontime=\"$actiontime\", action=\"$action\" where maintactionid=\"$maintactionid\""); } // refresh the action in question from the database - $actiontoedit=getactiondata($maintactionid); + $actiontoedit = getactiondata($maintactionid); } if ($actiondelete && $actionauthorized) { // delete the action - mysqli_query($db,"delete from maintactions where maintactionid=\"$maintactionid\""); + mysqli_query($db, "delete from maintactions where maintactionid=\"$maintactionid\""); } @@ -279,66 +281,67 @@ if ($actiondelete && $actionauthorized) { pagetable("begin"); if (!$print) { - pageblock("left","begin"); + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); // display the form if ($mfadd || $actionadd) { - $mfdate=$today; - $mftime=$now; - $actiondate=$today; - $actiontime=$now; + $mfdate = $today; + $mftime = $now; + $actiondate = $today; + $actiontime = $now; } if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) { - $mfdate=$mftoedit["mfdate"]; - $mftime=$mftoedit["mftime"]; - $mfpart=$mftoedit["mfpart"]; - $mfpartloc=$mftoedit["mfpartloc"]; - $mfmalfunction=$mftoedit["mfmalfunction"]; - $nha=$mftoedit["nha"]; - $repord=$mftoedit["repord"]; - $lognoteid=$mftoedit["lognoteid"]; - if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) $mftech=$mftoedit["mftech"]; - if (! $mftime) $mftime=$now; + $mfdate = $mftoedit["mfdate"]; + $mftime = $mftoedit["mftime"]; + $mfpart = $mftoedit["mfpart"]; + $mfpartloc = $mftoedit["mfpartloc"]; + $mfmalfunction = $mftoedit["mfmalfunction"]; + $nha = $mftoedit["nha"]; + $repord = $mftoedit["repord"]; + $lognoteid = $mftoedit["lognoteid"]; + if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) $mftech = $mftoedit["mftech"]; + if (! $mftime) $mftime = $now; } if (($mfedit || $actionadd || $actionedit) && ! ($mfsubmit || $actionaddsubmit || $actioneditsubmit)) { - $partinfo=array(); - $partinfoinput['partid']=$mfpart; - $partinfo=get_part_data($partinfoinput); - $mfpart=$partinfo['partid']; - $uid=$partinfo['uid']; - $partnum=$partinfo['partnum']; - $sernum=$partinfo['sernum']; - $partname=$partinfo['partname']; - $pluresult=$partinfo['result']; - if ($pluresult==2) $pdatamismatch=TRUE; else $pdatamismatch=FALSE; + $partinfo = array(); + $partinfoinput['partid'] = $mfpart; + $partinfo = get_part_data($partinfoinput); + $mfpart = $partinfo['partid']; + $uid = $partinfo['uid']; + $partnum = $partinfo['partnum']; + $sernum = $partinfo['sernum']; + $partname = $partinfo['partname']; + $pluresult = $partinfo['result']; + if ($pluresult == 2) $pdatamismatch = TRUE; + else $pdatamismatch = FALSE; } -$techname=dblookup($db,"techs","techid","techname",$mftech); +$techname = dblookup($db, "techs", "techid", "techname", $mftech); if ($mfsubmit) { if ($mfmalfunction) { if (($uid || ($partnum && $sernum)) || $mfpart) { if ($mfadd) { - format_message(0,"Maintenance Form added. You may enter another one or return to Maintenance Forms page."); + format_message(0, "Maintenance Form added. You may enter another one or return to Maintenance Forms page."); } if ($mfedit) { - format_message(0,"Maintenance Form changed. Return to Maintenance Forms page."); + format_message(0, "Maintenance Form changed. Return to Maintenance Forms page."); } } else { - format_message(1,"You didn't enter any part information. Please try again."); + format_message(1, "You didn't enter any part information. Please try again."); } } else { - format_message(1,"You didn't enter any malfunction description. Please try again."); + format_message(1, "You didn't enter any malfunction description. Please try again."); } } if ($mfdelete) { - format_message(0,"Maintenance Form Deleted. Return to Maintenance Forms page."); + format_message(0, "Maintenance Form Deleted. Return to Maintenance Forms page."); } if ($pdatamismatch) { - $advtxt=" + $advtxt = "   Warning: The $uidtext doesn't match the Part Number/Serial Number associated with it in our database. Please ensure the part information @@ -346,7 +349,7 @@ if ($pdatamismatch) { the Parts page to correct the database. "; } else { - $advtxt=" + $advtxt = " You can enter a $uidtext or Part Number/Serial Number or both. "; } @@ -374,34 +377,34 @@ if ($printfmt) { Flags
%s %s %s%s $notetag
%s %s %s%s $notetag
%s %s %s%s $notetag
"; - + // create an array called theseflags of flagids set for this maintformid - $allflags=mysqli_query($db,"select flagid from flags"); + $allflags = mysqli_query($db, "select flagid from flags"); unset($theseflags); - $theseflags=[]; - while ($thisflag=mysqli_fetch_row($allflags)) { - if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) { - $theseflags[]=$thisflag[0]; + $theseflags = []; + while ($thisflag = mysqli_fetch_row($allflags)) { + if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) { + $theseflags[] = $thisflag[0]; } } // display flag symbols for set flags - $flagslist=mysqli_query($db,"select * from flags"); - while ($flagsymbol=mysqli_fetch_assoc($flagslist)) { - if ($theseflags[0]=="") $theseflags=[]; - if (!empty($theseflags) && in_array($flagsymbol["flagid"],$theseflags)) { - echo $flagsymbol['flagsym']."  "; + $flagslist = mysqli_query($db, "select * from flags"); + while ($flagsymbol = mysqli_fetch_assoc($flagslist)) { + if ($theseflags[0] == "") $theseflags = []; + if (!empty($theseflags) && in_array($flagsymbol["flagid"], $theseflags)) { + echo $flagsymbol['flagsym'] . "  "; } } echo "

Maintenance Actions
"; - $maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc"); - while ($actiontable=mysqli_fetch_assoc($maintactionqry)) { - $actiondate=$actiontable["actiondate"]; - $actiontime=$actiontable["actiontime"]; - $tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]); - $actiontext=convertweblinks($actiontable["action"]); + $maintactionqry = mysqli_query($db, "select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc"); + while ($actiontable = mysqli_fetch_assoc($maintactionqry)) { + $actiondate = $actiontable["actiondate"]; + $actiontime = $actiontable["actiontime"]; + $tname = dblookup($db, "techs", "techid", "techname", $actiontable["actiontech"]); + $actiontext = convertweblinks($actiontable["action"]); // print the actions echo " @@ -463,39 +466,49 @@ if ($printfmt) {
"; // create an array called theseflags of flagids set for this maintformid - $allflags=mysqli_query($db,"select flagid from flags"); + $allflags = mysqli_query($db, "select flagid from flags"); unset($theseflags); - $theseflags=[]; - while ($thisflag=mysqli_fetch_row($allflags)) { - if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) { - $theseflags[]=$thisflag[0]; + $theseflags = []; + while ($thisflag = mysqli_fetch_row($allflags)) { + if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) { + $theseflags[] = $thisflag[0]; } } if ($mfadd) { - $flagslist=mysqli_query($db,"select * from flags where status=1"); + $flagslist = mysqli_query($db, "select * from flags where status=1"); } else { - $flagslist=mysqli_query($db,"select * from flags"); + $flagslist = mysqli_query($db, "select * from flags"); } - $flagsperline=8; - $flagcount=1; - while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { + $flagsperline = 8; + $flagcount = 1; + while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { //if ($theseflags[0]=="") $theseflags=[]; - if (in_array($flagcheckbox["flagid"],$theseflags)) { - printf("%s", - $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + if (in_array($flagcheckbox["flagid"], $theseflags)) { + printf( + "%s", + $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("%s", - $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( + "%s", + $flagcheckbox["flagid"], + $flagcheckbox["flagcolor"], + $flagcheckbox["flagname"], + $flagcheckbox["flagsym"] + ); } } - if ($flagcount<$flagsperline) { + if ($flagcount < $flagsperline) { echo "   "; $flagcount++; } else { echo "
"; - $flagcount=1; + $flagcount = 1; } } echo " @@ -542,7 +555,7 @@ if ($printfmt) {
"; } - + echo "
@@ -550,16 +563,16 @@ if ($printfmt) { if ($actionadd || $actionedit) { // show the action form if ($actionadd) { - $matime=$now; - $actiontext=""; - $actiontech=$loggedinas; + $matime = $now; + $actiontext = ""; + $actiontech = $loggedinas; } else if ($actionedit) { - $actiontext=$actiontoedit['action']; - $actiontech=$actiontoedit['actiontech']; - $actiondate=$actiontoedit['actiondate']; - $actiontime=$actiontoedit['actiontime']; + $actiontext = $actiontoedit['action']; + $actiontech = $actiontoedit['actiontech']; + $actiondate = $actiontoedit['actiondate']; + $actiontime = $actiontoedit['actiontime']; } - $tname=dblookup($db,"techs","techid","techname",$actiontech); + $tname = dblookup($db, "techs", "techid", "techname", $actiontech); echo " "; -$partqry=mysqli_query($db,"select * from parts order by $sort $order"); -while ($partline=mysqli_fetch_assoc($partqry)) { +$partqry = mysqli_query($db, "select * from parts order by $sort $order"); +while ($partline = mysqli_fetch_assoc($partqry)) { if (!$partline['uid']) { - $pluidtxt="none"; + $pluidtxt = "none"; } else { - $pluidtxt=$partline['uid']; + $pluidtxt = $partline['uid']; } if ($loggedin) { - printf(" + printf( + " ", - $partline['partid'],$pluidtxt, - $partline['partnum'], - $partline['sernum'], - $partline['partname'] + $partline['partid'], + $pluidtxt, + $partline['partnum'], + $partline['sernum'], + $partline['partname'] ); } else { - printf(" + printf( + " ", - $pluidtxt, - $partline['partnum'], - $partline['sernum'], - $partline['partname'] + $pluidtxt, + $partline['partnum'], + $partline['sernum'], + $partline['partname'] ); } echo " @@ -115,9 +118,7 @@ echo " echo "

"; banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/profile.php b/distfiles/profile.php index 15af5cb..48319d1 100644 --- a/distfiles/profile.php +++ b/distfiles/profile.php @@ -10,133 +10,136 @@ include("functions.php"); if (!isset($_SESSION['login'])) { - header ("Location: login.php"); + header("Location: login.php"); } -$techid=$_SESSION['login'] ?? NULL; -$print=$_REQUEST['print'] ?? NULL; -$table=$_REQUEST['table'] ?? NULL; -$updateinfo=$_REQUEST['updateinfo'] ?? NULL; -$updatedisplay=$_REQUEST['updatedisplay'] ?? NULL; -$setcolor=$_REQUEST['setcolor'] ?? NULL; -$name=$_REQUEST['name'] ?? NULL; -$pass=$_REQUEST['pass'] ?? NULL; -$passconf=$_REQUEST['passconf'] ?? NULL; -$shift=$_REQUEST['shift'] ?? NULL; -$display_urlchunk=$_REQUEST['display_urlchunk'] ?? NULL; -$display_showts=$_REQUEST['display_showts'] ?? NULL; -$display_techalpha=$_REQUEST['display_techalpha'] ?? NULL; -$display_subjalpha=$_REQUEST['display_subjalpha'] ?? NULL; -$display_logstyle=$_REQUEST['display_logstyle'] ?? NULL; -$modcolor=$_REQUEST['modcolor'] ?? NULL; -$hexcolor=$_REQUEST['hexcolor'] ?? NULL; -$resetcustom=$_REQUEST["resetcustom"] ?? NULL; +$techid = $_SESSION['login'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$table = $_REQUEST['table'] ?? NULL; +$updateinfo = $_REQUEST['updateinfo'] ?? NULL; +$updatedisplay = $_REQUEST['updatedisplay'] ?? NULL; +$setcolor = $_REQUEST['setcolor'] ?? NULL; +$name = $_REQUEST['name'] ?? NULL; +$pass = $_REQUEST['pass'] ?? NULL; +$passconf = $_REQUEST['passconf'] ?? NULL; +$shift = $_REQUEST['shift'] ?? NULL; +$display_urlchunk = $_REQUEST['display_urlchunk'] ?? NULL; +$display_showts = $_REQUEST['display_showts'] ?? NULL; +$display_techalpha = $_REQUEST['display_techalpha'] ?? NULL; +$display_subjalpha = $_REQUEST['display_subjalpha'] ?? NULL; +$display_logstyle = $_REQUEST['display_logstyle'] ?? NULL; +$modcolor = $_REQUEST['modcolor'] ?? NULL; +$hexcolor = $_REQUEST['hexcolor'] ?? NULL; +$resetcustom = $_REQUEST["resetcustom"] ?? NULL; -$logname=LOG_NAME; +$logname = LOG_NAME; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname","My Profile",$print); +framework("begin", "$logname", "My Profile", $print); pagetable("begin"); -if(!$print){ - pageblock("left","begin"); - +if (!$print) { + pageblock("left", "begin"); + // ******** begin database manipulation ******** if ($updateinfo) { // name shift password settings // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Tech name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\" and techid!=\"$techid\""))) { - if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\" and techid!=\"$techid\""))) { + if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) { + $nameunique = FALSE; echo " Tech name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } // test for matching passwords - if ($pass!="password_is_unchanged") { - if ($pass==$passconf) { - $passmatch=1; - $passhash=password_hash($pass,PASSWORD_DEFAULT); - $namepassupdqry=("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\""); + if ($pass != "password_is_unchanged") { + if ($pass == $passconf) { + $passmatch = TRUE; + $passhash = password_hash($pass, PASSWORD_DEFAULT); + $namepassupdqry = ("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\""); } else { - $passmatch=0; + $passmatch = FALSE; echo " The passwords you supplied don't match.
"; } } else { - $passmatch=1; - $namepassupdqry="update techs set techname=\"$name\" where techid=\"$techid\""; + $passmatch = TRUE; + $namepassupdqry = "update techs set techname=\"$name\" where techid=\"$techid\""; } if ($namesuppld && $nameunique && $passmatch) { - mysqli_query($db,$namepassupdqry); - mysqli_query($db,"update techs set shift=\"$shift\" where techid=\"$techid\""); + mysqli_query($db, $namepassupdqry); + mysqli_query($db, "update techs set shift=\"$shift\" where techid=\"$techid\""); } } if ($updatedisplay) { // display settings - if ($display_showts) $display_showts=1; else $display_showts=0; - if ($display_techalpha=="a") $display_techalpha=1; else $display_techalpha=0; - if ($display_subjalpha=="a") $display_subjalpha=1; else $display_subjalpha=0; + if ($display_showts) $display_showts = 1; + else $display_showts = 0; + if ($display_techalpha == "a") $display_techalpha = 1; + else $display_techalpha = 0; + if ($display_subjalpha == "a") $display_subjalpha = 1; + else $display_subjalpha = 0; // test for urlchunk supplied if (strlen(trim($display_urlchunk))) { - $chunksuppld=1; + $chunksuppld = TRUE; } else { - $chunksuppld=0; + $chunksuppld = FALSE; echo " URL chunk size cannot be blank.
"; } if ($chunksuppld) { - putsetting('url_chunk_size',$display_urlchunk,$techid); - putsetting('show_ts',$display_showts,$techid); - putsetting('tech_alpha',$display_techalpha,$techid); - putsetting('subj_alpha',$display_subjalpha,$techid); - putsetting('log_style',$display_logstyle,$techid); + putsetting('url_chunk_size', $display_urlchunk, $techid); + putsetting('show_ts', $display_showts, $techid); + putsetting('tech_alpha', $display_techalpha, $techid); + putsetting('subj_alpha', $display_subjalpha, $techid); + putsetting('log_style', $display_logstyle, $techid); } } if ($setcolor) { // color settings - $hexcolor="#".ltrim($hexcolor); - putsetting($modcolor,$hexcolor,$techid); + $hexcolor = "#" . ltrim($hexcolor); + putsetting($modcolor, $hexcolor, $techid); } - if ($resetcustom) mysqli_query($db,"delete from customs where customtech=\"$techid\""); - + if ($resetcustom) mysqli_query($db, "delete from customs where customtech=\"$techid\""); + sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); // pull my current data from tables -$curname=dblookup($db,"techs","techid","techname",$techid); -$curshift=dblookup($db,"techs","techid","shift",$techid); -$pass=$passconf="password_is_unchanged"; +$curname = dblookup($db, "techs", "techid", "techname", $techid); +$curshift = dblookup($db, "techs", "techid", "shift", $techid); +$pass = $passconf = "password_is_unchanged"; // other values from customs -$curlchunk=getsetting('url_chunk_size',$techid)["value"]; -$curts=getsetting('show_ts',$techid)["value"]; -$curtdo=getsetting('tech_alpha',$techid)["value"]; -$cursdo=getsetting('subj_alpha',$techid)["value"]; -$curbgc=getsetting('background_color',$techid)["value"]; -$cursbc=getsetting('sidebar_color',$techid)["value"]; -$curmbgc=getsetting('menubg_color',$techid)["value"]; -$curtc=getsetting('text_color',$techid)["value"]; -$curlc=getsetting('link_color',$techid)["value"]; -$curvlc=getsetting('vlink_color',$techid)["value"]; -$curhc=getsetting('heading_color',$techid)["value"]; -$curlogstyle=getsetting('log_style',$techid)["value"]; +$curlchunk = getsetting('url_chunk_size', $techid)["value"]; +$curts = getsetting('show_ts', $techid)["value"]; +$curtdo = getsetting('tech_alpha', $techid)["value"]; +$cursdo = getsetting('subj_alpha', $techid)["value"]; +$curbgc = getsetting('background_color', $techid)["value"]; +$cursbc = getsetting('sidebar_color', $techid)["value"]; +$curmbgc = getsetting('menubg_color', $techid)["value"]; +$curtc = getsetting('text_color', $techid)["value"]; +$curlc = getsetting('link_color', $techid)["value"]; +$curvlc = getsetting('vlink_color', $techid)["value"]; +$curhc = getsetting('heading_color', $techid)["value"]; +$curlogstyle = getsetting('log_style', $techid)["value"]; // show the form echo " @@ -149,19 +152,19 @@ Password:  

Need a random password?   "; -$rpw=substr(str_shuffle(password_hash(microtime(),PASSWORD_DEFAULT)), 10, 12); +$rpw = substr(str_shuffle(password_hash(microtime(), PASSWORD_DEFAULT)), 10, 12); echo "   $rpw

Shift:   "; -$logstyleqry=mysqli_query($db,"select styleid,stylename from styles where styletype=\"logdisplay\""); -while ($logstylerow=mysqli_fetch_assoc($logstyleqry)) { - if ($logstylerow["styleid"]==$curlogstyle) { - printf("",$logstylerow["styleid"],$logstylerow["stylename"]); +$logstyleqry = mysqli_query($db, "select styleid,stylename from styles where styletype=\"logdisplay\""); +while ($logstylerow = mysqli_fetch_assoc($logstyleqry)) { + if ($logstylerow["styleid"] == $curlogstyle) { + printf("", $logstylerow["styleid"], $logstylerow["stylename"]); } else { - printf("",$logstylerow["styleid"],$logstylerow["stylename"]); + printf("", $logstylerow["styleid"], $logstylerow["stylename"]); } } echo " @@ -236,7 +239,7 @@ echo "
My Color Preferences

"; -switch($modcolor) { +switch ($modcolor) { case "background_color": echo "
Tech:  $tname @@ -597,25 +610,25 @@ if ($printfmt) {

"; } - + echo "Maintenance Actions    "; if ($_SESSION['login'] && $maintformid) echo ""; echo "

"; - - - $maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc"); - while ($actiontable=mysqli_fetch_assoc($maintactionqry)) { - $maintactionid=$actiontable["maintactionid"]; - $actiondate=$actiontable["actiondate"]; - $actiontime=$actiontable["actiontime"]; - $maintformnum=$actiontable["maintformnum"]; - $tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]); - $actiontext=convertweblinks($actiontable["action"]); + + + $maintactionqry = mysqli_query($db, "select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc"); + while ($actiontable = mysqli_fetch_assoc($maintactionqry)) { + $maintactionid = $actiontable["maintactionid"]; + $actiondate = $actiontable["actiondate"]; + $actiontime = $actiontable["actiontime"]; + $maintformnum = $actiontable["maintformnum"]; + $tname = dblookup($db, "techs", "techid", "techname", $actiontable["actiontech"]); + $actiontext = convertweblinks($actiontable["action"]); // print the table echo "
"; - if (($loggedinas==$actiontable["actiontech"]) || $isadmin) { + if (($loggedinas == $actiontable["actiontech"]) || $isadmin) { echo " \"Edit   \"Delete @@ -638,16 +651,14 @@ if ($printfmt) {

"; } - + echo " "; } banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/partentry.php b/distfiles/partentry.php index ed7ba64..5775dfd 100644 --- a/distfiles/partentry.php +++ b/distfiles/partentry.php @@ -11,39 +11,39 @@ include("functions.php"); if (!isset($_SESSION['login'])) { - header ("Location: login.php"); + header("Location: login.php"); } -$loggedinas=$_SESSION['login']; -$isadmin=dblookup($db,"techs","techid","admin",$loggedinas); +$loggedinas = $_SESSION['login']; +$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas); -$print=$_REQUEST['print'] ?? NULL; -$add=$_REQUEST['add'] ?? NULL; -$edit=$_REQUEST['edit'] ?? NULL; -$delete=$_REQUEST['delete'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$add = $_REQUEST['add'] ?? NULL; +$edit = $_REQUEST['edit'] ?? NULL; +$delete = $_REQUEST['delete'] ?? NULL; -$partid=$_REQUEST['partid'] ?? NULL; -$uid=$_REQUEST['uid'] ?? NULL; -$partnum=$_REQUEST['partnum'] ?? NULL; -$sernum=$_REQUEST['sernum'] ?? NULL; -$partname=$_REQUEST['partname'] ?? NULL; -$submit=$_REQUEST['submit'] ?? NULL; +$partid = $_REQUEST['partid'] ?? NULL; +$uid = $_REQUEST['uid'] ?? NULL; +$partnum = $_REQUEST['partnum'] ?? NULL; +$sernum = $_REQUEST['sernum'] ?? NULL; +$partname = $_REQUEST['partname'] ?? NULL; +$submit = $_REQUEST['submit'] ?? NULL; -$logname=LOG_NAME; -$uidtext=UID_TEXT; +$logname = LOG_NAME; +$uidtext = UID_TEXT; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } if ($edit || $delete) { - framework("begin","$logname","Part Edit",$print); + framework("begin", "$logname", "Part Edit", $print); } else { - $add=1; - framework("begin","$logname","Part Entry",$print); + $add = 1; + framework("begin", "$logname", "Part Entry", $print); } // ******** begin database manipulation ******** @@ -53,11 +53,11 @@ if ($add) { if ($submit) { // add the entry if submit is pressed if ($uid || ($partnum && $sernum)) { - $partexists=mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uid\" or (partnum=\"$partnum\" and sernum=\"$sernum\")")); + $partexists = mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uid\" or (partnum=\"$partnum\" and sernum=\"$sernum\")")); if (! $partexists) { // add to parts table - mysqli_query($db,"insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")"); - $partid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")"); + $partid = mysqli_insert_id($db); } } } @@ -66,18 +66,18 @@ if ($edit) { if ($submit) { if ($uid || ($partnum && $sernum)) { // update parts table - mysqli_query($db,"update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$partid\""); + mysqli_query($db, "update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$partid\""); } } } if ($delete) { // check for occurrence in logparts table - $inlogparts=mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where partid=\"$partid\"")); + $inlogparts = mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where partid=\"$partid\"")); // check for occurrence in maintforms table - $inmaintforms=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mfpart=\"$partid\"")); + $inmaintforms = mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mfpart=\"$partid\"")); // delete from parts table - if(!$inlogparts && !$inmaintforms) { - mysqli_query($db,"delete from parts where partid=\"$partid\""); + if (!$inlogparts && !$inmaintforms) { + mysqli_query($db, "delete from parts where partid=\"$partid\""); } } @@ -85,24 +85,24 @@ if ($delete) { pagetable("begin"); if (!$print) { - pageblock("left","begin"); + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); // display the form -$partdatainput=array(); -$partdatainput['partid']=$partid; -$partinfo=get_part_data($partdatainput); -if ($partinfo['result']==2) { - $pdatamismatch=TRUE; +$partdatainput = array(); +$partdatainput['partid'] = $partid; +$partinfo = get_part_data($partdatainput); +if ($partinfo['result'] == 2) { + $pdatamismatch = TRUE; } else { - $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; + $pdatamismatch = FALSE; + $uid = (array_key_exists('uid', $partinfo)) ? $partinfo['uid'] : NULL; + $partnum = (array_key_exists('partnum', $partinfo)) ? $partinfo['partnum'] : NULL; + $sernum = (array_key_exists('sernum', $partinfo)) ? $partinfo['sernum'] : NULL; + $partname = (array_key_exists('partname', $partinfo)) ? $partinfo['partname'] : NULL; } if ($delete) { if ($inmaintforms) { @@ -168,9 +168,7 @@ echo " "; banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/parts.php b/distfiles/parts.php index 7893f93..606eac2 100644 --- a/distfiles/parts.php +++ b/distfiles/parts.php @@ -10,50 +10,50 @@ include("functions.php"); if (isset($_SESSION['login'])) { - $loggedin=1; + $loggedin = TRUE; } else { - unset($loggedin); + $loggedin = FALSE; } -$print=$_REQUEST['print'] ?? NULL; -$add=$_REQUEST['add'] ?? NULL; -$sort=$_REQUEST['sort'] ?? NULL; -$order=$_REQUEST['order'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$add = $_REQUEST['add'] ?? NULL; +$sort = $_REQUEST['sort'] ?? NULL; +$order = $_REQUEST['order'] ?? NULL; -$logname=LOG_NAME; -$uidtext=UID_TEXT; +$logname = LOG_NAME; +$uidtext = UID_TEXT; if ($add) { - header ("Location: partentry.php?add=1"); + header("Location: partentry.php?add=1"); } -if (! $sort) $sort="uid"; +if (! $sort) $sort = "uid"; if ($order == "asc") { - $order="desc"; + $order = "desc"; } else if ($order == "desc") { - $order="asc"; + $order = "asc"; } else { - $order="asc"; + $order = "asc"; } if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname","Parts",$print); +framework("begin", "$logname", "Parts", $print); pagetable("begin"); -if(!$print) { - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); if ($loggedin) { echo " @@ -71,15 +71,16 @@ echo "
Part Name
%s @@ -87,22 +88,24 @@ while ($partline=mysqli_fetch_assoc($partqry)) { %s %s %s
%s %s %s %s
", - $eventdata_eventid,$duedatestrg, - $devicedata_devicedesc,$devicedata_devicename, - $taskdata_taskdesc,$taskdata_taskname, - $lastdatestrg + $eventdata_eventid, + $duedatestrg, + $devicedata_devicedesc, + $devicedata_devicename, + $taskdata_taskdesc, + $taskdata_taskname, + $lastdatestrg ); } echo "
Page background color"; colorpicker("profile.php?setcolor=1&modcolor=background_color&hexcolor="); @@ -290,9 +293,7 @@ echo " "; -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/refchain.php b/distfiles/refchain.php index f13f231..2826055 100644 --- a/distfiles/refchain.php +++ b/distfiles/refchain.php @@ -9,69 +9,70 @@ include("functions.php"); -$print=$_REQUEST['print'] ?? ""; -$chainnote=$_REQUEST['chainnote']; +$print = $_REQUEST['print'] ?? ""; +$chainnote = $_REQUEST['chainnote'] ?? NULL; -$logname=LOG_NAME; +$logname = LOG_NAME; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname","Reference Chain Display",$print); +framework("begin", "$logname", "Reference Chain Display", $print); // ******** begin database manipulation ******** -$master=generate_chain($chainnote); +$master = generate_chain($chainnote); // ******** end database manipulation ******** pagetable("begin"); -if(!$print){ - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); // display the chain -$mptr=0; +$mptr = 0; echo "

"; echo ""; -while($mptr\"Add    "; +while ($mptr < count($master)) { + if (mysqli_num_rows(mysqli_query($db, "select * from lognotes where lognoteid=$master[$mptr]"))) { + $tablerow = mysqli_fetch_assoc(mysqli_query($db, "select * from lognotes where lognoteid=$master[$mptr]")); + $noteid = $tablerow["lognoteid"]; + $urldatestr = "y=" . date("Y", strtotime($tablerow["date"])) . "&m=" . date("m", strtotime($tablerow["date"])) . "&d=" . date("d", strtotime($tablerow["date"])); + $refs = "  \"Add    "; // convert the shift number to a name - $shname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]); + $shname = dblookup($db, "shifts", "shiftid", "shiftname", $tablerow["shift"]); // convert tech number to name - $tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]); + $tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]); //convert subject number to name - $subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]); + $subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]); // create links of urls in note - $fmtnote=convertweblinks($tablerow["lognote"]); + $fmtnote = convertweblinks($tablerow["lognote"]); // generate the flags string - $flagstring=""; - $flagmapqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$noteid"); + $flagstring = ""; + $flagmapqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$noteid"); if (mysqli_num_rows($flagmapqry)) { - while ($flagids=mysqli_fetch_row($flagmapqry)) { - $flagid=$flagids[0]; - $flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); - $flagcolor=$flagparam["flagcolor"]; - $flagsym=$flagparam["flagsym"]; - $flagstring=$flagstring."$flagsym  "; + 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 . "$flagsym  "; } } - - if ($flagstring) $fmtnote=$fmtnote."
".$flagstring; - printf(" + + if ($flagstring) $fmtnote = $fmtnote . "
" . $flagstring; + printf( + "
@@ -81,23 +82,24 @@ while($mptr%s ", - $tablerow["lognoteid"],$tablerow["lognoteid"], - $tablerow["date"],$tablerow["time"], - $shname, - $tname, - $subjname, - $fmtnote, - $refs); + $tablerow["lognoteid"], + $tablerow["lognoteid"], + $tablerow["date"], + $tablerow["time"], + $shname, + $tname, + $subjname, + $fmtnote, + $refs + ); } else { - printf("\n",$master[$mptr]); + printf("\n", $master[$mptr]); } - $mptr=$mptr+1; + $mptr = $mptr + 1; } echo "
Note IDDate / TimeShiftTechSubjectNoteReferences
%s %s / %s%s
Note Id %s has been deleted and cannot be displayed.
Note Id %s has been deleted and cannot be displayed.


"; banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/schedmaint.php b/distfiles/schedmaint.php index db5e130..1dacf33 100644 --- a/distfiles/schedmaint.php +++ b/distfiles/schedmaint.php @@ -10,76 +10,76 @@ include("functions.php"); if (isset($_SESSION['login'])) { - $loggedin=true; + $loggedin = true; } else { - $loggedin=false; + $loggedin = false; } -$techid=$_SESSION['login'] ?? NULL; -$isadmin=dblookup($db,"techs","techid","admin",$techid); +$techid = $_SESSION['login'] ?? NULL; +$isadmin = dblookup($db, "techs", "techid", "admin", $techid); -$upcoming=$_REQUEST['upcoming'] ?? NULL; -$schedule=$_REQUEST['schedule'] ?? NULL; -$tasks=$_REQUEST['tasks'] ?? NULL; -$devices=$_REQUEST['devices'] ?? NULL; -$action=$_REQUEST['action'] ?? NULL; -$complete=$_REQUEST['complete'] ?? NULL; -$defer=$_REQUEST['defer'] ?? NULL; -$add=$_REQUEST['add'] ?? NULL; -$edit=$_REQUEST['edit'] ?? NULL; -$update=$_REQUEST['update'] ?? NULL; -$delete=$_REQUEST['delete'] ?? NULL; -$id=$_REQUEST['id'] ?? NULL; -$active_flag=$_REQUEST['active_flag'] ?? 0; +$upcoming = $_REQUEST['upcoming'] ?? NULL; +$schedule = $_REQUEST['schedule'] ?? NULL; +$tasks = $_REQUEST['tasks'] ?? NULL; +$devices = $_REQUEST['devices'] ?? NULL; +$action = $_REQUEST['action'] ?? NULL; +$complete = $_REQUEST['complete'] ?? NULL; +$defer = $_REQUEST['defer'] ?? NULL; +$add = $_REQUEST['add'] ?? NULL; +$edit = $_REQUEST['edit'] ?? NULL; +$update = $_REQUEST['update'] ?? NULL; +$delete = $_REQUEST['delete'] ?? NULL; +$id = $_REQUEST['id'] ?? NULL; +$active_flag = $_REQUEST['active_flag'] ?? 0; -$devicename=$_REQUEST['devicename'] ?? NULL; -$devicedesc=$_REQUEST['devicedesc'] ?? NULL; -$group_flag=$_REQUEST['group_flag'] ?? 0; -$members=$_REQUEST['members'] ?? []; +$devicename = $_REQUEST['devicename'] ?? NULL; +$devicedesc = $_REQUEST['devicedesc'] ?? NULL; +$group_flag = $_REQUEST['group_flag'] ?? 0; +$members = $_REQUEST['members'] ?? []; -$weekdays_only=$_REQUEST['weekdays_only'] ?? NULL; -$nextdue_relative=$_REQUEST['nextdue_relative'] ?? NULL; -$taskname=$_REQUEST['taskname'] ?? NULL; -$taskdesc=$_REQUEST['taskdesc'] ?? NULL; -$frequency=$_REQUEST['frequency'] ?? NULL; -$period=$_REQUEST['period'] ?? NULL; -$refdoc_name=$_REQUEST['refdoc_name'] ?? NULL; -$refdoc_url=$_REQUEST['refdoc_url'] ?? NULL; +$weekdays_only = $_REQUEST['weekdays_only'] ?? NULL; +$nextdue_relative = $_REQUEST['nextdue_relative'] ?? NULL; +$taskname = $_REQUEST['taskname'] ?? NULL; +$taskdesc = $_REQUEST['taskdesc'] ?? NULL; +$frequency = $_REQUEST['frequency'] ?? NULL; +$period = $_REQUEST['period'] ?? NULL; +$refdoc_name = $_REQUEST['refdoc_name'] ?? NULL; +$refdoc_url = $_REQUEST['refdoc_url'] ?? NULL; -$deferred_flag=$_REQUEST['deferred_flag'] ?? 0; -$deferred_date=$_REQUEST['deferred_date'] ?? NULL; -$start_date=$_REQUEST['start_date'] ?? NULL; -$last_date=$_REQUEST['last_date'] ?? NULL; -$task=$_REQUEST['task'] ?? NULL; -$device=$_REQUEST['device'] ?? NULL; -$deferuntil=$_REQUEST['deferuntil'] ?? NULL; -$completedate=$_REQUEST['completedate'] ?? NULL; -$addlognote=$_REQUEST['addlognote'] ?? NULL; +$deferred_flag = $_REQUEST['deferred_flag'] ?? 0; +$deferred_date = $_REQUEST['deferred_date'] ?? NULL; +$start_date = $_REQUEST['start_date'] ?? NULL; +$last_date = $_REQUEST['last_date'] ?? NULL; +$task = $_REQUEST['task'] ?? NULL; +$device = $_REQUEST['device'] ?? NULL; +$deferuntil = $_REQUEST['deferuntil'] ?? NULL; +$completedate = $_REQUEST['completedate'] ?? NULL; +$addlognote = $_REQUEST['addlognote'] ?? NULL; -$logname=LOG_NAME; +$logname = LOG_NAME; -$print=$_REQUEST['print'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } // **** BEGIN DATABASE OPERATIONS **** -$tomorrow=mysqli_fetch_row(mysqli_query($db,"select adddate((select current_date),1)"))[0]; -$errorstack=array(); +$tomorrow = mysqli_fetch_row(mysqli_query($db, "select adddate((select current_date),1)"))[0]; +$errorstack = array(); if ($action) { if ($complete) { // sanitize user input - $completedate=mysqli_real_escape_string($db,$completedate); + $completedate = mysqli_real_escape_string($db, $completedate); // update events - mysqli_query($db,"update events set last_date=\"$completedate\", deferred_flag=0, deferred_date=\"0000-00-00\" where eventid=\"$id\""); + mysqli_query($db, "update events set last_date=\"$completedate\", deferred_flag=0, deferred_date=\"0000-00-00\" where eventid=\"$id\""); if ($addlognote) { - $compltaskname=mysqli_fetch_row(mysqli_query($db,"select tasks.taskname from tasks,events where events.eventid=\"$id\" and tasks.taskid=events.task"))[0]; - $compldevicename=mysqli_fetch_row(mysqli_query($db,"select devices.devicename from devices,events where events.eventid=\"$id\" and devices.deviceid=events.device"))[0]; - $lognotestrg="Scheduled Maintenance task \"$compltaskname\" completed on device \"$compldevicename\"."; + $compltaskname = mysqli_fetch_row(mysqli_query($db, "select tasks.taskname from tasks,events where events.eventid=\"$id\" and tasks.taskid=events.task"))[0]; + $compldevicename = mysqli_fetch_row(mysqli_query($db, "select devices.devicename from devices,events where events.eventid=\"$id\" and devices.deviceid=events.device"))[0]; + $lognotestrg = "Scheduled Maintenance task \"$compltaskname\" completed on device \"$compldevicename\"."; // redirect to logentry header("Cache-Control:no-cache, must-revalidate"); header("Pragma:no-cache"); @@ -89,7 +89,7 @@ if ($action) { } if ($defer) { // update events - mysqli_query($db,"update events set deferred_flag=1, deferred_date=\"$deferuntil\" where eventid=\"$id\""); + mysqli_query($db, "update events set deferred_flag=1, deferred_date=\"$deferuntil\" where eventid=\"$id\""); } } if ($add) { @@ -97,41 +97,41 @@ if ($add) { // do error checking // check for task selected if ($task) { - $taskselected=true; + $taskselected = true; } else { - $taskselected=false; - $errorstack[]=" You didn't select a task.
"; + $taskselected = false; + $errorstack[] = " You didn't select a task.
"; } // check for device selected if ($device) { - $deviceselected=true; + $deviceselected = true; } else { - $deviceselected=false; - $errorstack[]=" You didn't select a device.
"; + $deviceselected = false; + $errorstack[] = " You didn't select a device.
"; } // sanitize text data - $start_date=mysqli_real_escape_string($db,$start_date); - $last_date=mysqli_real_escape_string($db,$last_date); - $deferred_date=mysqli_real_escape_string($db,$deferred_date); + $start_date = mysqli_real_escape_string($db, $start_date); + $last_date = mysqli_real_escape_string($db, $last_date); + $deferred_date = mysqli_real_escape_string($db, $deferred_date); if ($taskselected && $deviceselected) { // determine if device represents a group and break out individual devices - if (dblookup($db,"devices","deviceid","group_flag",$device)) { - $memberqry=mysqli_query($db,"select memberdevice from devicegroups where groupdevice=\"$device\""); - $memberlist=array(); - while ($memberrow=mysqli_fetch_row($memberqry)) { - $memberlist[]=$memberrow[0]; + if (dblookup($db, "devices", "deviceid", "group_flag", $device)) { + $memberqry = mysqli_query($db, "select memberdevice from devicegroups where groupdevice=\"$device\""); + $memberlist = array(); + while ($memberrow = mysqli_fetch_row($memberqry)) { + $memberlist[] = $memberrow[0]; } } else { - $memberlist=array($device); + $memberlist = array($device); } // run through the memberlist and modify the table foreach ($memberlist as $memberdev) { - if ($start_date==NULL) $start_date=$today; - if ($last_date==NULL) $last_date="0000-00-00"; - if ($deferred_date==NULL) $deferred_date="0000-00-00"; - $addqry=("insert into events(task,device,start_date,last_date,deferred_flag,deferred_date,active_flag) + if ($start_date == NULL) $start_date = $today; + if ($last_date == NULL) $last_date = "0000-00-00"; + if ($deferred_date == NULL) $deferred_date = "0000-00-00"; + $addqry = ("insert into events(task,device,start_date,last_date,deferred_flag,deferred_date,active_flag) values(\"$task\",\"$memberdev\",\"$start_date\",\"$last_date\",\"$deferred_flag\",\"$deferred_date\",\"$active_flag\")"); - mysqli_query($db,$addqry); + mysqli_query($db, $addqry); } } } @@ -139,54 +139,54 @@ if ($add) { // do error checking // test for name supplied if (strlen(trim($taskname))) { - $namesuppld=true; + $namesuppld = true; } else { - $namesuppld=false; - $errorstack[]=" Task name cannot be blank.
"; + $namesuppld = false; + $errorstack[] = " Task name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select taskid from tasks where taskname=\"$taskname\""))) { - $nameunique=false; - $errorstack[]=" Task name already exists.
"; + if (mysqli_num_rows(mysqli_query($db, "select taskid from tasks where taskname=\"$taskname\""))) { + $nameunique = false; + $errorstack[] = " Task name already exists.
"; } else { - $nameunique=true; + $nameunique = true; } // sanitize text data - $taskname=mysqli_real_escape_string($db,$taskname); - $taskdesc=mysqli_real_escape_string($db,$taskdesc); - $refdoc_name=mysqli_real_escape_string($db,$refdoc_name); - $refdoc_url=mysqli_real_escape_string($db,$refdoc_url); - + $taskname = mysqli_real_escape_string($db, $taskname); + $taskdesc = mysqli_real_escape_string($db, $taskdesc); + $refdoc_name = mysqli_real_escape_string($db, $refdoc_name); + $refdoc_url = mysqli_real_escape_string($db, $refdoc_url); + if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into tasks(taskname,taskdesc,frequency,period,weekdays_only,nextdue_relative,refdoc_name,refdoc_url,active_flag) + $addqry = ("insert into tasks(taskname,taskdesc,frequency,period,weekdays_only,nextdue_relative,refdoc_name,refdoc_url,active_flag) values(\"$taskname\",\"$taskdesc\",\"$frequency\",\"$period\",\"$weekdays_only\",\"$nextdue_relative\",\"$refdoc_name\",\"$refdoc_url\",\"$active_flag\")"); - mysqli_query($db,$addqry); + mysqli_query($db, $addqry); } } if ($devices) { // do error checking // test for name supplied if (strlen(trim($devicename))) { - $namesuppld=true; + $namesuppld = true; } else { - $namesuppld=false; - $errorstack[]=" Device name cannot be blank.
"; + $namesuppld = false; + $errorstack[] = " Device name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select deviceid from devices where devicename=\"$devicename\""))) { - $nameunique=false; - $errorstack[]=" Device name already exists.
"; + if (mysqli_num_rows(mysqli_query($db, "select deviceid from devices where devicename=\"$devicename\""))) { + $nameunique = false; + $errorstack[] = " Device name already exists.
"; } else { - $nameunique=true; + $nameunique = true; } // sanitize name and description - $devicename=mysqli_real_escape_string($db,$devicename); - $devicedesc=mysqli_real_escape_string($db,$devicedesc); + $devicename = mysqli_real_escape_string($db, $devicename); + $devicedesc = mysqli_real_escape_string($db, $devicedesc); if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into devices(devicename,devicedesc,group_flag,active_flag) values(\"$devicename\",\"$devicedesc\",\"$group_flag\",\"$active_flag\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into devices(devicename,devicedesc,group_flag,active_flag) values(\"$devicename\",\"$devicedesc\",\"$group_flag\",\"$active_flag\")"); + mysqli_query($db, $addqry); } } } @@ -194,19 +194,19 @@ if ($edit) { if ($schedule) { if ($delete) { // delete entity - mysqli_query($db,"delete from events where eventid=\"$id\""); + mysqli_query($db, "delete from events where eventid=\"$id\""); } if ($update) { // do error checking // sanitize text data - $start_date=mysqli_real_escape_string($db,$start_date); - $last_date=mysqli_real_escape_string($db,$last_date); - $deferred_date=mysqli_real_escape_string($db,$deferred_date); + $start_date = mysqli_real_escape_string($db, $start_date); + $last_date = mysqli_real_escape_string($db, $last_date); + $deferred_date = mysqli_real_escape_string($db, $deferred_date); // update the tasks table - if ($start_date==NULL) $start_date=$today; - if ($last_date==NULL) $last_date="0000-00-00"; - if ($deferred_date==NULL) $deferred_date="0000-00-00"; - mysqli_query($db,"update events + if ($start_date == NULL) $start_date = $today; + if ($last_date == NULL) $last_date = "0000-00-00"; + if ($deferred_date == NULL) $deferred_date = "0000-00-00"; + mysqli_query($db, "update events set task=\"$task\",device=\"$device\",start_date=\"$start_date\",last_date=\"$last_date\",deferred_flag=\"$deferred_flag\", deferred_date=\"$deferred_date\",active_flag=\"$active_flag\" where eventid=\"$id\""); @@ -215,45 +215,45 @@ if ($edit) { if ($tasks) { if ($delete) { // check for scheduled maintenance for this entity - if (mysqli_num_rows(mysqli_query($db,"select eventid from events where task=\"$id\""))) { - $hasevents=true; - $errorstack[]=" Task has been scheduled maintenance and cannot be deleted.
"; + if (mysqli_num_rows(mysqli_query($db, "select eventid from events where task=\"$id\""))) { + $hasevents = true; + $errorstack[] = " Task has been scheduled maintenance and cannot be deleted.
"; } else { - $hasevents=false; + $hasevents = false; } if (!$hasevents) { // delete entity - mysqli_query($db,"delete from tasks where taskid=\"$id\""); + mysqli_query($db, "delete from tasks where taskid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($taskname))) { - $namesuppld=true; + $namesuppld = true; } else { - $namesuppld=false; - $errorstack[]=" Task name cannot be blank.
"; + $namesuppld = false; + $errorstack[] = " Task name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select taskid from tasks where taskname=\"$taskname\" and taskid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select taskid from tasks where taskname=\"$taskname\""))) { - $nameunique=false; - $errorstack[]=" Task name already exists.
"; + if (mysqli_num_rows(mysqli_query($db, "select taskid from tasks where taskname=\"$taskname\" and taskid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select taskid from tasks where taskname=\"$taskname\""))) { + $nameunique = false; + $errorstack[] = " Task name already exists.
"; } else { - $nameunique=true; + $nameunique = true; } } else { - $nameunique=true; + $nameunique = true; } // sanitize text data - $taskname=mysqli_real_escape_string($db,$taskname); - $taskdesc=mysqli_real_escape_string($db,$taskdesc); - $refdoc_name=mysqli_real_escape_string($db,$refdoc_name); - $refdoc_url=mysqli_real_escape_string($db,$refdoc_url); + $taskname = mysqli_real_escape_string($db, $taskname); + $taskdesc = mysqli_real_escape_string($db, $taskdesc); + $refdoc_name = mysqli_real_escape_string($db, $refdoc_name); + $refdoc_url = mysqli_real_escape_string($db, $refdoc_url); if ($namesuppld && $nameunique) { // update the tasks table - mysqli_query($db,"update tasks + mysqli_query($db, "update tasks set taskname=\"$taskname\",taskdesc=\"$taskdesc\",frequency=\"$frequency\",period=\"$period\",weekdays_only=\"$weekdays_only\", nextdue_relative=\"$nextdue_relative\",refdoc_name=\"$refdoc_name\",refdoc_url=\"$refdoc_url\",active_flag=\"$active_flag\" where taskid=\"$id\""); @@ -263,48 +263,48 @@ if ($edit) { if ($devices) { if ($delete) { // check for scheduled maintenance for this device - if (mysqli_num_rows(mysqli_query($db,"select eventid from events where device=\"$id\""))) { - $hasevents=true; - $errorstack[]=" Device has scheduled maintenance and cannot be deleted.
"; + if (mysqli_num_rows(mysqli_query($db, "select eventid from events where device=\"$id\""))) { + $hasevents = true; + $errorstack[] = " Device has scheduled maintenance and cannot be deleted.
"; } else { - $hasevents=false; + $hasevents = false; } if (!$hasevents) { // delete entity - mysqli_query($db,"delete from devices where deviceid=\"$id\""); + mysqli_query($db, "delete from devices where deviceid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($devicename))) { - $namesuppld=true; + $namesuppld = true; } else { - $namesuppld=false; - $errorstack[]=" Device name cannot be blank.
"; + $namesuppld = false; + $errorstack[] = " Device name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select deviceid from devices where devicename=\"$devicename\" and deviceid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select deviceid from devices where devicename=\"$devicename\""))) { - $nameunique=false; - $errorstack[]=" Device name already exists.
"; + if (mysqli_num_rows(mysqli_query($db, "select deviceid from devices where devicename=\"$devicename\" and deviceid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select deviceid from devices where devicename=\"$devicename\""))) { + $nameunique = false; + $errorstack[] = " Device name already exists.
"; } else { - $nameunique=true; + $nameunique = true; } } else { - $nameunique=true; + $nameunique = true; } // sanitize name and description - $devicename=mysqli_real_escape_string($db,$devicename); - $devicedesc=mysqli_real_escape_string($db,$devicedesc); + $devicename = mysqli_real_escape_string($db, $devicename); + $devicedesc = mysqli_real_escape_string($db, $devicedesc); if ($namesuppld && $nameunique) { // update the devices table - mysqli_query($db,"update devices set devicename=\"$devicename\",devicedesc=\"$devicedesc\",group_flag=\"$group_flag\",active_flag=\"$active_flag\" where deviceid=\"$id\""); + mysqli_query($db, "update devices set devicename=\"$devicename\",devicedesc=\"$devicedesc\",group_flag=\"$group_flag\",active_flag=\"$active_flag\" where deviceid=\"$id\""); // update the devicegroups table - mysqli_query($db,"delete from devicegroups where groupdevice=\"$id\""); + mysqli_query($db, "delete from devicegroups where groupdevice=\"$id\""); if ($group_flag) { foreach ($members as $member) { - mysqli_query($db,"insert into devicegroups(groupdevice,memberdevice) values(\"$id\",\"$member\")"); + mysqli_query($db, "insert into devicegroups(groupdevice,memberdevice) values(\"$id\",\"$member\")"); } } } @@ -314,17 +314,17 @@ if ($edit) { // **** END DATABASE OPERATIONS **** -framework("begin","$logname","Scheduled Maintenance",$print); +framework("begin", "$logname", "Scheduled Maintenance", $print); //var_dump($_REQUEST); pagetable("begin"); -pageblock("left","begin"); +pageblock("left", "begin"); sidemenu(); -pageblock("left","end"); +pageblock("left", "end"); -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); if ($loggedin) { echo " @@ -340,17 +340,17 @@ if ($loggedin) { } // display any errors from database operations if (count($errorstack)) { - foreach($errorstack as $errorline) { + foreach ($errorstack as $errorline) { echo "$errorline
"; } } if ($action) { // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from events where eventid=$id")); + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from events where eventid=$id")); extract($currentvalues); - $taskname=dblookup($db,"tasks","taskid","taskname",$task); - $devicename=dblookup($db,"devices","deviceid","devicename",$device); + $taskname = dblookup($db, "tasks", "taskid", "taskname", $task); + $devicename = dblookup($db, "devices", "deviceid", "devicename", $device); // display form to complete or defer echo "
Task :   $taskname Device :   $devicename
@@ -383,46 +383,46 @@ if ($action) { // manage maintenance schedule if ($edit) { // set form options for editing - $sectiontitle="Modify Event

"; - $formtag="
"; - $buttontags=" + $sectiontitle = "Modify Event

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from events where eventid=$id")); + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from events where eventid=$id")); extract($currentvalues); if ($active_flag) { - $activetag=""; + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } if ($deferred_flag) { - $deferredtag=""; + $deferredtag = ""; } else { - $deferredtag=""; + $deferredtag = ""; } - if ($start_date=="0000-00-00") $start_date=$today; - if ($last_date=="0000-00-00") $last_date=""; - if ($deferred_date=="0000-00-00") $deferred_date=$tomorrow; - $deferuntiltag=""; - $startdatetag=""; - $lastdatetag=""; + if ($start_date == "0000-00-00") $start_date = $today; + if ($last_date == "0000-00-00") $last_date = ""; + if ($deferred_date == "0000-00-00") $deferred_date = $tomorrow; + $deferuntiltag = ""; + $startdatetag = ""; + $lastdatetag = ""; } else { // set form options for add - $sectiontitle="Add Scheduled Maintenance

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add Scheduled Maintenance

"; + $formtag = ""; + $buttontags = " "; // set default values - $deferredtag=""; - $deferuntiltag=""; - $activetag=""; - $startdatetag=""; - $lastdatetag=""; + $deferredtag = ""; + $deferuntiltag = ""; + $activetag = ""; + $startdatetag = ""; + $lastdatetag = ""; } // display form echo " @@ -434,13 +434,13 @@ if ($action) {
Task:  Device:   "; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { extract($tablerow); - if ($start_date=="0000-00-00") $start_date=$today; - if ($last_date=="0000-00-00") $last_date=""; - if ($deferred_date=="0000-00-00") $deferred_date=""; + if ($start_date == "0000-00-00") $start_date = $today; + if ($last_date == "0000-00-00") $last_date = ""; + if ($deferred_date == "0000-00-00") $deferred_date = ""; if ($active_flag) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } if ($deferred_flag) { - $deferredflag="\"deferred\""; + $deferredflag = "\"deferred\""; } else { - $deferredflag="\"not"; + $deferredflag = "\"not"; } - $taskdata=mysqli_fetch_assoc(mysqli_query($db,"select * from tasks where taskid=\"$task\"")); - extract($taskdata,EXTR_PREFIX_ALL,"taskdata"); - $devicedata=mysqli_fetch_assoc(mysqli_query($db,"select * from devices where deviceid=\"$device\"")); - extract($devicedata,EXTR_PREFIX_ALL,"devicedata"); - if ($taskdata_period=="once") { - $tasktitle="One-time event"; + $taskdata = mysqli_fetch_assoc(mysqli_query($db, "select * from tasks where taskid=\"$task\"")); + extract($taskdata, EXTR_PREFIX_ALL, "taskdata"); + $devicedata = mysqli_fetch_assoc(mysqli_query($db, "select * from devices where deviceid=\"$device\"")); + extract($devicedata, EXTR_PREFIX_ALL, "devicedata"); + if ($taskdata_period == "once") { + $tasktitle = "One-time event"; } else { - $tasktitle="Repeat every $taskdata_frequency $taskdata_period"; + $tasktitle = "Repeat every $taskdata_frequency $taskdata_period"; } - printf(" + printf( + " @@ -520,60 +521,63 @@ if ($action) { ", - $eventid,$eventid, - $tasktitle,$taskdata_taskname, - $devicedata_devicename, - $start_date, - $last_date, - $deferredflag, - $deferred_date, - $statdef); + $eventid, + $eventid, + $tasktitle, + $taskdata_taskname, + $devicedata_devicename, + $start_date, + $last_date, + $deferredflag, + $deferred_date, + $statdef + ); } echo "
Event IDTaskDeviceStart DateLast
Completed
DeferredDeferred
Until
Active
%s %s%s %s
"; } else if ($tasks) { // manage tasks if ($edit) { // set form options for editing - $sectiontitle="Modify Task

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Task

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from tasks where taskid=$id")); + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from tasks where taskid=$id")); extract($currentvalues); - $perioddef=$period; + $perioddef = $period; if ($active_flag) { - $activetag=""; + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } if ($weekdays_only) { - $wdotag=""; + $wdotag = ""; } else { - $wdotag=""; + $wdotag = ""; } if ($nextdue_relative) { - $nextduetag="Absolute   Relative"; + $nextduetag = "Absolute   Relative"; } else { - $nextduetag="Absolute   Relative"; + $nextduetag = "Absolute   Relative"; } } else { // set form options for add - $sectiontitle="Add New Task

"; - $formtag=""; - $perioddef="once"; - $frequency=1; - $buttontags=" + $sectiontitle = "Add New Task

"; + $formtag = ""; + $perioddef = "once"; + $frequency = 1; + $buttontags = " "; // set default values - $wdotag=""; - $nextduetag="Absolute   Relative"; - $activetag=""; + $wdotag = ""; + $nextduetag = "Absolute   Relative"; + $activetag = ""; } // display form echo " @@ -590,10 +594,10 @@ if ($action) { Repeat every:     "; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { extract($tablerow); if ($active_flag) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - if ($period=="once") { - $rptstrg="one time only"; + if ($period == "once") { + $rptstrg = "one time only"; } else { - $rptstrg="$frequency $period"; + $rptstrg = "$frequency $period"; } - + if ($nextdue_relative) { - $duecalc="Relative"; + $duecalc = "Relative"; } else { - $duecalc="Absolute"; + $duecalc = "Absolute"; } if ($refdoc_name) { - $refstrg="$refdoc_name"; + $refstrg = "$refdoc_name"; if ($refdoc_url) { - $refstrg="$refdoc_name"; + $refstrg = "$refdoc_name"; } } else { - $refstrg=""; + $refstrg = ""; } if ($weekdays_only) { - $wdoflag="\"active\""; + $wdoflag = "\"active\""; } else { - $wdoflag="\"inactive\""; + $wdoflag = "\"inactive\""; } - printf(" + printf( + " @@ -660,54 +665,55 @@ if ($action) { ", - $taskid,$taskname, - $taskdesc, - $rptstrg, - $duecalc, - $wdoflag, - $refstrg, - $statdef); + $taskid, + $taskname, + $taskdesc, + $rptstrg, + $duecalc, + $wdoflag, + $refstrg, + $statdef + ); } echo "
Task NameTask DescriptionRepeat EveryDue Date
Calculation
Weekdays
Only
ReferenceActive
%s %s%s %s
"; - } else if ($devices) { // manage devices if ($edit) { // set form options for editing - $sectiontitle="Modify Device

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Device

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from devices where deviceid=$id")); + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from devices where deviceid=$id")); extract($currentvalues); if ($group_flag) { - $showgrouptable=true; - $grouptag=""; + $showgrouptable = true; + $grouptag = ""; } else { - $showgrouptable=false; - $grouptag=""; + $showgrouptable = false; + $grouptag = ""; } if ($active_flag) { - $activetag=""; + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Device

"; - $formtag=""; - $showgrouptable=false; - $buttontags=" + $sectiontitle = "Add New Device

"; + $formtag = ""; + $showgrouptable = false; + $buttontags = " "; // set default values - $activetag=""; - $grouptag=""; + $activetag = ""; + $grouptag = ""; } // display form echo " @@ -722,28 +728,30 @@ if ($action) { Device represents a group of devices:  $grouptag

"; if ($showgrouptable) { - $existingdevs=mysqli_query($db,"select * from devices where deviceid!=$id and active_flag=\"1\""); + $existingdevs = mysqli_query($db, "select * from devices where deviceid!=$id and active_flag=\"1\""); echo " Existing members of this group

"; - while ($grouprow=mysqli_fetch_assoc($existingdevs)) { - extract($grouprow,EXTR_PREFIX_ALL,"gtbl"); - if (mysqli_num_rows(mysqli_query($db,"select groupid from devicegroups where memberdevice=$gtbl_deviceid and groupdevice=$id"))) { - $memberdef=""; + while ($grouprow = mysqli_fetch_assoc($existingdevs)) { + extract($grouprow, EXTR_PREFIX_ALL, "gtbl"); + if (mysqli_num_rows(mysqli_query($db, "select groupid from devicegroups where memberdevice=$gtbl_deviceid and groupdevice=$id"))) { + $memberdef = ""; } else { - $memberdef=""; + $memberdef = ""; } - printf(" + printf( + " ", - $gtbl_devicename, - $gtbl_devicedesc, - $memberdef); + $gtbl_devicename, + $gtbl_devicedesc, + $memberdef + ); } echo "
Device NameDevice DescriptionMember
%s %s %s

"; } @@ -756,25 +764,26 @@ if ($action) {

"; // show table of current devices - $existingdata=mysqli_query($db,"select * from devices"); + $existingdata = mysqli_query($db, "select * from devices"); echo " Existing Devices   Click on the Device ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { extract($tablerow); if ($group_flag) { - $groupdef="\"This"; + $groupdef = "\"This"; } else { - $groupdef="\"This"; + $groupdef = "\"This"; } if ($active_flag) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " @@ -782,20 +791,25 @@ if ($action) { ", - $deviceid,$deviceid, - $devicename, - $devicedesc, - $groupdef, - $statdef); + $deviceid, + $deviceid, + $devicename, + $devicedesc, + $groupdef, + $statdef + ); } echo "
Device IDDevice NameDevice DescriptionGroupActive
%s %s%s %s
"; } else { - $ucevents=get_upcoming_events(); - + $ucevents = get_upcoming_events(); + // sort the upcoming events - function uc_cmp($a,$b) { return strcmp($a["duedate"], $b["duedate"]); } - uasort($ucevents,'uc_cmp'); - + function uc_cmp($a, $b) + { + return strcmp($a["duedate"], $b["duedate"]); + } + uasort($ucevents, 'uc_cmp'); + // show upcoming events table echo " Upcoming Scheduled Maintenance

@@ -806,55 +820,59 @@ if ($action) { "; foreach ($ucevents as $ucline) { extract($ucline); - printf(" + printf( + "
%s %s %s %s



"; - + // build array of deferred events - $defeventsqry=mysqli_query($db,"select * from events where active_flag=\"1\" and deferred_flag=\"1\" and deferred_date > \"$today\" order by deferred_date asc"); - $defevents=array(); - while ($defeventrow=mysqli_fetch_assoc($defeventsqry)) { + $defeventsqry = mysqli_query($db, "select * from events where active_flag=\"1\" and deferred_flag=\"1\" and deferred_date > \"$today\" order by deferred_date asc"); + $defevents = array(); + while ($defeventrow = mysqli_fetch_assoc($defeventsqry)) { // provide eventid,task,device,start_date,last_date,deferred_flag,deferred_date,active_flag - extract($defeventrow,EXTR_PREFIX_ALL,"def"); + extract($defeventrow, EXTR_PREFIX_ALL, "def"); // provide deviceid,devicename,devicedesc,group_flag,active_flag - $devicedata=mysqli_fetch_assoc(mysqli_query($db,"select * from devices where deviceid=\"$def_device\"")); - extract($devicedata,EXTR_PREFIX_ALL,"devicedata"); + $devicedata = mysqli_fetch_assoc(mysqli_query($db, "select * from devices where deviceid=\"$def_device\"")); + extract($devicedata, EXTR_PREFIX_ALL, "devicedata"); // provide taskid,taskname,taskdesc,frequency,period,weekdays_only,nextdue_relative,refdoc_name,refdoc_url,active_flag - $taskdata=mysqli_fetch_assoc(mysqli_query($db,"select * from tasks where taskid=\"$def_task\"")); - extract($taskdata,EXTR_PREFIX_ALL,"taskdata"); - if ( ! ($taskdata_period == "once" && $def_last_date > $def_start_date)) { - if ($def_last_date=="0000-00-00") { - $lastdatestrg="never"; + $taskdata = mysqli_fetch_assoc(mysqli_query($db, "select * from tasks where taskid=\"$def_task\"")); + extract($taskdata, EXTR_PREFIX_ALL, "taskdata"); + if (! ($taskdata_period == "once" && $def_last_date > $def_start_date)) { + if ($def_last_date == "0000-00-00") { + $lastdatestrg = "never"; } else { - $lastdatestrg="$def_last_date"; + $lastdatestrg = "$def_last_date"; } - $defeventline=array( - 'def_eventid'=>$def_eventid, - 'def_deferred_date'=>$def_deferred_date, - 'devicedata_devicedesc'=>$devicedata_devicedesc, - 'devicedata_devicename'=>$devicedata_devicename, - 'taskdata_taskdesc'=>$taskdata_taskdesc, - 'taskdata_taskname'=>$taskdata_taskname, - 'lastdatestrg'=>$lastdatestrg + $defeventline = array( + 'def_eventid' => $def_eventid, + 'def_deferred_date' => $def_deferred_date, + 'devicedata_devicedesc' => $devicedata_devicedesc, + 'devicedata_devicename' => $devicedata_devicename, + 'taskdata_taskdesc' => $taskdata_taskdesc, + 'taskdata_taskname' => $taskdata_taskname, + 'lastdatestrg' => $lastdatestrg ); - $defevents[]=$defeventline; + $defevents[] = $defeventline; } } - + // show deferred events table echo " Deferred Scheduled Maintenance

@@ -865,17 +883,21 @@ if ($action) { "; foreach ($defevents as $defline) { extract($defline); - printf(" + printf( + "
%s %s %s %s
"; while ($logtablerow = mysqli_fetch_assoc($logrowqry)) { - $logrefs="    \"Add"; + $logrefs = "    \"Add"; if (islink($logtablerow['lognoteid'])) { - $logrefs=$logrefs."      \"View"; + $logrefs = $logrefs . "      \"View"; } // convert the shift number to a name - $logshname=dblookup($db,"shifts","shiftid","shiftname",$logtablerow['shift']); + $logshname = dblookup($db, "shifts", "shiftid", "shiftname", $logtablerow['shift']); // convert tech number to name - $logtname=dblookup($db,"techs","techid","techname",$logtablerow['tech']); + $logtname = dblookup($db, "techs", "techid", "techname", $logtablerow['tech']); //convert subject number to name - $logsubjname=dblookup($db,"subjects","subjectid","subjectname",$logtablerow['subject']); + $logsubjname = dblookup($db, "subjects", "subjectid", "subjectname", $logtablerow['subject']); // create links of urls in note - $logfmtnote=convertweblinks($logtablerow['lognote']); - + $logfmtnote = convertweblinks($logtablerow['lognote']); + // generate the flags string - $flagstring=""; - $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."$flagsym  "; + $flagstring = ""; + $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 . "$flagsym  "; } if ($flagstring) { - $logfmtnote=$logfmtnote."
".$flagstring."     "; - } else { - $logfmtnote=$logfmtnote."
"; + $logfmtnote = $logfmtnote . "
" . $flagstring . "     "; + } else { + $logfmtnote = $logfmtnote . "
"; } - - printf(" + + printf( + " @@ -720,24 +741,27 @@ if ($search) { ", - $logtablerow['lognoteid'],$logtablerow['lognoteid'], - $logtablerow['date'],$logtablerow['time'], - $logshname, - $logtname, - $logsubjname, - $logfmtnote, - $logrefs); + $logtablerow['lognoteid'], + $logtablerow['lognoteid'], + $logtablerow['date'], + $logtablerow['time'], + $logshname, + $logtname, + $logsubjname, + $logfmtnote, + $logrefs + ); } echo "
Note IDDate/TimeShiftTechSubjectNoteReferences
%s %s / %s %s%s %s


"; } else { echo "No Logbook notes match your search criteria.

"; } } - if ($target[0]=="") $target=[]; - if (in_array("maintform",$target)) { + if ($target[0] == "") $target = []; + if (in_array("maintform", $target)) { // run maintforms query and show results - $mf_num_results=mysqli_num_rows($mfrowqry); - if($mf_num_results) { + $mf_num_results = mysqli_num_rows($mfrowqry); + if ($mf_num_results) { echo " Results from Maintenance Forms: $mf_num_results


@@ -754,25 +778,25 @@ if ($search) { "; while ($mfrow = mysqli_fetch_assoc($mfrowqry)) { // look up part data - $mfuid=dblookup($db,"parts","partid","uid",$mfrow["mfpart"]); - if ($mfuid=="") $mfuid=" "; - $mfpartno=dblookup($db,"parts","partid","partnum",$mfrow["mfpart"]); - if ($mfpartno=="") $mfpartno=" "; - $mfserno=dblookup($db,"parts","partid","sernum",$mfrow["mfpart"]); - if ($mfserno=="") $mfserno=" "; - $mfpartname=dblookup($db,"parts","partid","partname",$mfrow["mfpart"]); - if ($mfpartname=="") $mfpartname=" "; + $mfuid = dblookup($db, "parts", "partid", "uid", $mfrow["mfpart"]); + if ($mfuid == "") $mfuid = " "; + $mfpartno = dblookup($db, "parts", "partid", "partnum", $mfrow["mfpart"]); + if ($mfpartno == "") $mfpartno = " "; + $mfserno = dblookup($db, "parts", "partid", "sernum", $mfrow["mfpart"]); + if ($mfserno == "") $mfserno = " "; + $mfpartname = dblookup($db, "parts", "partid", "partname", $mfrow["mfpart"]); + if ($mfpartname == "") $mfpartname = " "; // look up tech name - $mftname=dblookup($db,"techs","techid","techname",$mfrow["mftech"]); - if ($mfrow["lognoteid"]==0) { - $mfnoteidval=" "; - $mfnotetag="%s%s"; + $mftname = dblookup($db, "techs", "techid", "techname", $mfrow["mftech"]); + if ($mfrow["lognoteid"] == 0) { + $mfnoteidval = " "; + $mfnotetag = "%s%s"; } else { - $mfnoteidval=$mfrow["lognoteid"]; - $mfnotetag="%s"; + $mfnoteidval = $mfrow["lognoteid"]; + $mfnotetag = "%s"; } printf( - " + " @@ -782,14 +806,16 @@ if ($search) { ", - $mfrow["maintformid"],$mfrow["maintformid"], - $mfrow["mfdate"], - $mftname, - $mfuid, - $mfpartno, - $mfserno, - $mfpartname, - $mfnoteidval,$mfnoteidval + $mfrow["maintformid"], + $mfrow["maintformid"], + $mfrow["mfdate"], + $mftname, + $mfuid, + $mfpartno, + $mfserno, + $mfpartname, + $mfnoteidval, + $mfnoteidval ); } echo "
%s %s %s%s $mfnotetag


"; @@ -797,11 +823,11 @@ if ($search) { echo "No Maintenance Forms match your search criteria.

"; } } - if ($target[0]=="") $target=[]; - if (in_array("part",$target)) { + if ($target[0] == "") $target = []; + if (in_array("part", $target)) { // run parts query and show results - $p_num_results=mysqli_num_rows($prowqry); - if($p_num_results) { + $p_num_results = mysqli_num_rows($prowqry); + if ($p_num_results) { echo " Results from Parts: $p_num_results

@@ -813,9 +839,10 @@ if ($search) { "; - while ($partrow=mysqli_fetch_assoc($prowqry)) { + while ($partrow = mysqli_fetch_assoc($prowqry)) { if ($loggedin) { - printf(" + printf( + " ", - $partrow['partid'], - $partrow['uid'], - $partrow['partnum'], - $partrow['sernum'], - $partrow['partname'] + $partrow['partid'], + $partrow['uid'], + $partrow['partnum'], + $partrow['sernum'], + $partrow['partname'] ); } else { - printf(" + printf( + " ", - $partrow['uid'], - $partrow['partnum'], - $partrow['sernum'], - $partrow['partname'] + $partrow['uid'], + $partrow['partnum'], + $partrow['sernum'], + $partrow['partname'] ); } echo " @@ -860,9 +888,7 @@ if ($search) { } banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/settings.php b/distfiles/settings.php index cebd1a0..7a3b616 100644 --- a/distfiles/settings.php +++ b/distfiles/settings.php @@ -11,55 +11,53 @@ $today = date("Y-m-d"); $now = date("H:i:s"); -$sttl=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"session_ttl_days\""))[0]; -$ostype=strtoupper(substr(php_uname('s'), 0, 3)); +$sttl = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"session_ttl_days\""))[0]; +$ostype = strtoupper(substr(php_uname('s'), 0, 3)); if ($ostype == 'WIN') { - $sdir=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"win_server_session_dir\""))[0]; + $sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"win_server_session_dir\""))[0]; } else { - $sdir=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"unix_server_session_dir\""))[0]; + $sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"unix_server_session_dir\""))[0]; } -$lifetime=60 * 60 * 24 * $sttl; +$lifetime = 60 * 60 * 24 * $sttl; if (!is_dir($sdir)) mkdir($sdir, 0700, true); ini_set('session.cookie_lifetime', $lifetime); ini_set('session.gc_maxlifetime', $lifetime); ini_set('session.save_path', $sdir); -$ss=session_status(); -if ($ss==PHP_SESSION_NONE) session_start(); +$ss = session_status(); +if ($ss == PHP_SESSION_NONE) session_start(); // get config options from database and assign them to constants unset($techid); if (isset($_SESSION['login']) && $_SESSION['login'] != '') { - $techid=$_SESSION['login']; + $techid = $_SESSION['login']; } -$configqry=mysqli_query($db,"select confname,confvalue,confid from configs"); +$configqry = mysqli_query($db, "select confname,confvalue,confid from configs"); while ($configrow = mysqli_fetch_assoc($configqry)) { - $constname=strtoupper($configrow["confname"]); + $constname = strtoupper($configrow["confname"]); if (isset($techid)) { - $confid=$configrow["confid"]; - $custqry=mysqli_query($db,"select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\""); + $confid = $configrow["confid"]; + $custqry = mysqli_query($db, "select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\""); if (mysqli_num_rows($custqry)) { - $custrow=mysqli_fetch_row($custqry); - $custval=$custrow[0]; + $custrow = mysqli_fetch_row($custqry); + $custval = $custrow[0]; } else { unset($custval); } } if (isset($custval)) { - $constvalue=$custval; + $constvalue = $custval; } else { - $constvalue=$configrow["confvalue"]; + $constvalue = $configrow["confvalue"]; } - define("$constname","$constvalue"); + define("$constname", "$constvalue"); } // error reporting -$logerrors=LOG_ERRORS; -if ($logerrors==1) { +$logerrors = LOG_ERRORS; +if ($logerrors == 1) { error_reporting(E_ALL); } else { error_reporting(0); } - -?> diff --git a/distfiles/templates.php b/distfiles/templates.php index 74a691c..8282715 100644 --- a/distfiles/templates.php +++ b/distfiles/templates.php @@ -10,72 +10,73 @@ include("functions.php"); if (!$_SESSION['login'] && !$_REQUEST['partview']) { - header ("Location: login.php"); + header("Location: login.php"); } -$techid=$_SESSION['login'] ?? NULL; -$isadmin=dblookup($db,"techs","techid","admin",$techid); -$print=$_REQUEST['print'] ?? NULL; -$efftechid=$_REQUEST['efftechid'] ?? NULL; -$shift=$_REQUEST['shift'] ?? NULL; -$subject=$_REQUEST['subject'] ?? NULL; -$note=$_REQUEST['note'] ?? NULL; -$flags=$_POST['flags'] ?? []; -$refstring=$_REQUEST['refstring'] ?? NULL; -$submit=$_REQUEST['submit'] ?? NULL; -$operation=$_REQUEST['operation'] ?? NULL; -$templateid=$_REQUEST['templateid'] ?? NULL; -$templatename=$_REQUEST['templatename'] ?? NULL; -$usertemplateid=$_REQUEST['usertemplateid'] ?? NULL; -$globaltemplateid=$_REQUEST['globaltemplateid'] ?? NULL; -$loadtemplate=$_REQUEST['loadtemplate'] ?? NULL; +$techid = $_SESSION['login'] ?? NULL; +$isadmin = dblookup($db, "techs", "techid", "admin", $techid); +$print = $_REQUEST['print'] ?? NULL; +$efftechid = $_REQUEST['efftechid'] ?? NULL; +$shift = $_REQUEST['shift'] ?? NULL; +$subject = $_REQUEST['subject'] ?? NULL; +$note = $_REQUEST['note'] ?? NULL; +$flags = $_POST['flags'] ?? []; +$refstring = $_REQUEST['refstring'] ?? NULL; +$submit = $_REQUEST['submit'] ?? NULL; +$operation = $_REQUEST['operation'] ?? NULL; +$templateid = $_REQUEST['templateid'] ?? NULL; +$templatename = $_REQUEST['templatename'] ?? NULL; +$usertemplateid = $_REQUEST['usertemplateid'] ?? NULL; +$globaltemplateid = $_REQUEST['globaltemplateid'] ?? NULL; +$loadtemplate = $_REQUEST['loadtemplate'] ?? NULL; -$logname=LOG_NAME; -$techalpha=TECH_ALPHA; -$subjalpha=SUBJ_ALPHA; +$logname = LOG_NAME; +$techalpha = TECH_ALPHA; +$subjalpha = SUBJ_ALPHA; -$defaultshift=dblookup($db,"techs","techid","shift",$techid); +$defaultshift = dblookup($db, "techs", "techid", "shift", $techid); -if ($print=="Printer Friendly") { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; +if ($print == "Printer Friendly") { + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname","Note Templates",$print); +framework("begin", "$logname", "Note Templates", $print); // make basic determination about authorization if ($isadmin) { - $authorized=TRUE; -} else if ($efftechid==$techid) { - $authorized=TRUE; + $authorized = TRUE; +} else if ($efftechid == $techid) { + $authorized = TRUE; } else { - $authorized=FALSE; + $authorized = FALSE; } // var_dump($_REQUEST); -function templatetable($db,$techid,$user) { +function templatetable($db, $techid, $user) +{ // Show template table - $isadmin=dblookup($db,"techs","techid","admin",$techid); - $templatequery=mysqli_query($db,"select * from notetemplates where tech=\"$user\" order by templatename asc"); - $tblusername=dblookup($db,"techs","techid","techname",$user); + $isadmin = dblookup($db, "techs", "techid", "admin", $techid); + $templatequery = mysqli_query($db, "select * from notetemplates where tech=\"$user\" order by templatename asc"); + $tblusername = dblookup($db, "techs", "techid", "techname", $user); if (mysqli_num_rows($templatequery)) { - $hastemplates=TRUE; + $hastemplates = TRUE; } else { - $hastemplates=FALSE; + $hastemplates = FALSE; } - + echo ""; if ($hastemplates) { // print the user header - if ($user=="0") { + if ($user == "0") { echo "Global Templates"; } else { - if ($user==$techid) { + if ($user == $techid) { echo "My templates"; } else { echo "Templates for $tblusername"; @@ -85,62 +86,62 @@ function templatetable($db,$techid,$user) { echo "
Part Name
\"Edit @@ -824,14 +851,15 @@ if ($search) { %s %s %s
\"You @@ -840,10 +868,10 @@ if ($search) { %s %s %s
"; echo ""; while ($tablerow = mysqli_fetch_assoc($templatequery)) { - $templateid=$tablerow["templateid"]; - $templatename=$tablerow["templatename"]; + $templateid = $tablerow["templateid"]; + $templatename = $tablerow["templatename"]; // convert shift number to name - $shiftname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]); + $shiftname = dblookup($db, "shifts", "shiftid", "shiftname", $tablerow["shift"]); // convert subject number to name - $subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]); + $subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]); // create links of urls in note - $fmtnote=convertweblinks($tablerow["lognote"]); + $fmtnote = convertweblinks($tablerow["lognote"]); // generate the flags string - $flagstring=""; - $flagqry=mysqli_query($db,"select flagid from flagmap where notetemplateid=$templateid"); - while ($flagid=mysqli_fetch_row($flagqry)) { - $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); - $flagcolor=$flagparams["flagcolor"]; - $flagsym=$flagparams["flagsym"]; - $flagname=$flagparams["flagname"]; - $flagstring=$flagstring."$flagsym  "; + $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 . "$flagsym  "; } if ($flagstring) { - $fmtnote=$fmtnote."
".$flagstring."     "; - } else { - $fmtnote=$fmtnote."
"; + $fmtnote = $fmtnote . "
" . $flagstring . "     "; + } else { + $fmtnote = $fmtnote . "
"; } // generate a reference string - $refstring=NULL; - $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); - while ($tgt=mysqli_fetch_row($refstringqry)) { - $refstring=$refstring." ".$tgt[0]; + $refstring = NULL; + $refstringqry = mysqli_query($db, "select target from reflinks where templateid=\"$templateid\""); + while ($tgt = mysqli_fetch_row($refstringqry)) { + $refstring = $refstring . " " . $tgt[0]; } // now print the line in the table - if (!$isadmin && $user=="0") { - $nameblock="$templatename"; + if (!$isadmin && $user == "0") { + $nameblock = "$templatename"; } else { - $nameblock="$templatename"; + $nameblock = "$templatename"; } printf( - " + "\n", - $nameblock, - $shiftname, - $subjname, - $fmtnote, - $refstring + $nameblock, + $shiftname, + $subjname, + $fmtnote, + $refstring ); }; echo "
Template NameShiftSubjectNoteReferences
%s %s %s %s %s



"; } else { - if ($user=="0") { + if ($user == "0") { echo "There are no global templates"; } else { - if ($user==$techid) { + if ($user == $techid) { echo "You have no templates"; } else { echo "$tblusername has no templates"; @@ -154,108 +155,108 @@ function templatetable($db,$techid,$user) { // ******** begin database manipulation ******** if ($usertemplateid) { - $templateid=$usertemplateid; + $templateid = $usertemplateid; } else if ($globaltemplateid) { - $templateid=$globaltemplateid; + $templateid = $globaltemplateid; } else { - $loadtemplate=NULL; + $loadtemplate = NULL; } -if ($operation=="add") { - if ($submit) { +if ($operation == "add") { + if ($submit) { if ($note) { // remove cruft from note text - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - + $note = strip_tags($note, ""); + $note = mysqli_real_escape_string($db, $note); + if ($authorized) { // check if name supplied if ($templatename) { - $namesupplied=TRUE; + $namesupplied = TRUE; // check if supplied name already exists - if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where tech=\"$efftechid\" and templatename=\"$templatename\""))) { + if (! mysqli_num_rows(mysqli_query($db, "select templateid from notetemplates where tech=\"$efftechid\" and templatename=\"$templatename\""))) { // add the record to notetemplates - mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote) values (\"$templatename\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")"); - $newtemplateid=mysqli_insert_id($db); - + mysqli_query($db, "insert into notetemplates(templatename,shift,tech,subject,lognote) values (\"$templatename\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")"); + $newtemplateid = mysqli_insert_id($db); + // update the flagmap table foreach ($flags as $thisflag) { // set flag for this note - mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$newtemplateid\")"); + mysqli_query($db, "insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$newtemplateid\")"); } - + // add references to the reflinks table if (strlen($refstring)) { - $refstring=trim($refstring); - $refarray=explode(" ",$refstring); + $refstring = trim($refstring); + $refarray = explode(" ", $refstring); foreach ($refarray as $target) { - mysqli_query($db,"insert into reflinks(templateid,target) values($newtemplateid,$target)"); + mysqli_query($db, "insert into reflinks(templateid,target) values($newtemplateid,$target)"); } } - $templateid=$newtemplateid; + $templateid = $newtemplateid; } else { - $nameexists=TRUE; + $nameexists = TRUE; } } else { - $namesupplied=FALSE; + $namesupplied = FALSE; } } } } } -if ($operation=="edit" || $operation=="delete") { +if ($operation == "edit" || $operation == "delete") { // test to see if this templateid is owned by techid to prevent hijacking - $owner=dblookup($db,"notetemplates","templateid","tech",$templateid); - if (!$isadmin && ($owner!=$techid)) $authorized=FALSE; - - if ($submit) { + $owner = dblookup($db, "notetemplates", "templateid", "tech", $templateid); + if (!$isadmin && ($owner != $techid)) $authorized = FALSE; + + if ($submit) { if ($note) { // remove cruft from note text - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - + $note = strip_tags($note, ""); + $note = mysqli_real_escape_string($db, $note); + if ($templatename) { - $namesupplied=TRUE; + $namesupplied = TRUE; } else { - $namesupplied=FALSE; + $namesupplied = FALSE; } - + if ($authorized) { // check if name was supplied if ($templatename) { // update notetemplates - mysqli_query($db,"update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\""); - + mysqli_query($db, "update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\""); + // update the flagmap table - mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\""); + mysqli_query($db, "delete from flagmap where notetemplateid=\"$templateid\""); foreach ($flags as $thisflag) { // set flag for this note - mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$templateid\")"); + mysqli_query($db, "insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$templateid\")"); } - + // update the reflinks table - mysqli_query($db,"delete from reflinks where templateid=\"$templateid\""); + mysqli_query($db, "delete from reflinks where templateid=\"$templateid\""); if (strlen($refstring)) { - $refstring=trim($refstring); - $refarray=explode(" ",$refstring); + $refstring = trim($refstring); + $refarray = explode(" ", $refstring); foreach ($refarray as $target) { - mysqli_query($db,"insert into reflinks(templateid,target) values($templateid,$target)"); + mysqli_query($db, "insert into reflinks(templateid,target) values($templateid,$target)"); } } } } } } - if ($operation=="delete") { + if ($operation == "delete") { if ($authorized) { // update notetemplates - mysqli_query($db,"delete from notetemplates where templateid=\"$templateid\""); + mysqli_query($db, "delete from notetemplates where templateid=\"$templateid\""); // update the flagmap table - mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\""); + mysqli_query($db, "delete from flagmap where notetemplateid=\"$templateid\""); // update the reflinks table - mysqli_query($db,"delete from reflinks where templateid=\"$templateid\""); - $templateid=NULL; - $note=NULL; + mysqli_query($db, "delete from reflinks where templateid=\"$templateid\""); + $templateid = NULL; + $note = NULL; } } } @@ -264,118 +265,118 @@ if ($operation=="edit" || $operation=="delete") { pagetable("begin"); if (!$print) { - pageblock("left","begin"); + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); -if ($submit || $operation=="delete") { +if ($submit || $operation == "delete") { // show success/failure messages - $nameexists=$nameexists ?? NULL; - $namesupplied=$namesupplied ?? NULL; - - if ($operation=="add") { - $addfail=FALSE; + $nameexists = $nameexists ?? NULL; + $namesupplied = $namesupplied ?? NULL; + + if ($operation == "add") { + $addfail = FALSE; if ($nameexists) { - format_message(1,"Template creation failed because the name you supplied already exists. Please try again."); - $addfail=TRUE; + format_message(1, "Template creation failed because the name you supplied already exists. Please try again."); + $addfail = TRUE; } if (!$namesupplied) { - format_message(1,"Template creation failed because you didn't supply a name. Please try again."); - $addfail=TRUE; + format_message(1, "Template creation failed because you didn't supply a name. Please try again."); + $addfail = TRUE; } if (!$note) { - format_message(1,"Template creation failed because you didn't enter any note text. Please try again."); - $addfail=TRUE; + format_message(1, "Template creation failed because you didn't enter any note text. Please try again."); + $addfail = TRUE; } if (!$authorized) { - format_message(1,"Template creation failed because you are not authorized to do so."); - $addfail=TRUE; + format_message(1, "Template creation failed because you are not authorized to do so."); + $addfail = TRUE; } - if (!$addfail) format_message(0,"Template created."); + if (!$addfail) format_message(0, "Template created."); } - if ($operation=="edit") { - $editfail=FALSE; + if ($operation == "edit") { + $editfail = FALSE; if (!$namesupplied) { - format_message(1,"Template save failed because you didn't supply a name. Please try again."); - $editfail=TRUE; + format_message(1, "Template save failed because you didn't supply a name. Please try again."); + $editfail = TRUE; } if (!$note) { - format_message(1,"Template save failed because you didn't enter any note text. Please try again."); - $editfail=TRUE; + format_message(1, "Template save failed because you didn't enter any note text. Please try again."); + $editfail = TRUE; } if (!$authorized) { - format_message(1,"Template save failed because you are not authorized to do so."); - $editfail=TRUE; + format_message(1, "Template save failed because you are not authorized to do so."); + $editfail = TRUE; } - if (!$editfail) format_message(0,"Template modified."); + if (!$editfail) format_message(0, "Template modified."); } - if ($operation=="delete") { - $deletefail=FALSE; + if ($operation == "delete") { + $deletefail = FALSE; if (!$authorized) { - format_message(1,"Template delete failed because you are not authorized to do so."); - $deletefail=TRUE; + format_message(1, "Template delete failed because you are not authorized to do so."); + $deletefail = TRUE; } - if (!$deletefail) format_message(0,"Template deleted."); + if (!$deletefail) format_message(0, "Template deleted."); } } -if ($operation=="delete") { +if ($operation == "delete") { // just show the link back to the templates page echo "
Manage templates



"; -} else if ($operation=="add" || $operation=="edit") { +} else if ($operation == "add" || $operation == "edit") { // Display the input form if ($loadtemplate) { // make templateid the selected template if ($usertemplateid) { - $templateid=$usertemplateid; + $templateid = $usertemplateid; } else if ($globaltemplateid) { - $templateid=$globaltemplateid; + $templateid = $globaltemplateid; } else { - $templateid=NULL; + $templateid = NULL; } } - if ($operation=="edit" || $loadtemplate) { + if ($operation == "edit" || $loadtemplate) { // use values from the templateid supplied with a defined tech id - $loadeddata=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\"")); - $filltemplatename=$loadeddata["templatename"]; + $loadeddata = mysqli_fetch_assoc(mysqli_query($db, "select * from notetemplates where templateid=\"$templateid\"")); + $filltemplatename = $loadeddata["templatename"]; if ($efftechid) { - $filltech=$efftechid; - } else if ($isadmin && $loadeddata["tech"]=="0") { - $filltech="0"; + $filltech = $efftechid; + } else if ($isadmin && $loadeddata["tech"] == "0") { + $filltech = "0"; } else { - $filltech=$techid; + $filltech = $techid; } - $fillshift=$loadeddata["shift"]; - $fillsubject=$loadeddata["subject"]; - $fillnote=$loadeddata["lognote"]; + $fillshift = $loadeddata["shift"]; + $fillsubject = $loadeddata["subject"]; + $fillnote = $loadeddata["lognote"]; } else { // use empty values with a defined tech id - $filltemplatename=NULL; + $filltemplatename = NULL; if ($efftechid) { - $filltech=$efftechid; + $filltech = $efftechid; } else { - $filltech=$techid; + $filltech = $techid; } - $fillshift=$defaultshift; - $fillsubject=NULL; - $fillnote=NULL; + $fillshift = $defaultshift; + $fillsubject = NULL; + $fillnote = NULL; } - - if ($operation=="add") $optext="Creating new"; - if ($operation=="edit") $optext="Editing"; + + if ($operation == "add") $optext = "Creating new"; + if ($operation == "edit") $optext = "Editing"; echo "
$optext template

"; - + // show the template selection line - templateselect($techid,$operation); - + templateselect($techid, $operation); + // start template entry section echo " @@ -388,25 +389,26 @@ if ($operation=="delete") {
Tech:  
Shift:   Subject:  
@@ -454,50 +457,60 @@ if ($operation=="delete") {   Insert Link
"; - + // create an array called theseflags and optionally load it with flagids set for this template unset($theseflags); - $theseflags=[]; + $theseflags = []; if ($templateid) { - $allflags=mysqli_query($db,"select flagid from flags"); - while ($thisflag=mysqli_fetch_row($allflags)) { - if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) { - $theseflags[]=$thisflag[0]; + $allflags = mysqli_query($db, "select flagid from flags"); + while ($thisflag = mysqli_fetch_row($allflags)) { + if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) { + $theseflags[] = $thisflag[0]; } } } - - $flagslist=mysqli_query($db,"select * from flags where status=1"); - $flagsperline=8; - $flagcount=1; - + + $flagslist = mysqli_query($db, "select * from flags where status=1"); + $flagsperline = 8; + $flagcount = 1; + // display checkboxes for all the flags, selecting the ones that are set for this template - while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { - if ($operation=="edit" && in_array($flagcheckbox["flagid"],$theseflags)) { - printf("%s", - $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { + if ($operation == "edit" && in_array($flagcheckbox["flagid"], $theseflags)) { + printf( + "%s", + $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("%s", - $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( + "%s", + $flagcheckbox["flagid"], + $flagcheckbox["flagcolor"], + $flagcheckbox["flagname"], + $flagcheckbox["flagsym"] + ); } } - if ($flagcount<$flagsperline) { + if ($flagcount < $flagsperline) { echo "   "; $flagcount++; } else { echo "
"; - $flagcount=1; + $flagcount = 1; } } - - if ($operation=="edit" || $loadtemplate) { + + if ($operation == "edit" || $loadtemplate) { // generate a reference string - $refstring=NULL; - $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); - while ($tgt=mysqli_fetch_row($refstringqry)) { - $refstring=$refstring." ".$tgt[0]; + $refstring = NULL; + $refstringqry = mysqli_query($db, "select target from reflinks where templateid=\"$templateid\""); + while ($tgt = mysqli_fetch_row($refstringqry)) { + $refstring = $refstring . " " . $tgt[0]; } } echo " @@ -505,14 +518,14 @@ if ($operation=="delete") {                                "; - - if ($operation=="add" && $authorized) { + + if ($operation == "add" && $authorized) { echo " "; } - if ($operation=="edit" && $authorized) { + if ($operation == "edit" && $authorized) { echo " @@ -521,34 +534,32 @@ if ($operation=="delete") { Deleted templates are irretrievable! "; } - + echo "
"; } else { echo "
Create or copy a template

"; - + // Show my user template table - templatetable($db,$techid,$techid); - + templatetable($db, $techid, $techid); + // Show global template table - templatetable($db,$techid,"0"); - + templatetable($db, $techid, "0"); + if ($isadmin) { // Show template tables for other users - $techqry=mysqli_query($db,"select techid from techs where techid != $techid and techid != 0"); - while ($techtblrow=(mysqli_fetch_row($techqry))) { - templatetable($db,$techid,$techtblrow[0]); + $techqry = mysqli_query($db, "select techid from techs where techid != $techid and techid != 0"); + while ($techtblrow = (mysqli_fetch_row($techqry))) { + templatetable($db, $techid, $techtblrow[0]); } } } banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/install.sh b/install.sh index 1fdde6a..afc16d3 100755 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ # install.sh # OpenLog Online Logbook -# Copyright (C) 2025 Rod Wright +# Copyright (C) 2026 Rod Wright # SPDX-License-Identifier: GPL-2.0