Compare commits
2 Commits
c7eddb5465
...
9c77d8ffb0
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c77d8ffb0 | |||
| 426c5092ba |
81
action.php
81
action.php
@@ -1,4 +1,3 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -80,16 +79,12 @@
|
||||
.editable:hover {
|
||||
background:rgb(226, 43, 43);
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
let id = "<?php echo $_GET['id'];?>";
|
||||
|
||||
@@ -227,17 +222,42 @@ 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 '<br><button onclick="window.close()">Close Window</button>';
|
||||
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 +282,46 @@ switch($_GET['op']) {
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<p><center><button onclick="window.close()">Close Window</button></center>
|
||||
|
||||
<script>
|
||||
function toggleJournal() {
|
||||
var journalEntries = document.getElementById("journal-entries");
|
||||
var toggleButton = document.querySelector("button[onclick='toggleJournal()']");
|
||||
if (journalEntries.style.display === "none") {
|
||||
journalEntries.style.display = "block";
|
||||
toggleButton.textContent = "Hide Journal Entries";
|
||||
} else {
|
||||
journalEntries.style.display = "none";
|
||||
toggleButton.textContent = "Show Journal Entries";
|
||||
}
|
||||
}
|
||||
</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>
|
||||
|
||||
|
||||
29
webhook.php
29
webhook.php
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user