| @@ -24,9 +24,9 @@ | ||
| 24 | 24 | $quote_id = isset($_GET['id']) ? intval($_GET['id']) : 0; |
| 25 | 25 | if ($quote_id) { |
| 26 | 26 | $post = get_post($quote_id); |
| 27 | 27 | if (!$post || $post->post_type !== \EasyInvoice\Constants\PostTypes::EASY_INVOICE_QUOTE_POST_TYPE) { |
| 28 | - wp_die(__('Invalid post type. This builder can only be used for quotes.', 'easy-invoice'), __('Invalid Post Type', 'easy-invoice'), array('back_link' => true)); | |
| 28 | + wp_die(esc_html__('That quote does not exist or has been deleted.', 'easy-invoice'), esc_html__('Quote not found', 'easy-invoice'), array('back_link' => true, 'response' => 404)); | |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | $quote = null; |
| 32 | 32 | |
| @@ -48,10 +48,10 @@ | ||
| 48 | 48 | $quote_declined_message = get_option('easy_invoice_quote_declined_message', __('Thank you for your consideration.', 'easy-invoice')); |
| 49 | 49 | |
| 50 | 50 | $quote_data = array( |
| 51 | 51 | 'number' => $quote_number_service ? $quote_number_service->getNextNumber() : 'QT-1', |
| 52 | - 'date' => date('Y-m-d'), | |
| 53 | - 'expiry_date' => date('Y-m-d', strtotime('+30 days')), | |
| 52 | + 'date' => current_time('Y-m-d'), | |
| 53 | + 'expiry_date' => wp_date('Y-m-d', strtotime('+30 days')), | |
| 54 | 54 | 'client_id' => 0, |
| 55 | 55 | 'client_name' => '', |
| 56 | 56 | 'client_email' => '', |
| 57 | 57 | 'client_phone' => '', |
| @@ -79,9 +79,11 @@ | ||
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | 81 | // Get clients from repository |
| 82 | 82 | $client_repository = ClientServiceProvider::getClientRepository(); |
| 83 | -$clients = $client_repository->all(); | |
| 83 | +// The hidden #select-client mirror only needs the document's own client; the picker | |
| 84 | +// searches over AJAX. Loading every client here built a model per user on each open. | |
| 85 | +$clients = []; | |
| 84 | 86 | |
| 85 | 87 | // Load client data directly in PHP if quote has a client |
| 86 | 88 | $client_data = null; |
| 87 | 89 | if ($quote && $quote->getClientId()) { |
| @@ -309,10 +311,10 @@ | ||
| 309 | 311 | }); |
| 310 | 312 | </script> |
| 311 | 313 | |
| 312 | 314 | <form id="quote-form" method="post"> |
| 313 | - <input type="hidden" id="quote-id" name="quote_id" value="<?php echo $quote_id; ?>"> | |
| 314 | - <input type="hidden" id="quote_nonce" name="quote_nonce" value="<?php echo wp_create_nonce('easy_invoice_nonce'); ?>"> | |
| 315 | + <input type="hidden" id="quote-id" name="quote_id" value="<?php echo (int) $quote_id; ?>"> | |
| 316 | + <input type="hidden" id="quote_nonce" name="quote_nonce" value="<?php echo esc_attr(wp_create_nonce('easy_invoice_nonce')); ?>"> | |
| 315 | 317 | |
| 316 | 318 | <div id="easy-invoice-content" class="h-screen flex flex-col bg-gray-50"> |
| 317 | 319 | <header class="ei-quote-builder-header ei-app-header-sync bg-white border-b border-gray-200 shadow-sm w-full z-10 box-border"> |
| 318 | 320 | <div class="max-w-full mx-auto h-full px-4 sm:px-5"> |