Journal display

This commit is contained in:
2025-03-13 18:11:19 +00:00
parent c7eddb5465
commit 426c5092ba
2 changed files with 77 additions and 22 deletions

View File

@@ -1,4 +1,3 @@
<!DOCTYPE html>
<html lang="en">
<head>
@@ -227,17 +226,41 @@ function opDetail() {
echo "<p><strong>Outbound To:</strong><span class=\"editable\" data-column=\"out_to\" contenteditable=\"true\">" . $row['out_to'] . "</p>";
echo "<p><strong>ETD:</strong><span class=\"editable\" data-column=\"etd\" contenteditable=\"true\">" . $row['etd'] . "</p>";
echo "<p><strong>Email Address:</strong> " . $row['email'] . "</p>";
echo "<p><strong>Phone:</strong> " . $row['phone'] . "</p>";
echo "<p><strong>Notes:</strong> " . $row['notes'] . "</p>";
echo "<p><i>PPR created at:</strong> " . $row['submitted_dt'] . " by " . $row['created_by'] . "</p></div>";
// Fetch journal entries
$journalSql = "SELECT * FROM journal WHERE ppr_id = " . $_GET['id'];
$journalResult = $conn->query($journalSql);
$journalCount = $journalResult->num_rows;
// Add button to toggle journal entries
echo '<button onclick="toggleJournal()">Show Journal Entries (' . $journalCount . ')</button>';
echo '<div id="journal-entries" style="display:none;">';
echo '<h3>Journal Entries</h3>';
echo '<table class="journal-table">';
echo '<tr><th>Timestamp</th><th>User</th><th>Entry</th></tr>';
if ($journalCount > 0) {
while ($journalRow = $journalResult->fetch_assoc()) {
echo '<tr>';
echo '<td>' . $journalRow['entry_dt'] . '</td>';
echo '<td>' . $journalRow['user'] . '</td>';
echo '<td>' . $journalRow['entry'] . '</td>';
echo '</tr>';
}
} else {
echo '<tr><td colspan="3">No journal entries found.</td></tr>';
}
echo '</table>';
echo '</div>';
echo '</div>';
} else {
echo "No details found for the given ID.";
}
$conn->close();
}
@@ -262,7 +285,44 @@ switch($_GET['op']) {
default:
}
?>
<p><center><button onclick="window.close()">Close Window</button></center>
<script>
function toggleJournal() {
var journalEntries = document.getElementById("journal-entries");
if (journalEntries.style.display === "none") {
journalEntries.style.display = "block";
} else {
journalEntries.style.display = "none";
}
}
</script>
<style>
.journal-table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
.journal-table th, .journal-table td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
.journal-table th {
background-color: #f2f2f2;
color: #333;
}
.journal-table tr:nth-child(even) {
background-color: #f9f9f9;
}
.journal-table tr:hover {
background-color: #f1f1f1;
}
</style>

View File

@@ -1,24 +1,19 @@
<?php
include("functions.php");
// Database connection details
$servername = "sasaprod.pattinson.org";
$username = "root";
$password = "PugPictureMousePen";
$dbname = "pprdevdb";
$created_by = "webhook-dev";
$created_by = "Website (DEV)";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$conn = connectDb();
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
// Check if the URL has a 'test' parameter set
if (isset($_GET['test'])) {
$payload = json_decode(file_get_contents('testhook.json'), true);
} else {
$payload = json_decode(file_get_contents('php://input'), true);
}
// Webhook payload
#$payload = json_decode(file_get_contents('php://input'), true);
$payload = json_decode(file_get_contents('testhook.json'), true);
// Log the received payload for debugging
error_log("Received payload: " . print_r($payload, true));
// Mapping of JSON 'name' keys to database column names
$columnMapping = [
@@ -92,15 +87,15 @@ $stmt->bind_param($types, ...$values);
// Execute the statement
if ($stmt->execute()) {
echo "New record created successfully";
error_log("New record created successfully");
$lastId = $stmt->insert_id;
if (!empty($email)) {
generatePprEmail($lastId, $email, $ac_reg);
} else {
echo "Email is not set.";
error_log("Email is not set.");
}
} else {
echo "Error: " . $stmt->error;
error_log("Error: " . $stmt->error);
}
// Close the connection