PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.0
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.0
2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.2 All 57 releases
easy-invoice / templates / quotes / preview.php

preview.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.4.0, at templates/quotes/preview.php

304 lines 7.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Quote Preview Template
4 *
5 * @package EasyInvoice
6 * @since 1.0.0
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12 // Get quote data
13 $quote_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
14 $quote = $quote ?? null;
15
16 if ($quote_id <= 0 || !$quote) {
17 wp_die(esc_html__('Quote not found.', 'easy-invoice'));
18 }
19
20 // Initialize formatter for currency formatting
21 $formatter = $quote ? new \EasyInvoice\Helpers\QuoteFormatter($quote) : null;
22
23 // Get the current template (default to 'standard')
24 $current_template = $quote && method_exists($quote, 'getTemplate') ? $quote->getTemplate() : 'standard';
25 if (empty($current_template)) {
26 $current_template = 'standard';
27 }
28
29 // Get company information from settings
30 $company_name = get_option('easy_invoice_company_name', 'Your Company Name');
31 $company_address = get_option('easy_invoice_company_address', 'Your Company Address');
32 $company_email = get_option('easy_invoice_company_email', 'info@yourcompany.com');
33 $company_phone = get_option('easy_invoice_company_phone', '+1 (555) 123-4567');
34 $company_website = get_option('easy_invoice_company_website', 'www.yourcompany.com');
35
36 ?>
37 <!DOCTYPE html>
38 <html lang="en">
39 <head>
40 <meta charset="UTF-8">
41 <meta name="viewport" content="width=device-width, initial-scale=1.0">
42 <title>Quote <?php echo $quote ? esc_html($quote->getNumber()) : 'Unknown'; ?></title>
43
44 <?php
45 // Bundled locally (wp.org requires all assets to ship inside the plugin)
46 // and printed through the script registry so filters and dependencies apply.
47 if ( ! wp_script_is( 'jspdf', 'registered' ) ) {
48 wp_register_script( 'jspdf', EASY_INVOICE_PLUGIN_URL . 'assets/js/vendors/jspdf.umd.min.js', [], '2.5.1', false );
49 }
50 wp_print_scripts( [ 'jspdf' ] );
51 ?>
52
53 <style>
54 * {
55 margin: 0;
56 padding: 0;
57 box-sizing: border-box;
58 }
59
60 body {
61 font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
62 line-height: 1.6;
63 color: #333;
64 background: #f8f9fa;
65 }
66
67 .quote-container {
68 max-width: 800px;
69 margin: 20px auto;
70 background: white;
71 box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
72 border-radius: 8px;
73 overflow: hidden;
74
75 }
76
77 .quote-header {
78 background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
79 color: white;
80 padding: 30px;
81 text-align: center;
82 }
83
84 .quote-header h1 {
85 font-size: 2.5rem;
86 font-weight: 300;
87 margin-bottom: 10px;
88 }
89
90 .quote-header .quote-number {
91 font-size: 1.2rem;
92 opacity: 0.9;
93 }
94
95 .quote-content {
96 padding: 40px;
97 }
98
99 .company-info {
100 display: flex;
101 justify-content: space-between;
102 margin-bottom: 40px;
103 padding-bottom: 20px;
104 border-bottom: 2px solid #e9ecef;
105 }
106
107 .company-details h2 {
108 color: #495057;
109 font-size: 1.5rem;
110 margin-bottom: 10px;
111 }
112
113 .company-details p {
114 color: #6c757d;
115 margin-bottom: 5px;
116 }
117
118 .client-info h3 {
119 color: #495057;
120 font-size: 1.2rem;
121 margin-bottom: 10px;
122 }
123
124 .client-info p {
125 color: #6c757d;
126 margin-bottom: 5px;
127 }
128
129 .quote-details {
130 margin-bottom: 30px;
131 }
132
133 .quote-details table {
134 width: 100%;
135 border-collapse: collapse;
136 }
137
138 .quote-details th,
139 .quote-details td {
140 padding: 8px;
141 text-align: left;
142 border-bottom: 1px solid #e9ecef;
143 }
144
145 .quote-details th {
146 background-color: #f8f9fa;
147 font-weight: 600;
148 color: #495057;
149 }
150
151 .items-table {
152 width: 100%;
153 border-collapse: collapse;
154 margin-bottom: 30px;
155 }
156
157 .items-table th,
158 .items-table td {
159 padding: 12px 8px;
160 text-align: left;
161 border-bottom: 1px solid #e9ecef;
162 }
163
164 .items-table th {
165 background-color: #f8f9fa;
166 font-weight: 600;
167 color: #495057;
168 }
169
170 .item-name {
171 font-weight: 500;
172 color: #495057;
173 }
174
175 .item-description {
176 font-size: 0.9rem;
177 color: #6c757d;
178 margin-top: 4px;
179 }
180
181 .amount {
182 font-weight: 600;
183 color: #495057;
184 }
185
186 .totals-section {
187 margin-bottom: 30px;
188 }
189
190 .totals-table {
191 width: 100%;
192 max-width: 300px;
193 margin-left: auto;
194 }
195
196 .total-row {
197 display: flex;
198 justify-content: space-between;
199 padding: 8px 0;
200 border-bottom: 1px solid #e9ecef;
201 }
202
203 .total-row:last-child {
204 border-bottom: 2px solid #495057;
205 font-weight: 600;
206 font-size: 1.1rem;
207 }
208
209 .notes-section {
210 margin-bottom: 30px;
211 }
212
213 .notes-section h3 {
214 color: #495057;
215 font-size: 1.2rem;
216 margin-bottom: 10px;
217 }
218
219 .notes-section p {
220 color: #6c757d;
221 line-height: 1.6;
222 }
223
224 .quote-footer {
225 background-color: #f8f9fa;
226 padding: 20px;
227 text-align: center;
228 color: #6c757d;
229 }
230
231 .quote-footer p {
232 margin-bottom: 5px;
233 }
234
235 /* Print styles */
236 @media print {
237 body {
238 background: white;
239 }
240
241 .quote-container {
242 box-shadow: none;
243 margin: 0;
244 }
245 }
246 </style>
247 </head>
248 <body>
249 <div class="quote-container">
250 <?php
251 // Dynamically load the selected template
252 $template_file = easy_invoice_design_template( 'quote', (string) $current_template );
253 if (file_exists($template_file)) {
254 include_once $template_file;
255 } else {
256 // Fallback to standard template if selected template doesn't exist
257 $template_file = easy_invoice_design_template( 'quote', 'standard' );
258 if (file_exists($template_file)) {
259 include_once $template_file;
260 } else {
261 // Show error if no template is available
262 echo '<div style="padding: 40px; text-align: center;">';
263 echo '<h2>Template Error</h2>';
264 echo '<p>The selected template "' . esc_html($current_template) . '" could not be loaded.</p>';
265 echo '</div>';
266 }
267 }
268 ?>
269 </div>
270
271 <script>
272 // Quote data for PDF generation
273 window.quoteData = <?php
274 $quote_data = $quote ? \EasyInvoice\Includes\Helpers\PdfHelper::getInvoiceDataForPdf($quote) : [];
275 if ($quote) {
276 $quote_data['status'] = $quote->getStatus();
277 }
278 echo json_encode($quote_data);
279 ?>;
280
281 // Global function for downloading PDF
282 function downloadQuotePdf(quoteId) {
283 try {
284 if (typeof QuotePdfGenerator !== 'undefined') {
285 // Use the new PDF generator that captures HTML directly
286 const pdfGenerator = new QuotePdfGenerator();
287 pdfGenerator.generatePDF();
288
289 // Show success message after a short delay
290 setTimeout(function() {
291 alert('PDF generated successfully');
292 }, 2000);
293 } else {
294 alert('Error: PDF generator not available');
295 }
296 } catch (error) {
297 console.error('PDF generation error:', error);
298 alert('Error generating PDF');
299 }
300 }
301 </script>
302 </body>
303 </html>
304