PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.3.1
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.3.1
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.3.1, at templates/quotes/preview.php

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