Skip to content

Commit

Permalink
Merge pull request #1121 from itflow-org/api-tck-fix-2
Browse files Browse the repository at this point in the history
API - New tickets
  • Loading branch information
johnnyq authored Dec 14, 2024
2 parents 19221b8 + 3eda726 commit 83cbb3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
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

0 comments on commit 83cbb3d

Please sign in to comment.