Start using the new modal when creating tickets. This allows us to select both the client and contact, along with a client-specific asset, location and vendor
This commit is contained in:
73
ajax.php
73
ajax.php
@@ -329,6 +329,79 @@ if (isset($_GET['get_client_contacts'])) {
|
|||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns ordered list of active assets for a specified client
|
||||||
|
*/
|
||||||
|
if (isset($_GET['get_client_assets'])) {
|
||||||
|
enforceUserPermission('module_client');
|
||||||
|
|
||||||
|
$client_id = intval($_GET['client_id']);
|
||||||
|
|
||||||
|
$asset_sql = mysqli_query(
|
||||||
|
$mysqli,
|
||||||
|
"SELECT asset_id, asset_name, contact_name FROM assets
|
||||||
|
LEFT JOIN clients on asset_client_id = client_id
|
||||||
|
LEFT JOIN contacts ON contact_id = asset_contact_id
|
||||||
|
WHERE assets.asset_archived_at IS NULL AND asset_client_id = $client_id
|
||||||
|
$access_permission_query
|
||||||
|
ORDER BY asset_important DESC, asset_name"
|
||||||
|
);
|
||||||
|
|
||||||
|
while ($row = mysqli_fetch_array($asset_sql)) {
|
||||||
|
$response['assets'][] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns locations for a specified client
|
||||||
|
*/
|
||||||
|
if (isset($_GET['get_client_locations'])) {
|
||||||
|
enforceUserPermission('module_client');
|
||||||
|
|
||||||
|
$client_id = intval($_GET['client_id']);
|
||||||
|
|
||||||
|
$locations_sql = mysqli_query(
|
||||||
|
$mysqli,
|
||||||
|
"SELECT location_id, location_name FROM locations
|
||||||
|
LEFT JOIN clients on location_client_id = client_id
|
||||||
|
WHERE locations.location_archived_at IS NULL AND location_client_id = $client_id
|
||||||
|
$access_permission_query
|
||||||
|
ORDER BY location_primary DESC, location_name ASC"
|
||||||
|
);
|
||||||
|
|
||||||
|
while ($row = mysqli_fetch_array($locations_sql)) {
|
||||||
|
$response['locations'][] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns ordered list of vendors for a specified client
|
||||||
|
*/
|
||||||
|
if (isset($_GET['get_client_vendors'])) {
|
||||||
|
enforceUserPermission('module_client');
|
||||||
|
|
||||||
|
$client_id = intval($_GET['client_id']);
|
||||||
|
|
||||||
|
$vendors_sql = mysqli_query(
|
||||||
|
$mysqli,
|
||||||
|
"SELECT vendor_id, vendor_name FROM vendors
|
||||||
|
LEFT JOIN clients on vendor_client_id = client_id
|
||||||
|
WHERE vendors.vendor_archived_at IS NULL AND vendor_client_id = $client_id
|
||||||
|
$access_permission_query
|
||||||
|
ORDER BY vendor_name ASC"
|
||||||
|
);
|
||||||
|
|
||||||
|
while ($row = mysqli_fetch_array($vendors_sql)) {
|
||||||
|
$response['vendors'][] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($response);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NEW TOTP getter for client login/passwords page
|
* NEW TOTP getter for client login/passwords page
|
||||||
* When provided with a login ID, checks permissions and returns the 6-digit code
|
* When provided with a login ID, checks permissions and returns the 6-digit code
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
// Client selected listener
|
|
||||||
// We seem to have to use jQuery to listen for events, as the client input is a select2 component?
|
|
||||||
|
|
||||||
const clientSelectDropdown = document.getElementById("changeClientSelect"); // Define client selector
|
|
||||||
|
|
||||||
// // If the client selector is disabled, we must be on client_recurring_tickets.php instead. Trigger the contact list update.
|
|
||||||
if (clientSelectDropdown.disabled) {
|
|
||||||
|
|
||||||
let client_id = $(clientSelectDropdown).find(':selected').val();
|
|
||||||
|
|
||||||
// Update the contacts dropdown list
|
|
||||||
populateContactsDropdown(client_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Listener for client selection. Populate contact select when a client is selected
|
|
||||||
$(clientSelectDropdown).on('select2:select', function (e) {
|
|
||||||
let client_id = $(this).find(':selected').val();
|
|
||||||
|
|
||||||
// Update the contacts dropdown list
|
|
||||||
populateContactsDropdown(client_id);
|
|
||||||
|
|
||||||
// TODO: Update the assets dropdown list
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Populate client contact function (after a client is selected)
|
|
||||||
function populateContactsDropdown(client_id) {
|
|
||||||
// Send a GET request to ajax.php as ajax.php?get_client_contacts=true&client_id=NUM
|
|
||||||
jQuery.get(
|
|
||||||
"ajax.php",
|
|
||||||
{get_client_contacts: 'true', client_id: client_id},
|
|
||||||
function(data) {
|
|
||||||
|
|
||||||
// If we get a response from ajax.php, parse it as JSON
|
|
||||||
const response = JSON.parse(data);
|
|
||||||
|
|
||||||
// Access the data for contacts (multiple)
|
|
||||||
const contacts = response.contacts;
|
|
||||||
|
|
||||||
// Contacts dropdown
|
|
||||||
const contactSelectDropdown = document.getElementById("contactSelect");
|
|
||||||
|
|
||||||
// Clear Category dropdown
|
|
||||||
let i, L = contactSelectDropdown.options.length - 1;
|
|
||||||
for (i = L; i >= 0; i--) {
|
|
||||||
contactSelectDropdown.remove(i);
|
|
||||||
}
|
|
||||||
contactSelectDropdown[contactSelectDropdown.length] = new Option('- Contact -', '0');
|
|
||||||
|
|
||||||
// Populate dropdown
|
|
||||||
contacts.forEach(contact => {
|
|
||||||
var appendText = "";
|
|
||||||
if (contact.contact_primary == "1") {
|
|
||||||
appendText = " (Primary)";
|
|
||||||
} else if (contact.contact_technical == "1") {
|
|
||||||
appendText = " (Technical)";
|
|
||||||
}
|
|
||||||
contactSelectDropdown[contactSelectDropdown.length] = new Option(contact.contact_name + appendText, contact.contact_id);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
176
js/tickets_add_modal.js
Normal file
176
js/tickets_add_modal.js
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
// Used to populate dynamic content in recurring_ticket_add_modal and ticket_add_modal_v2 based on selected client
|
||||||
|
|
||||||
|
// Client selected listener
|
||||||
|
// We seem to have to use jQuery to listen for events, as the client input is a select2 component?
|
||||||
|
|
||||||
|
const clientSelectDropdown = document.getElementById("changeClientSelect"); // Define client selector
|
||||||
|
|
||||||
|
// // If the client selector is disabled, we must be on a client-specific page instead. Trigger the lists to update.
|
||||||
|
if (clientSelectDropdown.disabled) {
|
||||||
|
|
||||||
|
let client_id = $(clientSelectDropdown).find(':selected').val();
|
||||||
|
|
||||||
|
populateLists(client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Listener for client selection. Populate select lists when a client is selected
|
||||||
|
$(clientSelectDropdown).on('select2:select', function (e) {
|
||||||
|
let client_id = $(this).find(':selected').val();
|
||||||
|
|
||||||
|
// Update the contacts dropdown list
|
||||||
|
populateLists(client_id);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// Populates dropdowns with dynamic content based on the client ID
|
||||||
|
// Called the client select dropdown is used or if the client select is disabled
|
||||||
|
function populateLists(client_id) {
|
||||||
|
|
||||||
|
populateContactsDropdown(client_id);
|
||||||
|
|
||||||
|
populateAssetsDropdown(client_id);
|
||||||
|
|
||||||
|
populateLocationsDropdown(client_id);
|
||||||
|
|
||||||
|
populateVendorsDropdown(client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate client contacts
|
||||||
|
function populateContactsDropdown(client_id) {
|
||||||
|
// Send a GET request to ajax.php as ajax.php?get_client_contacts=true&client_id=NUM
|
||||||
|
jQuery.get(
|
||||||
|
"ajax.php",
|
||||||
|
{get_client_contacts: 'true', client_id: client_id},
|
||||||
|
function(data) {
|
||||||
|
|
||||||
|
// If we get a response from ajax.php, parse it as JSON
|
||||||
|
const response = JSON.parse(data);
|
||||||
|
|
||||||
|
// Access the data for contacts (multiple)
|
||||||
|
const contacts = response.contacts;
|
||||||
|
|
||||||
|
// Contacts dropdown
|
||||||
|
const contactSelectDropdown = document.getElementById("contactSelect");
|
||||||
|
|
||||||
|
// Clear dropdown
|
||||||
|
let i, L = contactSelectDropdown.options.length - 1;
|
||||||
|
for (i = L; i >= 0; i--) {
|
||||||
|
contactSelectDropdown.remove(i);
|
||||||
|
}
|
||||||
|
contactSelectDropdown[contactSelectDropdown.length] = new Option('- Contact -', '0');
|
||||||
|
|
||||||
|
// Populate dropdown
|
||||||
|
contacts.forEach(contact => {
|
||||||
|
var appendText = "";
|
||||||
|
if (contact.contact_primary == "1") {
|
||||||
|
appendText = " (Primary)";
|
||||||
|
} else if (contact.contact_technical == "1") {
|
||||||
|
appendText = " (Technical)";
|
||||||
|
}
|
||||||
|
contactSelectDropdown[contactSelectDropdown.length] = new Option(contact.contact_name + appendText, contact.contact_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate client assets
|
||||||
|
function populateAssetsDropdown(client_id) {
|
||||||
|
jQuery.get(
|
||||||
|
"ajax.php",
|
||||||
|
{get_client_assets: 'true', client_id: client_id},
|
||||||
|
function(data) {
|
||||||
|
|
||||||
|
// If we get a response from ajax.php, parse it as JSON
|
||||||
|
const response = JSON.parse(data);
|
||||||
|
|
||||||
|
// Access the data for assets (multiple)
|
||||||
|
const assets = response.assets;
|
||||||
|
|
||||||
|
// Assets dropdown
|
||||||
|
const assetSelectDropdown = document.getElementById("assetSelect");
|
||||||
|
|
||||||
|
// Clear dropdown
|
||||||
|
let i, L = assetSelectDropdown.options.length - 1;
|
||||||
|
for (i = L; i >= 0; i--) {
|
||||||
|
assetSelectDropdown.remove(i);
|
||||||
|
}
|
||||||
|
assetSelectDropdown[assetSelectDropdown.length] = new Option('- Asset -', '0');
|
||||||
|
|
||||||
|
// Populate dropdown with asset name (and contact, if set)
|
||||||
|
assets.forEach(asset => {
|
||||||
|
let displayText = asset.asset_name;
|
||||||
|
if (asset.contact_name !== null) {
|
||||||
|
displayText = asset.asset_name + " - " + asset.contact_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
assetSelectDropdown[assetSelectDropdown.length] = new Option(displayText, asset.asset_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate client locations
|
||||||
|
function populateLocationsDropdown(client_id) {
|
||||||
|
jQuery.get(
|
||||||
|
"ajax.php",
|
||||||
|
{get_client_locations: 'true', client_id: client_id},
|
||||||
|
function(data) {
|
||||||
|
|
||||||
|
// If we get a response from ajax.php, parse it as JSON
|
||||||
|
const response = JSON.parse(data);
|
||||||
|
|
||||||
|
// Access the data for locations (multiple)
|
||||||
|
const locations = response.locations;
|
||||||
|
|
||||||
|
// Locations dropdown
|
||||||
|
const locationSelectDropdown = document.getElementById("locationSelect");
|
||||||
|
|
||||||
|
// Clear dropdown
|
||||||
|
let i, L = locationSelectDropdown.options.length - 1;
|
||||||
|
for (i = L; i >= 0; i--) {
|
||||||
|
locationSelectDropdown.remove(i);
|
||||||
|
}
|
||||||
|
locationSelectDropdown[locationSelectDropdown.length] = new Option('- Location -', '0');
|
||||||
|
|
||||||
|
// Populate dropdown
|
||||||
|
locations.forEach(location => {
|
||||||
|
locationSelectDropdown[locationSelectDropdown.length] = new Option(location.location_name, location.location_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate client vendors
|
||||||
|
function populateVendorsDropdown(client_id) {
|
||||||
|
jQuery.get(
|
||||||
|
"ajax.php",
|
||||||
|
{get_client_vendors: 'true', client_id: client_id},
|
||||||
|
function(data) {
|
||||||
|
|
||||||
|
// If we get a response from ajax.php, parse it as JSON
|
||||||
|
const response = JSON.parse(data);
|
||||||
|
|
||||||
|
// Access the data for locations (multiple)
|
||||||
|
const vendors = response.vendors;
|
||||||
|
|
||||||
|
// Locations dropdown
|
||||||
|
const vendorSelectDropdown = document.getElementById("vendorSelect");
|
||||||
|
|
||||||
|
// Clear dropdown
|
||||||
|
let i, L = vendorSelectDropdown.options.length - 1;
|
||||||
|
for (i = L; i >= 0; i--) {
|
||||||
|
vendorSelectDropdown.remove(i);
|
||||||
|
}
|
||||||
|
vendorSelectDropdown[vendorSelectDropdown.length] = new Option('- Vendor -', '0');
|
||||||
|
|
||||||
|
// Populate dropdown
|
||||||
|
vendors.forEach(vendor => {
|
||||||
|
vendorSelectDropdown[vendorSelectDropdown.length] = new Option(vendor.vendor_name, vendor.vendor_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Priority <strong class="text-danger">*</strong></label>
|
<label>Priority <strong class="text-danger">*</strong></label>
|
||||||
@@ -233,7 +233,7 @@
|
|||||||
$asset_name_select = nullable_htmlentities($row['asset_name']);
|
$asset_name_select = nullable_htmlentities($row['asset_name']);
|
||||||
?>
|
?>
|
||||||
<option value="<?php echo $asset_id_select; ?>"
|
<option value="<?php echo $asset_id_select; ?>"
|
||||||
<?php if (isset($_GET['asset_id']) && $asset_id_select == $_GET['asset_id']) { echo "selected"; }
|
<?php if (isset($_GET['asset_id']) && $asset_id_select == $_GET['asset_id']) { echo "selected"; }
|
||||||
?>
|
?>
|
||||||
|
|
||||||
><?php echo $asset_name_select; ?>
|
><?php echo $asset_name_select; ?>
|
||||||
@@ -288,4 +288,4 @@
|
|||||||
<!-- Recurring Ticket Client/Contact JS -->
|
<!-- Recurring Ticket Client/Contact JS -->
|
||||||
<link rel="stylesheet" href="plugins/jquery-ui/jquery-ui.min.css">
|
<link rel="stylesheet" href="plugins/jquery-ui/jquery-ui.min.css">
|
||||||
<script src="plugins/jquery-ui/jquery-ui.min.js"></script>
|
<script src="plugins/jquery-ui/jquery-ui.min.js"></script>
|
||||||
<script src="js/recurring_tickets_add_modal.js"></script>
|
<script src="js/tickets_add_modal.js"></script>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="modal-dialog modal-lg">
|
<div class="modal-dialog modal-lg">
|
||||||
<div class="modal-content bg-dark">
|
<div class="modal-content bg-dark">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title"><i class="fas fa-fw fa-life-ring mr-2"></i>New Ticket</h5>
|
<h5 class="modal-title"><i class="fas fa-fw fa-life-ring mr-2"></i>New Ticket (v1)</h5>
|
||||||
<button type="button" class="close text-white" data-dismiss="modal">
|
<button type="button" class="close text-white" data-dismiss="modal">
|
||||||
<span>×</span>
|
<span>×</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<?php if (isset($_GET['project_id'])) { ?>
|
<?php if (isset($_GET['project_id'])) { ?>
|
||||||
<input type="hidden" name="project" value="<?php echo intval($_GET['project_id']); ?>">
|
<input type="hidden" name="project" value="<?php echo intval($_GET['project_id']); ?>">
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<div class="modal-body bg-white">
|
<div class="modal-body bg-white">
|
||||||
|
|
||||||
<?php if (isset($_GET['client_id'])) { ?>
|
<?php if (isset($_GET['client_id'])) { ?>
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Priority <strong class="text-danger">*</strong></label>
|
<label>Priority <strong class="text-danger">*</strong></label>
|
||||||
@@ -265,16 +265,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<option value="<?php echo $contact_id_select; ?>"
|
<option value="<?php echo $contact_id_select; ?>"
|
||||||
<?php
|
<?php
|
||||||
if (isset($_GET['contact_id']) && $contact_id_select == intval($_GET['contact_id'])) {
|
if (isset($_GET['contact_id']) && $contact_id_select == intval($_GET['contact_id'])) {
|
||||||
echo "selected";
|
echo "selected";
|
||||||
} elseif (empty($_GET['contact_id']) && $contact_primary_select == 1) {
|
} elseif (empty($_GET['contact_id']) && $contact_primary_select == 1) {
|
||||||
echo "selected";
|
echo "selected";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
>
|
>
|
||||||
<?php echo "$contact_name_select$contact_title_display$contact_primary_display$contact_technical_display"; ?>
|
<?php echo "$contact_name_select$contact_title_display$contact_primary_display$contact_technical_display"; ?>
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@@ -322,8 +322,8 @@
|
|||||||
$asset_name_select = nullable_htmlentities($row['asset_name']);
|
$asset_name_select = nullable_htmlentities($row['asset_name']);
|
||||||
$asset_contact_name_select = nullable_htmlentities($row['contact_name']);
|
$asset_contact_name_select = nullable_htmlentities($row['contact_name']);
|
||||||
?>
|
?>
|
||||||
<option value="<?php echo $asset_id_select; ?>"
|
<option value="<?php echo $asset_id_select; ?>"
|
||||||
<?php if (isset($_GET['asset_id']) && $asset_id_select == $_GET['asset_id']) { echo "selected"; }
|
<?php if (isset($_GET['asset_id']) && $asset_id_select == $_GET['asset_id']) { echo "selected"; }
|
||||||
?>
|
?>
|
||||||
><?php echo "$asset_name_select - $asset_contact_name_select"; ?></option>
|
><?php echo "$asset_name_select - $asset_contact_name_select"; ?></option>
|
||||||
|
|
||||||
@@ -380,7 +380,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -417,7 +417,7 @@
|
|||||||
<input type="text" class="form-control" name="vendor_ticket_number" placeholder="Vendor ticket number">
|
<input type="text" class="form-control" name="vendor_ticket_number" placeholder="Vendor ticket number">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -486,4 +486,4 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
333
modals/ticket_add_modal_v2.php
Normal file
333
modals/ticket_add_modal_v2.php
Normal file
@@ -0,0 +1,333 @@
|
|||||||
|
<div class="modal" id="addTicketModalv2" tabindex="-1">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
<div class="modal-content bg-dark">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title"><i class="fas fa-fw fa-life-ring mr-2"></i>New Ticket (v2)</h5>
|
||||||
|
<button type="button" class="close text-white" data-dismiss="modal">
|
||||||
|
<span>×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form action="post.php" method="post" autocomplete="off">
|
||||||
|
<!-- Hidden/System fields -->
|
||||||
|
<?php if ($client_url && isset($client_id)) { ?>
|
||||||
|
<input type="hidden" name="client" value="<?php echo $client_id; ?>>">
|
||||||
|
<?php }
|
||||||
|
if (isset($_GET['contact_id'])) { ?>
|
||||||
|
<input type="hidden" name="contact" value="<?php echo intval($_GET['contact_id']); ?>">
|
||||||
|
<?php }
|
||||||
|
if (isset($_GET['project_id'])) { ?>
|
||||||
|
<input type="hidden" name="project" value="<?php echo intval($_GET['project_id']); ?>">
|
||||||
|
<?php } ?>
|
||||||
|
<input type="hidden" name="billable" value="0">
|
||||||
|
|
||||||
|
<div class="modal-body bg-white">
|
||||||
|
|
||||||
|
<!-- Nav -->
|
||||||
|
<ul class="nav nav-pills nav-justified mb-3">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" data-toggle="pill" href="#pills-add-details"><i class="fa fa-fw fa-life-ring mr-2"></i>Details</a>
|
||||||
|
</li>
|
||||||
|
<!-- Hide contact if in URL as it means we're creating a ticket from a contact record -->
|
||||||
|
<?php if (!isset($_GET['contact_id'])) { ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="pill" href="#pills-add-contacts"><i class="fa fa-fw fa-users mr-2"></i>Contact</a>
|
||||||
|
</li>
|
||||||
|
<?php } ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="pill" href="#pills-add-relationships"><i class="fa fa-fw fa-desktop mr-2"></i>Assignment</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
<div class="tab-content">
|
||||||
|
|
||||||
|
<!-- Ticket details -->
|
||||||
|
<div class="tab-pane fade show active" id="pills-add-details">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Template</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>
|
||||||
|
<select class="form-control select2" id="ticket_template_select" name="ticket_template_id" required>
|
||||||
|
<option value="0">- Choose a Template -</option>
|
||||||
|
<?php
|
||||||
|
$sql_ticket_templates = mysqli_query($mysqli, "
|
||||||
|
SELECT tt.ticket_template_id,
|
||||||
|
tt.ticket_template_name,
|
||||||
|
tt.ticket_template_subject,
|
||||||
|
tt.ticket_template_details,
|
||||||
|
COUNT(ttt.task_template_id) as task_count
|
||||||
|
FROM ticket_templates tt
|
||||||
|
LEFT JOIN task_templates ttt
|
||||||
|
ON tt.ticket_template_id = ttt.task_template_ticket_template_id
|
||||||
|
WHERE tt.ticket_template_archived_at IS NULL
|
||||||
|
GROUP BY tt.ticket_template_id
|
||||||
|
ORDER BY tt.ticket_template_name ASC
|
||||||
|
");
|
||||||
|
|
||||||
|
while ($row = mysqli_fetch_array($sql_ticket_templates)) {
|
||||||
|
$ticket_template_id_select = intval($row['ticket_template_id']);
|
||||||
|
$ticket_template_name_select = nullable_htmlentities($row['ticket_template_name']);
|
||||||
|
$ticket_template_subject_select = nullable_htmlentities($row['ticket_template_subject']);
|
||||||
|
$ticket_template_details_select = nullable_htmlentities($row['ticket_template_details']);
|
||||||
|
$task_count = intval($row['task_count']);
|
||||||
|
?>
|
||||||
|
<option value="<?php echo $ticket_template_id_select; ?>"
|
||||||
|
data-subject="<?php echo $ticket_template_subject_select; ?>"
|
||||||
|
data-details="<?php echo $ticket_template_details_select; ?>">
|
||||||
|
<?php echo $ticket_template_name_select; ?> (<?php echo $task_count; ?> tasks)
|
||||||
|
</option>
|
||||||
|
<?php echo "aaaaa"; ?>
|
||||||
|
<?php var_dump($row); ?>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Subject <strong class="text-danger">*</strong></label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" id="subjectInput" name="subject" placeholder="Subject" maxlength="500" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<textarea class="form-control tinymceTicket<?php if ($config_ai_enable) { echo "AI"; } ?>" id="detailsInput" name="details"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Priority <strong class="text-danger">*</strong></label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-thermometer-half"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="priority" required>
|
||||||
|
<option>Low</option>
|
||||||
|
<option>Medium</option>
|
||||||
|
<option>High</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Category</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-layer-group"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="category">
|
||||||
|
<option value="0">- Not Categorized -</option>
|
||||||
|
<?php
|
||||||
|
$sql_categories = mysqli_query($mysqli, "SELECT category_id, category_name FROM categories WHERE category_type = 'Ticket' AND category_archived_at IS NULL ORDER BY category_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_categories)) {
|
||||||
|
$category_id = intval($row['category_id']);
|
||||||
|
$category_name = nullable_htmlentities($row['category_name']);
|
||||||
|
?>
|
||||||
|
<option value="<?php echo $category_id; ?>"><?php echo $category_name; ?></option>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button class="btn btn-secondary" type="button"
|
||||||
|
data-toggle="ajax-modal"
|
||||||
|
data-modal-size="sm"
|
||||||
|
data-ajax-url="ajax/ajax_category_add.php?category=Ticket">
|
||||||
|
<i class="fas fa-fw fa-plus"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Assign to</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-user-check"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="assigned_to">
|
||||||
|
<option value="0">- Not Assigned -</option>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$sql = mysqli_query(
|
||||||
|
$mysqli,
|
||||||
|
"SELECT user_id, user_name FROM users
|
||||||
|
WHERE user_role_id > 1 AND user_status = 1 AND user_archived_at IS NULL ORDER BY user_name ASC"
|
||||||
|
);
|
||||||
|
while ($row = mysqli_fetch_array($sql)) {
|
||||||
|
$user_id = intval($row['user_id']);
|
||||||
|
$user_name = nullable_htmlentities($row['user_name']); ?>
|
||||||
|
<option value="<?php echo $user_id; ?>"><?php echo $user_name; ?></option>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ($config_module_enable_accounting) { ?>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="custom-control custom-switch">
|
||||||
|
<input type="checkbox" class="custom-control-input" name="billable" <?php if ($config_ticket_default_billable == 1) { echo "checked"; } ?> value="1" id="billable">
|
||||||
|
<label class="custom-control-label" for="billable">Mark Billable</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Ticket client/contact -->
|
||||||
|
<?php if (!isset($_GET['contact_id'])) { ?>
|
||||||
|
<div class="tab-pane fade" id="pills-add-contacts">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Client <strong class="text-danger">*</strong></label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="client" id="changeClientSelect" required <?php if ($client_url && isset($client_id)) { echo "disabled"; } ?>>
|
||||||
|
<option value="">- Client -</option>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL $access_permission_query ORDER BY client_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql)) {
|
||||||
|
$selectable_client_id = intval($row['client_id']);
|
||||||
|
$client_name = nullable_htmlentities($row['client_name']); ?>
|
||||||
|
|
||||||
|
<option value="<?php echo $selectable_client_id; ?>" <?php if ($client_url && isset($client_id) && $client_id == $selectable_client_id) {echo "selected"; } ?>><?php echo $client_name; ?></option>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Contact </label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="contact" id="contactSelect">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<div class="tab-pane fade" id="pills-add-relationships">
|
||||||
|
To-do: project, etc.
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label> Asset </label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-desktop"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="asset" id="assetSelect">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label> Location </label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-map-marker-alt"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="location" id="locationSelect">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
|
<div class="form-group">
|
||||||
|
<label> Vendor </label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-building"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="vendor" id="vendorSelect">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Vendor Ticket Number</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" name="vendor_ticket_number" placeholder="Vendor ticket number">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer bg-white">
|
||||||
|
<button type="submit" name="add_ticket" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Create</button>
|
||||||
|
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Ticket Templates -->
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
var templateSelect = $('#ticket_template_select');
|
||||||
|
var subjectInput = document.getElementById('subjectInput');
|
||||||
|
var detailsInput = document.getElementById('detailsInput');
|
||||||
|
|
||||||
|
templateSelect.on('select2:select', function(e) {
|
||||||
|
var selectedOption = e.params.data.element;
|
||||||
|
var templateSubject = selectedOption.getAttribute('data-subject');
|
||||||
|
var templateDetails = selectedOption.getAttribute('data-details');
|
||||||
|
|
||||||
|
// Update Subject
|
||||||
|
subjectInput.value = templateSubject || '';
|
||||||
|
|
||||||
|
// Update Details
|
||||||
|
if (typeof tinymce !== 'undefined') {
|
||||||
|
var editor = tinymce.get('detailsInput');
|
||||||
|
if (editor) {
|
||||||
|
editor.setContent(templateDetails || '');
|
||||||
|
} else {
|
||||||
|
detailsInput.value = templateDetails || '';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
detailsInput.value = templateDetails || '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- Ticket Client/Contact JS -->
|
||||||
|
<link rel="stylesheet" href="plugins/jquery-ui/jquery-ui.min.css">
|
||||||
|
<script src="plugins/jquery-ui/jquery-ui.min.js"></script>
|
||||||
|
<script src="js/tickets_add_modal.js"></script>
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ $sql_categories = mysqli_query(
|
|||||||
<?php if (lookupUserPermission("module_support") >= 2) { ?>
|
<?php if (lookupUserPermission("module_support") >= 2) { ?>
|
||||||
<div class="card-tools">
|
<div class="card-tools">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addTicketModal">
|
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addTicketModalv2">
|
||||||
<i class="fas fa-plus"></i><span class="d-none d-lg-inline ml-2">New Ticket</span>
|
<i class="fas fa-plus"></i><span class="d-none d-lg-inline ml-2">New Ticket</span>
|
||||||
</button>
|
</button>
|
||||||
<?php if ($num_rows[0] > 0) { ?>
|
<?php if ($num_rows[0] > 0) { ?>
|
||||||
@@ -438,6 +438,6 @@ if (isset($_GET["view"])) {
|
|||||||
<script src="js/bulk_actions.js"></script>
|
<script src="js/bulk_actions.js"></script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
require_once "modals/ticket_add_modal.php";
|
require_once "modals/ticket_add_modal_v2.php";
|
||||||
require_once "modals/ticket_export_modal.php";
|
require_once "modals/ticket_export_modal.php";
|
||||||
require_once "includes/footer.php";
|
require_once "includes/footer.php";
|
||||||
|
|||||||
Reference in New Issue
Block a user