diff --git a/ajax.php b/ajax.php index e1152a61..90fd64e6 100644 --- a/ajax.php +++ b/ajax.php @@ -284,57 +284,6 @@ if (isset($_GET['share_generate_link'])) { } -/* - * Looks up info for a given recurring (was scheduled) ticket ID from the database, used to dynamically populate modal edit fields - */ -if (isset($_GET['recurring_ticket_get_json_details'])) { - enforceUserPermission('module_support'); - - $client_id = intval($_GET['client_id']); - $ticket_id = intval($_GET['ticket_id']); - - // Get all contacts, to allow tickets to be raised under a specific contact - $contact_sql = mysqli_query($mysqli, "SELECT contact_id, contact_name FROM contacts - WHERE contact_client_id = $client_id - AND contact_archived_at IS NULL - ORDER BY contact_primary DESC, contact_technical DESC, contact_name ASC" - ); - while ($row = mysqli_fetch_array($contact_sql)) { - $response['contacts'][] = $row; - } - - // Get ticket details - $ticket_sql = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets - WHERE scheduled_ticket_id = $ticket_id - AND scheduled_ticket_client_id = $client_id LIMIT 1"); - while ($row = mysqli_fetch_array($ticket_sql)) { - $response['ticket'][] = $row; - } - - // Get assets - $asset_sql = mysqli_query($mysqli, "SELECT asset_id, asset_name FROM assets WHERE asset_client_id = $client_id AND asset_archived_at IS NULL"); - while ($row = mysqli_fetch_array($asset_sql)) { - $response['assets'][] = $row; - } - - // Get technicians to auto assign the ticket to - $sql_agents = mysqli_query( - $mysqli, - "SELECT users.user_id, user_name FROM users - LEFT JOIN user_settings on users.user_id = user_settings.user_id - WHERE user_role > 1 - AND user_status = 1 - AND user_archived_at IS NULL - ORDER BY user_name ASC" - ); - while ($row = mysqli_fetch_array($sql_agents)) { - $response['agents'][] = $row; - } - - echo json_encode($response); - -} - /* * Returns sorted list of active clients */ diff --git a/ajax/ajax_recurring_ticket_edit.php b/ajax/ajax_recurring_ticket_edit.php new file mode 100644 index 00000000..e6356739 --- /dev/null +++ b/ajax/ajax_recurring_ticket_edit.php @@ -0,0 +1,233 @@ + + + +
+ + + + + +
+ += 0; i--) { - agentDropdown.remove(i); - } - agentDropdown[agentDropdown.length] = new Option('- Agent -', '0'); - - - // Populate dropdown - agents.forEach(agent => { - if(parseInt(agent.user_id) == parseInt(ticket.scheduled_ticket_assigned_to)){ - // Selected agent - agentDropdown[agentDropdown.length] = new Option(agent.user_name, agent.user_id, true, true); - } - else{ - agentDropdown[agentDropdown.length] = new Option(agent.user_name, agent.user_id); - } - }); - - // Contact dropdown - var contactDropdown = document.getElementById("editTicketContact"); - - // Clear contact dropdown - var i, L = contactDropdown.options.length -1; - for(i = L; i >= 0; i--) { - contactDropdown.remove(i); - } - contactDropdown[contactDropdown.length] = new Option('- Contact -', '0'); - - - // Populate dropdown - contacts.forEach(contact => { - if(parseInt(contact.contact_id) == parseInt(ticket.scheduled_ticket_contact_id)){ - // Selected contact - contactDropdown[contactDropdown.length] = new Option(contact.contact_name, contact.contact_id, true, true); - } - else{ - contactDropdown[contactDropdown.length] = new Option(contact.contact_name, contact.contact_id); - } - }); - - // Frequency dropdown - var frequencyDropdown = document.querySelector("#editTicketFrequency"); - Array.from(frequencyDropdown.options).forEach(function (option, index){ - if(option.id === ticket.scheduled_ticket_frequency){ - frequencyDropdown.selectedIndex = index; - } - }); - - // Priority dropdown - var priorityDropdown = document.querySelector("#editTicketPriority"); - Array.from(priorityDropdown.options).forEach(function (option, index){ - if(option.id === ticket.scheduled_ticket_priority){ - priorityDropdown.selectedIndex = index; - } - }); - - // Asset dropdown - if (assets && assets.length > 0) { - var assetDropdown = document.getElementById("editTicketAssetId"); - - // Clear asset dropdown - var i, L = assetDropdown.options.length -1; - for(i = L; i >= 0; i--) { - assetDropdown.remove(i); - } - assetDropdown[assetDropdown.length] = new Option('- Asset -', '0'); - - // Populate dropdown - assets.forEach(asset => { - if(parseInt(asset.asset_id) == parseInt(ticket.scheduled_ticket_asset_id)){ - // Selected asset - assetDropdown[assetDropdown.length] = new Option(asset.asset_name, asset.asset_id, true, true); - } - else{ - assetDropdown[assetDropdown.length] = new Option(asset.asset_name, asset.asset_id); - } - }); - } - - } - ); -} diff --git a/modals/recurring_ticket_edit_modal.php b/modals/recurring_ticket_edit_modal.php deleted file mode 100644 index 1b8a80b9..00000000 --- a/modals/recurring_ticket_edit_modal.php +++ /dev/null @@ -1,158 +0,0 @@ - diff --git a/recurring_tickets.php b/recurring_tickets.php index e74c3ebf..08c17716 100644 --- a/recurring_tickets.php +++ b/recurring_tickets.php @@ -177,7 +177,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); - )"> + + @@ -194,7 +200,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); -