Added Seats Expire and Purchase dates to Software

This commit is contained in:
johnnyq 2022-02-18 01:09:16 -05:00
parent 0aec371ccd
commit ab973457b9
5 changed files with 101 additions and 20 deletions

View File

@ -41,7 +41,7 @@ $url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM software LEFT JOIN logins ON login_software_id = software_id
WHERE software_client_id = $client_id
AND (software_name LIKE '%$q%' OR software_type LIKE '%$q%' OR software_license LIKE '%$q%')
AND (software_name LIKE '%$q%' OR software_type LIKE '%$q%' OR software_key LIKE '%$q%')
ORDER BY $sb $o LIMIT $record_from, $record_to");
$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
@ -85,7 +85,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
<tr>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=software_name&o=<?php echo $disp; ?>">Software</a></th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=software_type&o=<?php echo $disp; ?>">Type</a></th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=software_license&o=<?php echo $disp; ?>">License</a></th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=software_license_type&o=<?php echo $disp; ?>">License Type</a></th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=software_seats&o=<?php echo $disp; ?>">Seats</a></th>
<th></th>
<th class="text-center">Action</th>
</tr>
@ -99,12 +100,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
$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 = "-";
}else{
$software_license_display = $software_license;
}
$software_key = $row['software_key'];
$software_seats = $row['software_seats'];
$software_purchase = $row['software_purchase'];
$software_expire = $row['software_expire'];
$software_notes = $row['software_notes'];
$login_id = $row['login_id'];
@ -113,9 +112,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
?>
<tr>
<td><a class="text-dark" href="#" data-toggle="modal" data-target="#editSoftwareModal<?php echo $software_id; ?>"><?php echo $software_name; ?></a></td>
<td><a class="text-dark" href="#" data-toggle="modal" data-target="#editSoftwareModal<?php echo $software_id; ?>"><?php echo "$software_name<br><span class='text-secondary'>$software_version</span>"; ?></a></td>
<td><?php echo $software_type; ?></td>
<td><?php echo $software_license_display; ?></td>
<td><?php echo $software_license_type; ?></td>
<td><?php echo $software_seats; ?></td>
<td>
<?php
if($login_id > 0){

View File

@ -75,12 +75,42 @@
</div>
<div class="form-group">
<label>License</label>
<label>Seats</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="number" class="form-control" name="seats" placeholder="Number of seats">
</div>
</div>
<div class="form-group">
<label>License Key</label>
<div class="input-group">
<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">
<input type="text" class="form-control" name="key" placeholder="License key">
</div>
</div>
<div class="form-group">
<label>Purchase Date</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="date" class="form-control" name="purchase">
</div>
</div>
<div class="form-group">
<label>Expire</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="date" class="form-control" name="expire">
</div>
</div>

View File

@ -73,14 +73,44 @@
<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>Seats</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="number" class="form-control" name="seats" placeholder="Number of seats" value="<?php echo $software_seats; ?>">
</div>
</div>
<div class="form-group">
<label>License</label>
<label>License Key</label>
<div class="input-group">
<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; ?>">
<input type="text" class="form-control" name="key" placeholder="License key" value="<?php echo $software_key; ?>">
</div>
</div>
<div class="form-group">
<label>Purchase Date</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="date" class="form-control" name="purchase" value="<?php echo $software_purchase; ?>">
</div>
</div>
<div class="form-group">
<label>Expire</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="date" class="form-control" name="expire" value="<?php echo $software_expire; ?>">
</div>
</div>

7
db.sql
View File

@ -1106,7 +1106,10 @@ CREATE TABLE `software` (
`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_key` varchar(200) DEFAULT NULL,
`software_seats` int(11) DEFAULT NULL,
`software_purchase` date DEFAULT NULL,
`software_expire` date DEFAULT NULL,
`software_notes` text DEFAULT NULL,
`software_created_at` datetime NOT NULL,
`software_updated_at` datetime DEFAULT NULL,
@ -1398,4 +1401,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2022-02-18 0:26:14
-- Dump completed on 2022-02-18 1:08:36

View File

@ -4601,11 +4601,20 @@ if(isset($_POST['add_software'])){
$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'])));
$key = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['key'])));
$license_type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['license_type'])));
$seats = intval($_POST['seats']);
$purchase = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['purchase'])));
if(empty($purchase)){
$purchase = "0000-00-00";
}
$expire = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire'])));
if(empty($expire)){
$expire = "0000-00-00";
}
$notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])));
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");
mysqli_query($mysqli,"INSERT INTO software SET software_name = '$name', software_version = '$version', software_type = '$type', software_key = '$key', software_license_type = '$license_type', software_seats = '$seats', software_purchase = '$purchase', software_expire = '$expire', 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);
@ -4632,13 +4641,22 @@ if(isset($_POST['edit_software'])){
$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'])));
$key = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['key'])));
$license_type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['license_type'])));
$seats = intval($_POST['seats']);
$purchase = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['purchase'])));
if(empty($purchase)){
$purchase = "0000-00-00";
}
$expire = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire'])));
if(empty($expire)){
$expire = "0000-00-00";
}
$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_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");
mysqli_query($mysqli,"UPDATE software SET software_name = '$name', software_version = '$version', software_type = '$type', software_key = '$key', software_license_type = '$license_type', software_seats = $seats, software_purchase = '$purchase', software_expire = '$expire', 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){