From 3b3e6a016646964e38fd1612d9802296d0087e1d Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 28 Aug 2021 16:07:31 -0400 Subject: [PATCH] UI Update on Trip Forms contact forms and location forms also Contact / Location under add /edit contact now add or edit the primary location and contact --- add_account_modal.php | 2 +- add_client_modal.php | 2 +- add_contact_modal.php | 2 +- add_location_modal.php | 2 +- add_trip_copy_modal.php | 12 ++++++------ add_trip_modal.php | 15 +++++++-------- clients.php | 2 ++ edit_account_modal.php | 2 +- edit_client_modal.php | 24 +++++++++++++----------- edit_contact_modal.php | 2 +- edit_location_modal.php | 2 +- edit_trip_modal.php | 12 ++++++------ post.php | 19 +++++++++++++++++++ 13 files changed, 60 insertions(+), 38 deletions(-) diff --git a/add_account_modal.php b/add_account_modal.php index 1ec87d93..1dd0e518 100644 --- a/add_account_modal.php +++ b/add_account_modal.php @@ -47,7 +47,7 @@
- +
diff --git a/add_client_modal.php b/add_client_modal.php index 4ad6c1b9..d6b2c7ab 100644 --- a/add_client_modal.php +++ b/add_client_modal.php @@ -260,7 +260,7 @@
- +
diff --git a/add_contact_modal.php b/add_contact_modal.php index 825e3f06..da27824a 100644 --- a/add_contact_modal.php +++ b/add_contact_modal.php @@ -40,7 +40,7 @@
- +
diff --git a/add_location_modal.php b/add_location_modal.php index acb879e3..0cfd7339 100644 --- a/add_location_modal.php +++ b/add_location_modal.php @@ -33,7 +33,7 @@
- +
diff --git a/add_trip_copy_modal.php b/add_trip_copy_modal.php index 92ba0980..d7ae1d04 100644 --- a/add_trip_copy_modal.php +++ b/add_trip_copy_modal.php @@ -29,6 +29,11 @@
+
+
+ > +
+
@@ -49,7 +54,7 @@
- +
@@ -88,11 +93,6 @@ -
- class="custom-control-input" id="customControlAutosizingCopy" name="roundtrip" value="1" > - -
-
diff --git a/clients.php b/clients.php index 4f32b8ac..297d8f93 100644 --- a/clients.php +++ b/clients.php @@ -167,6 +167,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $client_id = $row['client_id']; $client_name = $row['client_name']; $client_type = $row['client_type']; + $location_id = $row['location_id']; $location_country = $row['location_country']; $location_address = $row['location_address']; $location_city = $row['location_city']; @@ -177,6 +178,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); }else{ $location_address_display = "$location_address
$location_city $location_state $location_zip"; } + $contact_id = $row['contact_id']; $contact_name = $row['contact_name']; $contact_phone = $row['contact_phone']; if(strlen($client_phone)>2){ diff --git a/edit_account_modal.php b/edit_account_modal.php index 77ac817e..db4d102d 100644 --- a/edit_account_modal.php +++ b/edit_account_modal.php @@ -23,7 +23,7 @@
- +
diff --git a/edit_client_modal.php b/edit_client_modal.php index c4adca1d..e9b5acd3 100644 --- a/edit_client_modal.php +++ b/edit_client_modal.php @@ -9,6 +9,8 @@ + + @@ -141,7 +143,7 @@
- + @@ -154,7 +156,7 @@ @@ -166,7 +168,7 @@
- + @@ -179,7 +181,7 @@ @@ -195,7 +197,7 @@
- + @@ -207,12 +209,12 @@
- +
- +
@@ -222,7 +224,7 @@
- + @@ -232,7 +234,7 @@
- + @@ -251,7 +253,7 @@
- +
diff --git a/edit_contact_modal.php b/edit_contact_modal.php index 64c2d372..c5ca27ef 100644 --- a/edit_contact_modal.php +++ b/edit_contact_modal.php @@ -42,7 +42,7 @@
- +
diff --git a/edit_location_modal.php b/edit_location_modal.php index 8d3b781c..3a382553 100644 --- a/edit_location_modal.php +++ b/edit_location_modal.php @@ -35,7 +35,7 @@
- +
diff --git a/edit_trip_modal.php b/edit_trip_modal.php index 52b35e05..6a151702 100644 --- a/edit_trip_modal.php +++ b/edit_trip_modal.php @@ -30,6 +30,11 @@
+
+
+ > +
+
@@ -56,12 +61,7 @@
- -
- -
- class="custom-control-input" id="customControlAutosizingEdit" name="roundtrip" value="1" > - +
diff --git a/post.php b/post.php index 0d05de89..e4622393 100644 --- a/post.php +++ b/post.php @@ -740,6 +740,8 @@ if(isset($_POST['add_client'])){ if(isset($_POST['edit_client'])){ $client_id = intval($_POST['client_id']); + $location_id = intval($_POST['location_id']); + $contact_id = intval($_POST['contact_id']); $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type']))); $support = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['support']))); @@ -764,6 +766,23 @@ if(isset($_POST['edit_client'])){ //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Client', log_action = 'Modified', log_description = '$name', log_created_at = NOW(), client_id = $client_id, company_id = $session_company_id, log_user_id = $session_user_id"); + //Edit Primary Location + if($location_id > 0){ + mysqli_query($mysqli,"UPDATE locations SET location_address = '$address', location_city = '$city', location_state = '$state', location_zip = '$zip', location_country = '$country', location_updated_at = NOW() WHERE location_id = $location_id"); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Location', log_action = 'Modified', log_description = 'Primary Location $address', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id"); + } + + //Edit Primary Contact + if($contact_id > 0){ + mysqli_query($mysqli,"UPDATE contacts SET contact_name = '$contact', contact_title = '$title', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_email = '$email', contact_updated_at = NOW() WHERE contact_id = $contact_id"); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Modified', log_description = 'Primary Contact $contact', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id"); + + } + $_SESSION['alert_message'] = "Client $name updated"; header("Location: " . $_SERVER["HTTP_REFERER"]);