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

295 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 <!-- 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 .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 if (file_exists($template_file)) {
244 include_once $template_file;
245 } else {
246 // Fallback to standard template if selected template doesn't exist
247 $template_file = EASY_INVOICE_PLUGIN_DIR . 'templates/quote-templates/standard.php';
248 if (file_exists($template_file)) {
249 include_once $template_file;
250 } else {
251 // Show error if no template is available
252 echo '<div style="padding: 40px; text-align: center;">';
253 echo '<h2>Template Error</h2>';
254 echo '<p>The selected template "' . esc_html($current_template) . '" could not be loaded.</p>';
255 echo '</div>';
256 }
257 }
258 ?>
259 </div>
260
261 <!-- Quote data for PDF generation -->
262 <script>
263 // Quote data for PDF generation
264 window.quoteData = <?php
265 $quote_data = $quote ? \EasyInvoice\Includes\Helpers\PdfHelper::getInvoiceDataForPdf($quote) : [];
266 if ($quote) {
267 $quote_data['status'] = $quote->getStatus();
268 }
269 echo json_encode($quote_data);
270 ?>;
271
272 // Global function for downloading PDF
273 function downloadQuotePdf(quoteId) {
274 try {
275 if (typeof QuotePdfGenerator !== 'undefined') {
276 // Use the new PDF generator that captures HTML directly
277 const pdfGenerator = new QuotePdfGenerator();
278 pdfGenerator.generatePDF();
279
280 // Show success message after a short delay
281 setTimeout(function() {
282 alert('PDF generated successfully');
283 }, 2000);
284 } else {
285 alert('Error: PDF generator not available');
286 }
287 } catch (error) {
288 console.error('PDF generation error:', error);
289 alert('Error generating PDF');
290 }
291 }
292 </script>
293 </body>
294 </html>
295