Change client - fix code smell

This commit is contained in:
Marcus Hill
2023-04-10 19:13:31 +01:00
parent c55d2a8cda
commit a26f3087fc
4 changed files with 12 additions and 13 deletions

View File

@@ -3,16 +3,15 @@
*/ */
// Modal loaded listener - populate client select // Modal loaded listener - populate client select
changeClientModalLoad = document.getElementById('clientChangeTicketModalLoad'); const changeClientModalLoad = document.getElementById('clientChangeTicketModalLoad');
changeClientModalLoad.addEventListener('click', function() { changeClientModalLoad.addEventListener('click', function() {
populateChangeClientModal_Clients(); populateChangeClientModal_Clients();
}) })
// Client selected listener - populate contact select // Client selected listener - populate contact select
// We seem to have to use jQuery to listen for events, as the client input is a select2 component? // We seem to have to use jQuery to listen for events, as the client input is a select2 component?
clientSelectDropdown = document.getElementById("changeClientSelect"); const clientSelectDropdown = document.getElementById("changeClientSelect");
$(clientSelectDropdown).on('select2:select', function (e) { $(clientSelectDropdown).on('select2:select', function (e) {
console.log("Fired contacts listener!!!!!!")
let client_id = $(this).find(':selected').val(); let client_id = $(this).find(':selected').val();
populateChangeClientModal_Contacts(client_id); populateChangeClientModal_Contacts(client_id);
}); });
@@ -43,7 +42,7 @@ function populateChangeClientModal_Clients() {
// Client dropdown already defined in listeners as clientSelectDropdown // Client dropdown already defined in listeners as clientSelectDropdown
// Clear dropdown // Clear dropdown
var i, L = clientSelectDropdown.options.length -1; let i, L = clientSelectDropdown.options.length - 1;
for (i = L; i >= 0; i--) { for (i = L; i >= 0; i--) {
clientSelectDropdown.remove(i); clientSelectDropdown.remove(i);
} }
@@ -76,10 +75,10 @@ function populateChangeClientModal_Contacts(client_id) {
const contacts = response.contacts; const contacts = response.contacts;
// Contacts dropdown // Contacts dropdown
var contactSelectDropdown = document.getElementById("changeContactSelect"); const contactSelectDropdown = document.getElementById("changeContactSelect");
// Clear Category dropdown // Clear Category dropdown
var i, L = contactSelectDropdown.options.length -1; let i, L = contactSelectDropdown.options.length - 1;
for (i = L; i >= 0; i--) { for (i = L; i >= 0; i--) {
contactSelectDropdown.remove(i); contactSelectDropdown.remove(i);
} }

View File

@@ -6515,7 +6515,7 @@ if(isset($_POST['change_client_ticket'])){
mysqli_query($mysqli, "UPDATE tickets SET ticket_client_id = $client_id, ticket_contact_id = $contact_id WHERE ticket_id = $ticket_id LIMIT 1"); mysqli_query($mysqli, "UPDATE tickets SET ticket_client_id = $client_id, ticket_contact_id = $contact_id WHERE ticket_id = $ticket_id LIMIT 1");
//Logging //Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Ticket Reply', log_action = 'Modify', log_description = '$session_name modified ticket - client changed', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $ticket_id"); mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket Reply', log_action = 'Modify', log_description = '$session_name modified ticket - client changed', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $ticket_id");
$_SESSION['alert_message'] = "Ticket client updated"; $_SESSION['alert_message'] = "Ticket client updated";

View File

@@ -651,10 +651,10 @@ if (isset($_GET['ticket_id'])) {
</div> </div>
<?php <?php
require("ticket_edit_modal.php"); require_once("ticket_edit_modal.php");
require("ticket_change_client_modal.php"); require_once("ticket_change_client_modal.php");
require("ticket_merge_modal.php"); require_once("ticket_merge_modal.php");
require("ticket_invoice_add_modal.php"); require_once("ticket_invoice_add_modal.php");
} }

View File

@@ -23,12 +23,12 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>New Contact <strong class="text-danger">*</strong></label> <label>New Contact</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-user"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
</div> </div>
<select class="form-control select2" name="new_contact_id" id="changeContactSelect" required> <select class="form-control select2" name="new_contact_id" id="changeContactSelect">
</select> </select>
</div> </div>
</div> </div>