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

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