From 62f86df80eaef13211c4ab921a3df0685818659c Mon Sep 17 00:00:00 2001 From: root Date: Fri, 22 Mar 2019 01:32:34 -0400 Subject: [PATCH] Added edit notes, and added a bunch of delete functionality, fixed edit categories not showing correct type --- accounts.php | 2 +- categories.php | 2 +- client_assets.php | 2 +- client_contacts.php | 2 +- client_invoices.php | 2 +- client_locations.php | 2 +- client_logins.php | 2 +- client_notes.php | 4 +- client_vendors.php | 2 +- clients.php | 2 +- edit_category_modal.php | 2 +- edit_client_note_modal.php | 34 ++++++++ expenses.php | 2 +- invoices.php | 2 +- mileage.php | 2 +- post.php | 168 +++++++++++++++++++++++++++++++++++++ transfers.php | 2 +- 17 files changed, 218 insertions(+), 16 deletions(-) create mode 100644 edit_client_note_modal.php diff --git a/accounts.php b/accounts.php index 3f8df274..db38b9df 100644 --- a/accounts.php +++ b/accounts.php @@ -46,7 +46,7 @@ diff --git a/categories.php b/categories.php index c9c10d91..f3322f35 100644 --- a/categories.php +++ b/categories.php @@ -36,7 +36,7 @@ diff --git a/client_assets.php b/client_assets.php index 8db121a0..cce2a2fe 100644 --- a/client_assets.php +++ b/client_assets.php @@ -35,7 +35,7 @@ diff --git a/client_contacts.php b/client_contacts.php index ab7e8571..64af87dc 100644 --- a/client_contacts.php +++ b/client_contacts.php @@ -37,7 +37,7 @@ diff --git a/client_invoices.php b/client_invoices.php index 1bdfc882..4e3be727 100644 --- a/client_invoices.php +++ b/client_invoices.php @@ -44,7 +44,7 @@ Edit Copy PDF - Delete + Delete diff --git a/client_locations.php b/client_locations.php index aa89616d..e0e78f81 100644 --- a/client_locations.php +++ b/client_locations.php @@ -37,7 +37,7 @@ diff --git a/client_logins.php b/client_logins.php index 2bc3f803..47ae7981 100644 --- a/client_logins.php +++ b/client_logins.php @@ -31,7 +31,7 @@ diff --git a/client_notes.php b/client_notes.php index 0101c415..9a9c9e56 100644 --- a/client_notes.php +++ b/client_notes.php @@ -27,8 +27,8 @@ diff --git a/client_vendors.php b/client_vendors.php index fd5f99b5..15097a2c 100644 --- a/client_vendors.php +++ b/client_vendors.php @@ -28,7 +28,7 @@ diff --git a/clients.php b/clients.php index 1736450c..f1012174 100644 --- a/clients.php +++ b/clients.php @@ -59,7 +59,7 @@ diff --git a/edit_category_modal.php b/edit_category_modal.php index 29477ae2..a112ad7f 100644 --- a/edit_category_modal.php +++ b/edit_category_modal.php @@ -16,7 +16,7 @@
diff --git a/edit_client_note_modal.php b/edit_client_note_modal.php new file mode 100644 index 00000000..6337c2e4 --- /dev/null +++ b/edit_client_note_modal.php @@ -0,0 +1,34 @@ + \ No newline at end of file diff --git a/expenses.php b/expenses.php index 7cf5f058..7446b361 100644 --- a/expenses.php +++ b/expenses.php @@ -59,7 +59,7 @@ Edit Copy Refund - Delete + Delete
diff --git a/invoices.php b/invoices.php index 35d37bbc..c33975bf 100644 --- a/invoices.php +++ b/invoices.php @@ -57,7 +57,7 @@ Edit Copy PDF - Delete + Delete diff --git a/mileage.php b/mileage.php index f3dd5c55..f2e5fff3 100644 --- a/mileage.php +++ b/mileage.php @@ -46,7 +46,7 @@ diff --git a/post.php b/post.php index d14cbc0f..e5e78fdf 100644 --- a/post.php +++ b/post.php @@ -47,6 +47,17 @@ if(isset($_POST['edit_client'])){ } +if(isset($_GET['delete_client'])){ + $client_id = intval($_GET['delete_client']); + + mysqli_query($mysqli,"DELETE FROM clients WHERE client_id = $client_id"); + + $_SESSION['alert_message'] = "Client deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_vendor'])){ $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); @@ -88,6 +99,17 @@ if(isset($_POST['edit_vendor'])){ } +if(isset($_GET['delete_vendor'])){ + $vendor_id = intval($_GET['delete_vendor']); + + mysqli_query($mysqli,"DELETE FROM vendors WHERE vendor_id = $vendor_id"); + + $_SESSION['alert_message'] = "Vendor deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_mileage'])){ $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); @@ -121,6 +143,17 @@ if(isset($_POST['edit_mileage'])){ } +if(isset($_GET['delete_mileage'])){ + $mileage_id = intval($_GET['delete_mileage']); + + mysqli_query($mysqli,"DELETE FROM mileage WHERE mileage_id = $mileage_id"); + + $_SESSION['alert_message'] = "Mileage deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_account'])){ $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); @@ -147,6 +180,17 @@ if(isset($_POST['edit_account'])){ } +if(isset($_GET['delete_account'])){ + $account_id = intval($_GET['delete_account']); + + mysqli_query($mysqli,"DELETE FROM accounts WHERE account_id = $account_id"); + + $_SESSION['alert_message'] = "Account deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_category'])){ $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); @@ -174,6 +218,17 @@ if(isset($_POST['edit_category'])){ } +if(isset($_GET['delete_category'])){ + $category_id = intval($_GET['delete_category']); + + mysqli_query($mysqli,"DELETE FROM categories WHERE category_id = $category_id"); + + $_SESSION['alert_message'] = "Category deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_expense'])){ $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); @@ -209,6 +264,17 @@ if(isset($_POST['edit_expense'])){ } +if(isset($_GET['delete_expense'])){ + $expense_id = intval($_GET['delete_expense']); + + mysqli_query($mysqli,"DELETE FROM expenses WHERE expense_id = $expense_id"); + + $_SESSION['alert_message'] = "Expense deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_transfer'])){ $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); @@ -240,6 +306,17 @@ if(isset($_POST['edit_transfer'])){ } +if(isset($_GET['delete_transfer'])){ + $transfer_id = intval($_GET['delete_transfer']); + + mysqli_query($mysqli,"DELETE FROM transfers WHERE transfer_id = $transfer_id"); + + $_SESSION['alert_message'] = "Transfer deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_invoice'])){ $client = intval($_POST['client']); @@ -259,6 +336,17 @@ if(isset($_POST['add_invoice'])){ } +if(isset($_GET['delete_invoice'])){ + $invoice_id = intval($_GET['delete_invoice']); + + mysqli_query($mysqli,"DELETE FROM invoices WHERE invoice_id = $invoice_id"); + + $_SESSION['alert_message'] = "Invoice deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_invoice_item'])){ $invoice_id = intval($_POST['invoice_id']); @@ -396,6 +484,17 @@ if(isset($_POST['edit_client_contact'])){ } +if(isset($_GET['delete_client_contact'])){ + $client_contact_id = intval($_GET['delete_client_contact']); + + mysqli_query($mysqli,"DELETE FROM client_contacts WHERE client_contact_id = $client_contact_id"); + + $_SESSION['alert_message'] = "Contact deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_client_location'])){ $client_id = intval($_POST['client_id']); @@ -434,6 +533,17 @@ if(isset($_POST['edit_client_location'])){ } +if(isset($_GET['delete_client_location'])){ + $client_location_id = intval($_GET['delete_client_location']); + + mysqli_query($mysqli,"DELETE FROM client_locations WHERE client_location_id = $client_location_id"); + + $_SESSION['alert_message'] = "Location deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_client_asset'])){ $client_id = intval($_POST['client_id']); @@ -470,6 +580,17 @@ if(isset($_POST['edit_client_asset'])){ } +if(isset($_GET['delete_client_asset'])){ + $client_asset_id = intval($_GET['delete_client_asset']); + + mysqli_query($mysqli,"DELETE FROM client_assets WHERE client_asset_id = $client_asset_id"); + + $_SESSION['alert_message'] = "Asset deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_client_vendor'])){ $client_id = intval($_POST['client_id']); @@ -500,6 +621,17 @@ if(isset($_POST['edit_client_vendor'])){ } +if(isset($_GET['delete_client_vendor'])){ + $client_vendor_id = intval($_GET['delete_client_vendor']); + + mysqli_query($mysqli,"DELETE FROM client_vendors WHERE client_vendor_id = $client_vendor_id"); + + $_SESSION['alert_message'] = "Vendor deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_client_login'])){ $client_id = intval($_POST['client_id']); @@ -532,6 +664,17 @@ if(isset($_POST['edit_client_login'])){ } +if(isset($_GET['delete_client_login'])){ + $client_login_id = intval($_GET['delete_client_login']); + + mysqli_query($mysqli,"DELETE FROM client_logins WHERE client_login_id = $client_login_id"); + + $_SESSION['alert_message'] = "Login deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_client_note'])){ $client_id = intval($_POST['client_id']); @@ -546,6 +689,31 @@ if(isset($_POST['add_client_note'])){ } +if(isset($_POST['edit_client_note'])){ + + $client_note_id = intval($_POST['client_note_id']); + $subject = strip_tags(mysqli_real_escape_string($mysqli,$_POST['subject'])); + $note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['note'])); + + mysqli_query($mysqli,"UPDATE client_notes SET client_note_subject = '$subject', client_note_body = '$note' WHERE client_note_id = $client_note_id"); + + $_SESSION['alert_message'] = "Note updated"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + +if(isset($_GET['delete_client_note'])){ + $client_note_id = intval($_GET['delete_client_note']); + + mysqli_query($mysqli,"DELETE FROM client_notes WHERE client_note_id = $client_note_id"); + + $_SESSION['alert_message'] = "Note deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_user'])){ $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); $password = mysqli_real_escape_string($mysqli,$_POST['password']); diff --git a/transfers.php b/transfers.php index 6dd42eab..2d22c2a3 100644 --- a/transfers.php +++ b/transfers.php @@ -55,7 +55,7 @@ $sql = mysqli_query($mysqli,"SELECT * FROM transfers ORDER BY transfers.transfer