From 5d269368f62d277437647c3559e810caff00fce6 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Thu, 26 Jan 2023 13:34:13 +0000 Subject: [PATCH] Update contact API to support contact_import, contact_billing, contact_technical --- api/v1/contacts/contact_model.php | 7 +++++-- api/v1/contacts/create.php | 4 ++-- api/v1/contacts/update.php | 6 +++--- client_contact_details.php | 12 ++++++------ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/api/v1/contacts/contact_model.php b/api/v1/contacts/contact_model.php index dc3ecdda..f38320c1 100644 --- a/api/v1/contacts/contact_model.php +++ b/api/v1/contacts/contact_model.php @@ -4,10 +4,13 @@ define('number_regex', '/[^0-9]/'); $name = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_name']))); $title = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_title']))); $department = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_department']))); +$email = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_email']))); $phone = preg_replace(number_regex, '', $_POST['contact_phone']); $extension = preg_replace(number_regex, '', $_POST['contact_extension']); $mobile = preg_replace(number_regex, '', $_POST['contact_mobile']); -$email = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_email']))); $notes = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_notes']))); $auth_method = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_auth_method']))); -$location_id = intval($_POST['contact_location_id']); \ No newline at end of file +$important = intval($_POST['contact_important']); +$billing = intval($_POST['contact_billing']); +$technical = intval($_POST['contact_technical']); +$location_id = intval($_POST['contact_location_id']); diff --git a/api/v1/contacts/create.php b/api/v1/contacts/create.php index 0764fc74..eeb5640c 100644 --- a/api/v1/contacts/create.php +++ b/api/v1/contacts/create.php @@ -17,7 +17,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_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_email = '$email', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_created_at = NOW(), contact_department = '$department', contact_location_id = $location_id, contact_client_id = $client_id, company_id = $company_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_important = '$important', contact_billing = '$billing', contact_technical = '$technical', contact_created_at = NOW(), contact_location_id = $location_id, contact_client_id = $client_id, company_id = $company_id"); // Check insert & get insert ID if ($insert_sql) { @@ -31,4 +31,4 @@ if (!empty($name) && !empty($email) && !empty($client_id)) { } // Output -require_once('../create_output.php'); \ No newline at end of file +require_once('../create_output.php'); diff --git a/api/v1/contacts/update.php b/api/v1/contacts/update.php index eeac3407..ed5a56db 100644 --- a/api/v1/contacts/update.php +++ b/api/v1/contacts/update.php @@ -12,7 +12,7 @@ $update_count = FALSE; if (!empty($name) && !empty($email)) { - $update_sql = mysqli_query($mysqli, "UPDATE contacts SET contact_name = '$name', contact_title = '$title', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_email = '$email', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_updated_at = NOW(), contact_department_id = $department, contact_location_id = $location_id, contact_client_id = $client_id, company_id = $company_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_important = '$important', contact_billing = '$billing', contact_technical = '$technical', contact_updated_at = NOW(), contact_location_id = $location_id, contact_client_id = $client_id, company_id = $company_id WHERE contact_id = $contact_id LIMIT 1"); // Check insert & get insert ID if ($update_sql) { @@ -21,8 +21,8 @@ if (!empty($name) && !empty($email)) { //Logging mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Contact', log_action = 'Updated', log_description = '$name via API ($api_key_name)', log_ip = '$ip', log_created_at = NOW(), log_client_id = $client_id, company_id = $company_id"); mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'API', log_action = 'Success', log_description = 'Updated contact $name via API ($api_key_name)', log_ip = '$ip', log_created_at = NOW(), log_client_id = $client_id, company_id = $company_id"); - } + } else {var_dump( $update_sql);} } // Output -require_once('../update_output.php'); \ No newline at end of file +require_once('../update_output.php'); diff --git a/client_contact_details.php b/client_contact_details.php index 769512b1..464de3ca 100644 --- a/client_contact_details.php +++ b/client_contact_details.php @@ -68,7 +68,7 @@ if (isset($_GET['contact_id'])) {
-
+
contact_photo"> @@ -86,7 +86,7 @@ if (isset($_GET['contact_id'])) {
-
+
@@ -381,7 +381,7 @@ if (isset($_GET['contact_id'])) { ">Delete
-
+ @@ -440,11 +440,11 @@ if (isset($_GET['contact_id'])) { include("client_software_edit_modal.php"); } - + ?> - +