Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API - New tickets #1121

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions api/v1/tickets/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
// Default
$insert_id = false;

if (!empty($subject) && !empty($client_id)) {
if (!empty($subject)) {

// If no contact is selected automatically choose the primary contact for the client
if ($contact == 0) {
if (!is_int($client_id)) {
$client_id = 0;
}

// If no contact is selected automatically choose the primary contact for the client (if client set)
if ($contact == 0 && $client_id != 0) {
$sql = mysqli_query($mysqli,"SELECT contact_id FROM contacts WHERE contact_client_id = $client_id AND contact_primary = 1");
$row = mysqli_fetch_array($sql);
$contact = intval($row['contact_id']);
Expand All @@ -34,7 +38,8 @@
mysqli_query($mysqli,"UPDATE settings SET config_ticket_next_number = $new_config_ticket_next_number WHERE company_id = 1");

// Insert ticket
$insert_sql = mysqli_query($mysqli,"INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_priority = '$priority', ticket_status = 1, ticket_vendor_ticket_number = '$vendor_ticket_number', ticket_vendor_id = $vendor_id, ticket_created_by = 0, ticket_assigned_to = $assigned_to, ticket_contact_id = $contact, ticket_client_id = $client_id");
$url_key = randomString(156);
$insert_sql = mysqli_query($mysqli,"INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_priority = '$priority', ticket_status = 1, ticket_vendor_ticket_number = '$vendor_ticket_number', ticket_vendor_id = $vendor_id, ticket_created_by = 0, ticket_assigned_to = $assigned_to, ticket_contact_id = $contact, ticket_url_key = '$url_key', ticket_client_id = $client_id");

// Check insert & get insert ID
if ($insert_sql) {
Expand Down
4 changes: 2 additions & 2 deletions api/v1/tickets/ticket_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@


if (isset($_POST['ticket_details'])) {
$details = sanitizeInput($_POST['ticket_details']);
$details = sanitizeInput($_POST['ticket_details']) . "<br>";
} elseif ($ticket_row) {
$details = $ticket_row['ticket_details'];
} else {
$details = '< blank >';
$details = '< blank ><br>';
}

if (isset($_POST['ticket_vendor_id'])) {
Expand Down
Loading