From ef7bfd3c90a5658468a8cfa489551a146616b598 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Thu, 19 Aug 2021 12:25:32 -0400 Subject: [PATCH] Introduced Custom Extenal Links on main side Nav DB Structure updated Thanks @aftechno --- add_custom_link_modal.php | 52 ++++++++++++++ client_logins.php | 2 +- custom_links.php | 136 +++++++++++++++++++++++++++++++++++++ db.sql | 21 +++++- edit_custom_link_modal.php | 53 +++++++++++++++ post.php | 52 ++++++++++++++ side_nav.php | 47 +++++++++++++ 7 files changed, 361 insertions(+), 2 deletions(-) create mode 100644 add_custom_link_modal.php create mode 100644 custom_links.php create mode 100644 edit_custom_link_modal.php diff --git a/add_custom_link_modal.php b/add_custom_link_modal.php new file mode 100644 index 00000000..59bffc62 --- /dev/null +++ b/add_custom_link_modal.php @@ -0,0 +1,52 @@ + \ No newline at end of file diff --git a/client_logins.php b/client_logins.php index fd0674e6..7ec79b83 100644 --- a/client_logins.php +++ b/client_logins.php @@ -120,7 +120,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); - + diff --git a/custom_links.php b/custom_links.php new file mode 100644 index 00000000..2cf833d7 --- /dev/null +++ b/custom_links.php @@ -0,0 +1,136 @@ + $sb, 'o' => $o))); + +$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM custom_links + WHERE custom_link_name LIKE '%$q%' + AND company_id = $session_company_id + ORDER BY $sb $o LIMIT $record_from, $record_to" +); + +$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); + +?> + + +
+
+

Custom Links

+
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ + "> + + + + + + + + "; + }else{ + $custom_link_icon_display = ""; + } + $custom_link_url = $row['custom_link_url']; + + ?> + + + + + + + + + +
NameURLAction
+ +
+
+ +
+
+ + \ No newline at end of file diff --git a/db.sql b/db.sql index e3d3bdab..1ef508ae 100644 --- a/db.sql +++ b/db.sql @@ -266,6 +266,25 @@ CREATE TABLE `contracts` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `custom_links` +-- + +DROP TABLE IF EXISTS `custom_links`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `custom_links` ( + `custom_link_id` int(11) NOT NULL AUTO_INCREMENT, + `custom_link_name` varchar(250) NOT NULL, + `custom_link_icon` varchar(100) DEFAULT NULL, + `custom_link_url` varchar(250) NOT NULL, + `custom_link_order` int(11) DEFAULT NULL, + `custom_link_created_at` datetime NOT NULL, + `company_id` int(11) NOT NULL, + PRIMARY KEY (`custom_link_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `documents` -- @@ -1011,4 +1030,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-18 22:52:05 +-- Dump completed on 2021-08-19 12:24:33 diff --git a/edit_custom_link_modal.php b/edit_custom_link_modal.php new file mode 100644 index 00000000..b42b02a4 --- /dev/null +++ b/edit_custom_link_modal.php @@ -0,0 +1,53 @@ + \ No newline at end of file diff --git a/post.php b/post.php index c9695cd3..1e16d119 100644 --- a/post.php +++ b/post.php @@ -1482,6 +1482,58 @@ if(isset($_GET['delete_tax'])){ //End Tax +//Custom Link +if(isset($_POST['add_custom_link'])){ + + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $icon = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['icon']))); + $url = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['url']))); + + mysqli_query($mysqli,"INSERT INTO custom_links SET custom_link_name = '$name', custom_link_icon = '$icon', custom_link_url = '$url', custom_link_created_at = NOW(), company_id = $session_company_id"); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Custom Link', log_action = 'Created', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id"); + + $_SESSION['alert_message'] = "Custom link added"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + +if(isset($_POST['edit_custom_link'])){ + + $custom_link_id = intval($_POST['custom_link_id']); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $icon = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['icon']))); + $url = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['url']))); + + mysqli_query($mysqli,"UPDATE custom_links SET custom_link_name = '$name', custom_link_icon = '$icon', custom_link_url = '$url' WHERE custom_link_id = $custom_link_id AND company_id = $session_company_id"); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Custom Link', log_action = 'Modified', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id"); + + $_SESSION['alert_message'] = "Custom link modified"; + + header("Location: custom_links.php"); + +} + +if(isset($_GET['delete_custom_link'])){ + $custom_link_id = intval($_GET['delete_custom_link']); + + mysqli_query($mysqli,"DELETE FROM custom_links WHERE custom_link_id = $custom_link_id AND company_id = $session_company_id"); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Custom Link', log_action = 'Deleted', log_description = '$custom_link_id', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id"); + + $_SESSION['alert_message'] = "Custom link deleted"; + $_SESSION['alert_type'] = "danger"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} +//End Custom Link + if(isset($_GET['alert_ack'])){ $alert_id = intval($_GET['alert_ack']); diff --git a/side_nav.php b/side_nav.php index 5bc86dc0..c8765c60 100644 --- a/side_nav.php +++ b/side_nav.php @@ -209,6 +209,12 @@

Categories

+ + + + + + + +