mirror of
https://github.com/itflow-org/itflow
synced 2026-03-11 00:04:50 +00:00
Finished Adding Assigning Licenses to Device or Users under software
This commit is contained in:
@@ -93,8 +93,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
while($row = mysqli_fetch_array($sql)){
|
while($row = mysqli_fetch_array($sql)){
|
||||||
$software_id = $row['software_id'];
|
$software_id = $row['software_id'];
|
||||||
$software_name = $row['software_name'];
|
$software_name = $row['software_name'];
|
||||||
$software_version = $row['software_version'];
|
$software_version = $row['software_version'];
|
||||||
@@ -106,6 +106,27 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||||||
$software_expire = $row['software_expire'];
|
$software_expire = $row['software_expire'];
|
||||||
$software_notes = $row['software_notes'];
|
$software_notes = $row['software_notes'];
|
||||||
|
|
||||||
|
$seat_count = 0;
|
||||||
|
|
||||||
|
// Asset Licenses
|
||||||
|
$asset_licenses_sql = mysqli_query($mysqli,"SELECT asset_id FROM software_assets WHERE software_id = $software_id");
|
||||||
|
$asset_licenses_array = array();
|
||||||
|
while($row = mysqli_fetch_array($asset_licenses_sql)){
|
||||||
|
$asset_licenses_array[] = $row['asset_id'];
|
||||||
|
$seat_count = $seat_count + 1;
|
||||||
|
}
|
||||||
|
$asset_licenses = implode(',',$asset_licenses_array);
|
||||||
|
|
||||||
|
// Contact Licenses
|
||||||
|
$contact_licenses_sql = mysqli_query($mysqli,"SELECT contact_id FROM software_contacts WHERE software_id = $software_id");
|
||||||
|
$contact_licenses_array = array();
|
||||||
|
while($row = mysqli_fetch_array($contact_licenses_sql)){
|
||||||
|
$contact_licenses_array[] = $row['contact_id'];
|
||||||
|
$seat_count = $seat_count + 1;
|
||||||
|
}
|
||||||
|
$contact_licenses = implode(',',$contact_licenses_array);
|
||||||
|
|
||||||
|
// Get Login
|
||||||
$login_id = $row['login_id'];
|
$login_id = $row['login_id'];
|
||||||
$login_username = $row['login_username'];
|
$login_username = $row['login_username'];
|
||||||
$login_password = decryptLoginEntry($row['login_password']);
|
$login_password = decryptLoginEntry($row['login_password']);
|
||||||
@@ -115,7 +136,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||||||
<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><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_type; ?></td>
|
||||||
<td><?php echo $software_license_type; ?></td>
|
<td><?php echo $software_license_type; ?></td>
|
||||||
<td><?php echo $software_seats; ?></td>
|
<td><?php echo "$seat_count / $software_seats"; ?></td>
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
if($login_id > 0){
|
if($login_id > 0){
|
||||||
@@ -155,6 +176,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -15,6 +15,12 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" data-toggle="pill" href="#pills-details">Details</a>
|
<a class="nav-link active" data-toggle="pill" href="#pills-details">Details</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="pill" href="#pills-device-licenses">Device Licenses</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="pill" href="#pills-user-licenses">User Licenses</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-toggle="pill" href="#pills-notes">Notes</a>
|
<a class="nav-link" data-toggle="pill" href="#pills-notes">Notes</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -63,14 +69,19 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>License Type</label>
|
<label>License Type</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-cube"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-cube"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-control" name="license_type" placeholder="License type">
|
<select class="form-control select2" name="license_type">
|
||||||
|
<option value="">- Select a License Type -</option>
|
||||||
|
<?php foreach($license_types_array as $license_type) { ?>
|
||||||
|
<option><?php echo $license_type; ?></option>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -116,6 +127,69 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane fade" id="pills-device-licenses">
|
||||||
|
|
||||||
|
<div class="alert alert-info">
|
||||||
|
Select Assets that are licensed for this software
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="list-group">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$sql = mysqli_query($mysqli,"SELECT * FROM assets WHERE asset_client_id = $client_id ORDER BY asset_name ASC");
|
||||||
|
|
||||||
|
while($row = mysqli_fetch_array($sql)){
|
||||||
|
$asset_id = $row['asset_id'];
|
||||||
|
$asset_name = $row['asset_name'];
|
||||||
|
|
||||||
|
?>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" name="assets[]" value="<?php echo $asset_id; ?>">
|
||||||
|
<label class="form-check-label ml-2"><?php echo $asset_name; ?></label>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane fade" id="pills-user-licenses">
|
||||||
|
|
||||||
|
<div class="alert alert-info">
|
||||||
|
Select Users that are licensed for this software
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="list-group">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$sql = mysqli_query($mysqli,"SELECT * FROM contacts WHERE contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||||
|
|
||||||
|
while($row = mysqli_fetch_array($sql)){
|
||||||
|
$contact_id = $row['contact_id'];
|
||||||
|
$contact_name = $row['contact_name'];
|
||||||
|
$contact_email = $row['contact_email'];
|
||||||
|
|
||||||
|
?>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" name="contacts[]" value="<?php echo $contact_id; ?>">
|
||||||
|
<label class="form-check-label ml-2"><?php echo "$contact_name - $contact_email"; ?></label>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="tab-pane fade" id="pills-notes">
|
<div class="tab-pane fade" id="pills-notes">
|
||||||
|
|
||||||
<textarea class="form-control" rows="8" placeholder="Enter some notes" name="notes"></textarea>
|
<textarea class="form-control" rows="8" placeholder="Enter some notes" name="notes"></textarea>
|
||||||
|
|||||||
@@ -16,6 +16,12 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" data-toggle="pill" href="#pills-details<?php echo $software_id; ?>">Details</a>
|
<a class="nav-link active" data-toggle="pill" href="#pills-details<?php echo $software_id; ?>">Details</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="pill" href="#pills-device-licenses<?php echo $software_id; ?>">Device Licenses</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="pill" href="#pills-user-licenses<?php echo $software_id; ?>">User Licenses</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-toggle="pill" href="#pills-notes<?php echo $software_id; ?>">Notes</a>
|
<a class="nav-link" data-toggle="pill" href="#pills-notes<?php echo $software_id; ?>">Notes</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -70,7 +76,12 @@
|
|||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-cube"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-cube"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-control" name="license_type" placeholder="License type" value="<?php echo $software_license_type; ?>">
|
<select class="form-control select2" name="license_type">
|
||||||
|
<option value="">- Select a License Type -</option>
|
||||||
|
<?php foreach($license_types_array as $license_type_select) { ?>
|
||||||
|
<option <?php if($license_type_select == $software_license_type){ echo "selected"; } ?>><?php echo $license_type_select; ?></option>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -116,6 +127,69 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane fade" id="pills-device-licenses<?php echo $software_id; ?>">
|
||||||
|
|
||||||
|
<div class="alert alert-info">
|
||||||
|
Select Assets that are licensed for this software
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="list-group">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$sql_assets_select = mysqli_query($mysqli,"SELECT * FROM assets WHERE asset_client_id = $client_id ORDER BY asset_name ASC");
|
||||||
|
|
||||||
|
while($row = mysqli_fetch_array($sql_assets_select)){
|
||||||
|
$asset_id_select = $row['asset_id'];
|
||||||
|
$asset_name_select = $row['asset_name'];
|
||||||
|
|
||||||
|
?>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" name="assets[]" value="<?php echo $asset_id_select; ?>" <?php if(in_array($asset_id_select,$asset_licenses_array)){ echo "checked"; } ?>>
|
||||||
|
<label class="form-check-label ml-2"><?php echo $asset_name_select; ?></label>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane fade" id="pills-user-licenses<?php echo $software_id; ?>">
|
||||||
|
|
||||||
|
<div class="alert alert-info">
|
||||||
|
Select Users that are licensed for this software
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="list-group">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$sql_contacts_select = mysqli_query($mysqli,"SELECT * FROM contacts WHERE contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||||
|
|
||||||
|
while($row = mysqli_fetch_array($sql_contacts_select)){
|
||||||
|
$contact_id_select = $row['contact_id'];
|
||||||
|
$contact_name_select = $row['contact_name'];
|
||||||
|
$contact_email_select = $row['contact_email'];
|
||||||
|
|
||||||
|
?>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" name="contacts[]" value="<?php echo $contact_id_select; ?>" <?php if(in_array("$contact_id_select",$contact_licenses_array)){ echo "checked"; } ?>>
|
||||||
|
<label class="form-check-label ml-2"><?php echo "$contact_name_select - $contact_email_select"; ?></label>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="tab-pane fade" id="pills-notes<?php echo $software_id; ?>">
|
<div class="tab-pane fade" id="pills-notes<?php echo $software_id; ?>">
|
||||||
|
|
||||||
<textarea class="form-control" rows="8" placeholder="Enter some notes" name="notes"><?php echo $software_notes; ?></textarea>
|
<textarea class="form-control" rows="8" placeholder="Enter some notes" name="notes"><?php echo $software_notes; ?></textarea>
|
||||||
|
|||||||
@@ -887,4 +887,9 @@ $software_types_array = array(
|
|||||||
'Other'
|
'Other'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$license_types_array = array(
|
||||||
|
'Device',
|
||||||
|
'User'
|
||||||
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
35
post.php
35
post.php
@@ -4665,6 +4665,22 @@ if(isset($_POST['add_software'])){
|
|||||||
|
|
||||||
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");
|
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");
|
||||||
|
|
||||||
|
// Add Asset Licenses
|
||||||
|
if(!empty($_POST['assets'])){
|
||||||
|
foreach($_POST['assets'] as $asset){
|
||||||
|
intval($asset);
|
||||||
|
mysqli_query($mysqli,"INSERT INTO software_assets SET software_id = $software_id, asset_id = $asset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add Contact Licenses
|
||||||
|
if(!empty($_POST['contacts'])){
|
||||||
|
foreach($_POST['contacts'] as $contact){
|
||||||
|
intval($contact);
|
||||||
|
mysqli_query($mysqli,"INSERT INTO software_contacts SET software_id = $software_id, contact_id = $contact");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!empty($_POST['username'])) {
|
if(!empty($_POST['username'])) {
|
||||||
$software_id = mysqli_insert_id($mysqli);
|
$software_id = mysqli_insert_id($mysqli);
|
||||||
$username = strip_tags(mysqli_real_escape_string($mysqli,$_POST['username']));
|
$username = strip_tags(mysqli_real_escape_string($mysqli,$_POST['username']));
|
||||||
@@ -4707,6 +4723,25 @@ if(isset($_POST['edit_software'])){
|
|||||||
|
|
||||||
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");
|
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");
|
||||||
|
|
||||||
|
|
||||||
|
// Update Asset Licenses
|
||||||
|
mysqli_query($mysqli,"DELETE FROM software_assets WHERE software_id = $software_id");
|
||||||
|
if(!empty($_POST['assets'])){
|
||||||
|
foreach($_POST['assets'] as $asset){
|
||||||
|
intval($asset);
|
||||||
|
mysqli_query($mysqli,"INSERT INTO software_assets SET software_id = $software_id, asset_id = $asset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Contact Licenses
|
||||||
|
mysqli_query($mysqli,"DELETE FROM software_contacts WHERE software_id = $software_id");
|
||||||
|
if(!empty($_POST['contacts'])){
|
||||||
|
foreach($_POST['contacts'] as $contact){
|
||||||
|
intval($contact);
|
||||||
|
mysqli_query($mysqli,"INSERT INTO software_contacts SET software_id = $software_id, contact_id = $contact");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//If login exists then update the login
|
//If login exists then update the login
|
||||||
if($login_id > 0){
|
if($login_id > 0){
|
||||||
mysqli_query($mysqli,"UPDATE logins SET login_name = '$name', login_username = '$username', login_password = '$password', login_updated_at = NOW() WHERE login_id = $login_id AND company_id = $session_company_id");
|
mysqli_query($mysqli,"UPDATE logins SET login_name = '$name', login_username = '$username', login_password = '$password', login_updated_at = NOW() WHERE login_id = $login_id AND company_id = $session_company_id");
|
||||||
|
|||||||
Reference in New Issue
Block a user