| Server IP : 13.126.101.145 / Your IP : 216.73.217.47 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.3.17 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/rentals_updated/wp-content/plugins/woocommerce-rfq/ |
Upload File : |
<?php
// Ensure this is being run within the WordPress environment
if (!defined('ABSPATH')) {
exit;
}
function add_quotes_revision_details_page() {
add_submenu_page(
null, // Null to hide it from the menu
'Quotes Revision Details', // Page title
'Quotes Revision Details', // Menu title
'manage_options', // Capability
'quotes-revision-details', // Menu slug
'render_quotes_revision_details_page' // Function to display the page content
);
}
add_action('admin_menu', 'add_quotes_revision_details_page');
function render_quotes_revision_details_page() {
global $wpdb;
if (!isset($_GET['id'])) {
echo '<p>No quotation ID provided.</p>';
return;
}
$quote_id = intval($_GET['id']);
$table_name = $wpdb->prefix . 'quotation';
// Fetch the revision details for the quotation
$quotation = $wpdb->get_row($wpdb->prepare("SELECT revision_details FROM $table_name WHERE id = %d", $quote_id));
if (!$quotation || empty($quotation->revision_details)) {
echo '<br><p>No Revision Details Found for the Quotation.</p>';
echo '<a href="admin.php?page=edit-quotation&id=' . $quote_id . '" class="button">Back to Edit Quotation</a>';
return;
}
// Decode the JSON-encoded revision details
$revision_details = json_decode($quotation->revision_details, true);
if (empty($revision_details)) {
echo '<p>No revision details found for this quotation.</p>';
return;
}
echo '<div style="margin-top: 3%;">'; // Start of the div with margin
echo '<h2>Revision Details for Quotation ID ' . $quote_id . '</h2>';
// Add a Back button that redirects to the edit-quotation page
echo '<a href="admin.php?page=edit-quotation&id=' . $quote_id . '" class="button">Back to Edit Quotation</a>';
echo '<table class="widefat" cellspacing="0">';
echo '<thead><tr>';
echo '<th>Version</th>'; // New Version column
echo '<th>Date</th>';
echo '<th>Revised By</th>';
echo '<th>Final Price</th>';
echo '<th>Discount</th>';
// echo '<th>Status</th>';
echo '</tr></thead>';
echo '<tbody>';
// Initialize version counter
$version_counter = 1;
// Loop through the revisions and display them
foreach ($revision_details as $revision) {
echo '<tr>';
// Display the version number with leading zeros
echo '<td>' . str_pad($version_counter, 3, '0', STR_PAD_LEFT) . '</td>';
echo '<td>' . esc_html($revision['revision_date']) . '</td>';
echo '<td>' . esc_html($revision['revised_by']) . '</td>';
echo '<td>' . esc_html($revision['final_price']) . '</td>';
echo '<td>' . esc_html($revision['discount']) . '</td>';
// echo '<td>' . esc_html($revision['status']) . '</td>';
echo '</tr>';
// Increment version counter
$version_counter++;
}
echo '</tbody>';
echo '</table>';
echo '</div>'; // End of the div with margin
}
?>