Add Software Licnee Version and License Type as well as the beginnings to assign licneses to devices and or users

This commit is contained in:
johnnyq
2022-02-18 00:27:00 -05:00
parent a96d43a017
commit 0aec371ccd
6 changed files with 110 additions and 31 deletions

View File

@@ -1,13 +1,13 @@
<?php
if(!isset($_SESSION)){
// HTTP Only cookies
ini_set("session.cookie_httponly", True);
if($config_https_only){
// Tell client to only send cookie(s) over HTTPS
ini_set("session.cookie_secure", True);
}
session_start();
// HTTP Only cookies
ini_set("session.cookie_httponly", True);
if($config_https_only){
// Tell client to only send cookie(s) over HTTPS
ini_set("session.cookie_secure", True);
}
session_start();
}
//Check to see if setup is enabled
@@ -21,12 +21,13 @@
die;
}
//SESSION FINGERPRINT
// SESSION FINGERPRINT
$session_ip = strip_tags(mysqli_real_escape_string($mysqli,get_ip()));
$session_os = strip_tags(mysqli_real_escape_string($mysqli,get_os()));
//$session_browser = strip_tags(mysqli_real_escape_string($mysqli,get_web_browser()));
//$session_device = strip_tags(mysqli_real_escape_string($mysqli,get_device()));
//$session_user_agent = "$session_os - $session_browser";
// Get user agent
$session_user_agent = strip_tags(mysqli_real_escape_string($mysqli,$_SERVER['HTTP_USER_AGENT']));
@@ -73,9 +74,9 @@
include("get_settings.php");
//Detects if using an apple device and uses apple maps instead of google
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
if($iPod || $iPhone || $iPad){
$session_map_source = "apple";

View File

@@ -96,7 +96,9 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
while($row = mysqli_fetch_array($sql)){
$software_id = $row['software_id'];
$software_name = $row['software_name'];
$software_version = $row['software_version'];
$software_type = $row['software_type'];
$software_license_type = $row['software_license_type'];
$software_license = $row['software_license'];
if(empty($software_license)){
$software_license_display = "-";

View File

@@ -38,6 +38,16 @@
<input type="text" class="form-control" name="name" placeholder="Software name" required autofocus>
</div>
</div>
<div class="form-group">
<label>Version</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-cube"></i></span>
</div>
<input type="text" class="form-control" name="version" placeholder="Software version">
</div>
</div>
<div class="form-group">
<label>Type <strong class="text-danger">*</strong></label>
@@ -54,6 +64,16 @@
</div>
</div>
<div class="form-group">
<label>License Type</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-cube"></i></span>
</div>
<input type="text" class="form-control" name="license_type" placeholder="License type">
</div>
</div>
<div class="form-group">
<label>License</label>
<div class="input-group">

View File

@@ -39,6 +39,16 @@
<input type="text" class="form-control" name="name" placeholder="Software name" value="<?php echo $software_name; ?>" required>
</div>
</div>
<div class="form-group">
<label>Version</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-cube"></i></span>
</div>
<input type="text" class="form-control" name="version" placeholder="Software version" value="<?php echo $software_version; ?>">
</div>
</div>
<div class="form-group">
<label>Type <strong class="text-danger">*</strong></label>
@@ -53,6 +63,16 @@
</select>
</div>
</div>
<div class="form-group">
<label>License Type</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-cube"></i></span>
</div>
<input type="text" class="form-control" name="license_type" placeholder="License type" value="<?php echo $software_license_type; ?>">
</div>
</div>
<div class="form-group">
<label>License</label>
@@ -60,7 +80,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-key"></i></span>
</div>
<input type="text" class="form-control" name="license" placeholder="License key" value="<?php echo $software_license; ?>" required>
<input type="text" class="form-control" name="license" placeholder="License key" value="<?php echo $software_license; ?>">
</div>
</div>

66
db.sql
View File

@@ -1,8 +1,8 @@
-- MariaDB dump 10.19 Distrib 10.5.13-MariaDB, for debian-linux-gnu (x86_64)
-- MariaDB dump 10.19 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: pittpc_crm
-- ------------------------------------------------------
-- Server version 10.5.13-MariaDB-1:10.5.13+maria~focal
-- Server version 10.5.15-MariaDB-1:10.5.15+maria~focal
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -412,6 +412,7 @@ CREATE TABLE `documents` (
`document_created_at` datetime NOT NULL,
`document_updated_at` datetime DEFAULT NULL,
`document_archived_at` datetime DEFAULT NULL,
`document_folder_id` int(11) DEFAULT NULL,
`document_client_id` int(11) NOT NULL,
`company_id` int(11) NOT NULL,
PRIMARY KEY (`document_id`)
@@ -529,6 +530,21 @@ CREATE TABLE `files` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `folders`
--
DROP TABLE IF EXISTS `folders`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `folders` (
`folder_id` int(11) NOT NULL AUTO_INCREMENT,
`folder_name` varchar(200) NOT NULL,
`company_id` int(11) NOT NULL,
PRIMARY KEY (`folder_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `history`
--
@@ -1087,7 +1103,9 @@ DROP TABLE IF EXISTS `software`;
CREATE TABLE `software` (
`software_id` int(11) NOT NULL AUTO_INCREMENT,
`software_name` varchar(200) NOT NULL,
`software_version` varchar(200) DEFAULT NULL,
`software_type` varchar(200) NOT NULL,
`software_license_type` varchar(200) DEFAULT NULL,
`software_license` varchar(200) DEFAULT NULL,
`software_notes` text DEFAULT NULL,
`software_created_at` datetime NOT NULL,
@@ -1100,6 +1118,34 @@ CREATE TABLE `software` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `software_assets`
--
DROP TABLE IF EXISTS `software_assets`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `software_assets` (
`software_id` int(11) NOT NULL,
`asset_id` int(11) NOT NULL,
PRIMARY KEY (`software_id`,`asset_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `software_contacts`
--
DROP TABLE IF EXISTS `software_contacts`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `software_contacts` (
`software_id` int(11) NOT NULL,
`contact_id` int(11) NOT NULL,
PRIMARY KEY (`software_id`,`contact_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tags`
--
@@ -1241,20 +1287,6 @@ CREATE TABLE `trips` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `user_clients`
--
DROP TABLE IF EXISTS `user_clients`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_clients` (
`user_id` int(11) NOT NULL,
`client_id` int(11) NOT NULL,
PRIMARY KEY (`user_id`,`client_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `user_companies`
--
@@ -1366,4 +1398,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2022-02-05 16:40:40
-- Dump completed on 2022-02-18 0:26:14

View File

@@ -4599,11 +4599,13 @@ if(isset($_POST['add_software'])){
$client_id = intval($_POST['client_id']);
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
$version = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['version'])));
$type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])));
$license = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['license'])));
$license_type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['license_type'])));
$notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])));
mysqli_query($mysqli,"INSERT INTO software SET software_name = '$name', software_type = '$type', software_license = '$license', software_notes = '$notes', software_created_at = NOW(), software_client_id = $client_id, company_id = $session_company_id");
mysqli_query($mysqli,"INSERT INTO software SET software_name = '$name', software_version = '$version', software_type = '$type', software_license = '$license', software_license_type = '$license_type', software_notes = '$notes', software_created_at = NOW(), software_client_id = $client_id, company_id = $session_company_id");
if(!empty($_POST['username'])) {
$software_id = mysqli_insert_id($mysqli);
@@ -4628,13 +4630,15 @@ if(isset($_POST['edit_software'])){
$software_id = intval($_POST['software_id']);
$login_id = intval($_POST['login_id']);
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
$version = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['version'])));
$type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])));
$license = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['license'])));
$license_type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['license_type'])));
$notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])));
$username = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['username'])));
$password = trim(mysqli_real_escape_string($mysqli,encryptLoginEntry($_POST['password'])));
mysqli_query($mysqli,"UPDATE software SET software_name = '$name', software_type = '$type', software_license = '$license', software_notes = '$notes', software_updated_at = NOW() WHERE software_id = $software_id AND company_id = $session_company_id");
mysqli_query($mysqli,"UPDATE software SET software_name = '$name', software_version = '$version', software_type = '$type', software_license = '$license', software_license_type = '$license_type', software_notes = '$notes', software_updated_at = NOW() WHERE software_id = $software_id AND company_id = $session_company_id");
//If login exists then update the login
if($login_id > 0){