diff --git a/portal/contact_edit.php b/portal/contact_edit.php new file mode 100644 index 00000000..e187cc94 --- /dev/null +++ b/portal/contact_edit.php @@ -0,0 +1,114 @@ +set('URI.AllowedSchemes', ['data' => true, 'src' => true, 'http' => true, 'https' => true]); +$purifier = new HTMLPurifier($purifier_config); + +// Check for a contact ID +if (!isset($_GET['id']) && !intval($_GET['id'])) { + header("Location: contacts.php"); + exit(); +} + +$contact_id = intval($_GET['id']); + +$sql_contact = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_email, contact_primary, contact_technical, contact_billing, contact_auth_method FROM contacts WHERE contact_id = $contact_id AND contact_client_id = $session_client_id AND contacts.contact_archived_at IS NULL LIMIT 1"); + +$row = mysqli_fetch_array($sql_contact); + +if ($row) { + $contact_id = intval($row['contact_id']); + $contact_name = nullable_htmlentities($row['contact_name']); + $contact_email = nullable_htmlentities($row['contact_email']); + $contact_primary = intval($row['contact_primary']); + $contact_technical = intval($row['contact_technical']); + $contact_billing = intval($row['contact_billing']); +} else { + header("Location: portal_post.php?logout"); + exit(); +} + +?> + + + +
+
+ + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ + +
+
+
+
+ > + +
+
+
+
+
+
+ > + +
+
+
+
+ + Cannot edit the primary contact"; } else { ?> + + +
+
+ + + - + diff --git a/portal/document.php b/portal/document.php index d007e9de..16b39ac0 100644 --- a/portal/document.php +++ b/portal/document.php @@ -27,16 +27,31 @@ if (!isset($_GET['id']) && !intval($_GET['id'])) { } $document_id = intval($_GET['id']); -$sql_document = mysqli_query($mysqli, "SELECT document_id, document_name, document_content FROM documents WHERE document_id = $document_id AND document_client_id = $session_client_id AND document_template = 0 LIMIT 1"); +$sql_document = mysqli_query($mysqli, "SELECT document_id, document_name, document_content FROM documents WHERE document_id = $document_id AND document_client_id = $session_client_id AND document_template = 0 AND document_archived_at IS NULL LIMIT 1"); $row = mysqli_fetch_array($sql_document); -$document_id = intval($row['document_id']); -$document_name = nullable_htmlentities($row['document_name']); -$document_content = $purifier->purify($row['document_content']); +if ($row) { + $document_id = intval($row['document_id']); + $document_name = nullable_htmlentities($row['document_name']); + $document_content = $purifier->purify($row['document_content']); +} else { + header("Location: portal_post.php?logout"); + exit(); +} ?> + +

diff --git a/portal/portal_header.php b/portal/portal_header.php index 524e2108..b141dc4a 100644 --- a/portal/portal_header.php +++ b/portal/portal_header.php @@ -112,3 +112,22 @@ header("X-Frame-Options: DENY"); // Legacy
+ + +
+ + +
+ diff --git a/portal/portal_post.php b/portal/portal_post.php index 2fb50ae0..97e9e393 100644 --- a/portal/portal_post.php +++ b/portal/portal_post.php @@ -287,3 +287,20 @@ if (isset($_POST['edit_profile'])) { } header('Location: index.php'); } + +if (isset($_POST['edit_contact'])) { + $contact_id = intval($_POST['contact_id']); + $contact_name = sanitizeInput($_POST['contact_name']); + $contact_email = sanitizeInput($_POST['contact_email']); + $contact_technical = intval($_POST['contact_technical']); + $contact_billing = intval($_POST['contact_billing']); + + mysqli_query($mysqli, "UPDATE contacts SET contact_name = '$contact_name', contact_email = '$contact_email', contact_billing = $contact_billing, contact_technical = $contact_technical WHERE contact_id = $contact_id AND contact_client_id = $session_client_id AND contact_archived_at IS NULL AND contact_primary = 0"); + + // Logging + mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Contact', log_action = 'Modify', log_description = 'Client $session_contact_name modified contact $contact_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $session_client_id, log_entity_id = $contact_id"); + + $_SESSION['alert_message'] = "Contact updated"; + header('Location: contacts.php'); + +} \ No newline at end of file diff --git a/portal/ticket_add.php b/portal/ticket_add.php index b2022df4..8993a6a3 100644 --- a/portal/ticket_add.php +++ b/portal/ticket_add.php @@ -18,7 +18,7 @@ require_once 'inc_portal.php'; -

Raise a new ticket

+

Raise a new ticket