From 3e7f57f64ae35bccaabd525438a69b01d2d09a9c Mon Sep 17 00:00:00 2001 From: johnnyq Date: Fri, 10 May 2024 14:27:04 -0400 Subject: [PATCH] Add contact primary to the API edit ^Cd create --- api/v1/contacts/contact_model.php | 8 ++++++++ api/v1/contacts/create.php | 2 +- api/v1/contacts/update.php | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/v1/contacts/contact_model.php b/api/v1/contacts/contact_model.php index 8fa13b27..7cb724b4 100644 --- a/api/v1/contacts/contact_model.php +++ b/api/v1/contacts/contact_model.php @@ -74,6 +74,14 @@ if (isset($_POST['contact_auth_method'])) { $auth_method = ''; } +if (isset($_POST['contact_primary'])) { + $primary = intval($_POST['contact_primary']); +} elseif ($contact_row) { + $primary = $contact_row['contact_primary']; +} else { + $primary = '0'; +} + if (isset($_POST['contact_important'])) { $important = intval($_POST['contact_important']); } elseif ($contact_row) { diff --git a/api/v1/contacts/create.php b/api/v1/contacts/create.php index 2599eaa2..cf51f7c9 100644 --- a/api/v1/contacts/create.php +++ b/api/v1/contacts/create.php @@ -20,7 +20,7 @@ if (!empty($name) && !empty($email) && !empty($client_id)) { if (mysqli_num_rows($email_duplication_sql) == 0) { // Insert contact - $insert_sql = mysqli_query($mysqli, "INSERT INTO contacts SET contact_name = '$name', contact_title = '$title', contact_department = '$department', contact_email = '$email', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_important = '$important', contact_billing = '$billing', contact_technical = '$technical', contact_location_id = $location_id, contact_client_id = $client_id"); + $insert_sql = mysqli_query($mysqli, "INSERT INTO contacts SET contact_name = '$name', contact_title = '$title', contact_department = '$department', contact_email = '$email', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_primary = '$primary', contact_important = '$important', contact_billing = '$billing', contact_technical = '$technical', contact_location_id = $location_id, contact_client_id = $client_id"); // Check insert & get insert ID if ($insert_sql) { diff --git a/api/v1/contacts/update.php b/api/v1/contacts/update.php index 19ae914a..a5049f47 100644 --- a/api/v1/contacts/update.php +++ b/api/v1/contacts/update.php @@ -19,7 +19,7 @@ if (!empty($contact_id)) { require_once 'contact_model.php'; - $update_sql = mysqli_query($mysqli, "UPDATE contacts SET contact_name = '$name', contact_title = '$title', contact_department = '$department', contact_email = '$email', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_important = '$important', contact_billing = '$billing', contact_technical = '$technical', contact_location_id = $location_id, contact_client_id = $client_id WHERE contact_id = $contact_id LIMIT 1"); + $update_sql = mysqli_query($mysqli, "UPDATE contacts SET contact_name = '$name', contact_title = '$title', contact_department = '$department', contact_email = '$email', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_primary = '$primary', contact_important = '$important', contact_billing = '$billing', contact_technical = '$technical', contact_location_id = $location_id, contact_client_id = $client_id WHERE contact_id = $contact_id LIMIT 1"); // Check insert & get insert ID if ($update_sql) {