Skip to content

Commit 83cbb3d

Browse files
authored
Merge pull request #1121 from itflow-org/api-tck-fix-2
API - New tickets
2 parents 19221b8 + 3eda726 commit 83cbb3d

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

api/v1/tickets/create.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
// Default
2020
$insert_id = false;
2121

22-
if (!empty($subject) && !empty($client_id)) {
22+
if (!empty($subject)) {
2323

24-
// If no contact is selected automatically choose the primary contact for the client
25-
if ($contact == 0) {
24+
if (!is_int($client_id)) {
25+
$client_id = 0;
26+
}
27+
28+
// If no contact is selected automatically choose the primary contact for the client (if client set)
29+
if ($contact == 0 && $client_id != 0) {
2630
$sql = mysqli_query($mysqli,"SELECT contact_id FROM contacts WHERE contact_client_id = $client_id AND contact_primary = 1");
2731
$row = mysqli_fetch_array($sql);
2832
$contact = intval($row['contact_id']);
@@ -34,7 +38,8 @@
3438
mysqli_query($mysqli,"UPDATE settings SET config_ticket_next_number = $new_config_ticket_next_number WHERE company_id = 1");
3539

3640
// Insert ticket
37-
$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");
41+
$url_key = randomString(156);
42+
$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");
3843

3944
// Check insert & get insert ID
4045
if ($insert_sql) {

api/v1/tickets/ticket_model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929

3030

3131
if (isset($_POST['ticket_details'])) {
32-
$details = sanitizeInput($_POST['ticket_details']);
32+
$details = sanitizeInput($_POST['ticket_details']) . "<br>";
3333
} elseif ($ticket_row) {
3434
$details = $ticket_row['ticket_details'];
3535
} else {
36-
$details = '< blank >';
36+
$details = '< blank ><br>';
3737
}
3838

3939
if (isset($_POST['ticket_vendor_id'])) {

0 commit comments

Comments
 (0)