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 / live-preview.php

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

171 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <!-- Right Panel - Live Preview -->
2 <div class="bg-white shadow rounded-lg" style="padding: 10px;">
3
4 <div class="px-6 py-5 border-b border-gray-200" style="margin-bottom: 10px;">
5 <div class="flex justify-between items-center">
6 <div class="flex items-center">
7 <div class="flex-shrink-0 bg-indigo-100 rounded-lg p-3">
8 <i class="fas fa-eye text-indigo-600 text-xl"></i>
9 </div>
10 <div class="ml-4">
11 <h2 class="text-lg font-medium text-gray-900">Quote Preview</h2>
12 <p class="mt-1 text-sm text-gray-500">Live preview of your quote</p>
13 </div>
14 </div>
15 <?php if($quote_id > 0 ){ ?>
16 <a href="<?php echo get_permalink($quote_id); ?>" target="_blank" class="inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
17 <i class="fas fa-external-link-alt mr-2"></i>
18 Full Preview
19 </a>
20 <?php } ?>
21 </div>
22 </div>
23
24 <?php
25 // Get the current template (default to 'standard')
26 $current_template = $quote ? $quote->getTemplate() : 'standard';
27 if (empty($current_template)) {
28 $current_template = 'standard';
29 }
30 $template_class = 'template-' . $current_template;
31
32 // Initialize formatter for the quote templates
33 $formatter = new \EasyInvoice\Helpers\QuoteFormatter($quote);
34 ?>
35
36 <div id="quote-container" class="quote-container quote-preview <?php echo $template_class; ?>">
37 <?php
38 // Dynamically load the selected template from quote templates directory
39 $template_file = EASY_INVOICE_PLUGIN_DIR . 'templates/quote-templates/' . $current_template . '.php';
40
41 if (file_exists($template_file)) {
42 require $template_file;
43 } else {
44 // Show template not found message
45 ?>
46 <div class="template-not-found">
47 <div class="template-not-found-icon">
48 <i class="fas fa-exclamation-circle"></i>
49 </div>
50 <h3>Template Not Found</h3>
51 <p>The selected template "<?php echo esc_html($current_template); ?>" does not exist.</p>
52 <p>Please select a different template or contact support if you believe this is an error.</p>
53 </div>
54 <style>
55 .template-not-found {
56 text-align: center;
57 padding: 40px;
58 background: #fff;
59 border-radius: 8px;
60 box-shadow: 0 2px 4px rgba(0,0,0,0.1);
61 }
62 .template-not-found-icon {
63 font-size: 48px;
64 color: #dc3545;
65 margin-bottom: 20px;
66 }
67 .template-not-found h3 {
68 font-size: 24px;
69 color: #32325d;
70 margin-bottom: 10px;
71 }
72 .template-not-found p {
73 color: #8898aa;
74 margin-bottom: 10px;
75 }
76 </style>
77 <?php
78 }
79 ?>
80 </div>
81 </div>
82
83 <style>
84 /* Loading state styles */
85 .loading-overlay {
86 position: absolute;
87 top: 0;
88 left: 0;
89 right: 0;
90 bottom: 0;
91 background: rgba(255, 255, 255, 0.9);
92 display: flex;
93 justify-content: center;
94 align-items: center;
95 z-index: 1000;
96 }
97
98 .loading-spinner {
99 text-align: center;
100 }
101
102 .quote-container.loading .loading-overlay {
103 display: flex;
104 }
105
106 /* (Resize logic removed per request) */
107 </style>
108
109 <script>
110 jQuery(document).ready(function($) {
111 // Localize easyInvoice object for this page
112 // Localize easyInvoice object for this page
113 window.easyInvoiceQ = window.easyInvoice || {};
114 window.easyInvoice.isPro = <?php echo easy_invoice_has_pro() ? 'true' : 'false'; ?>;
115 window.easyInvoice.ajaxUrl = '<?php echo admin_url('admin-ajax.php'); ?>';
116 window.easyInvoice.nonce = '<?php echo wp_create_nonce('easy_invoice_nonce'); ?>';
117
118 // Function to update the live preview using AJAX
119 function updateLivePreview(templateId) {
120 $('#quote-container').addClass('loading');
121 $.ajax({
122 url: window.easyInvoice.ajaxUrl,
123 type: 'POST',
124 data: {
125 action: 'easy_invoice_load_quote_template',
126 template: templateId,
127 quote_id: <?php echo $quote ? $quote->getId() : 0; ?>,
128 nonce: window.easyInvoice.nonce
129 },
130 success: function(response) {
131 if (response.success) {
132 $('#quote-container').html(response.data.html);
133 } else {
134 $('#quote-container').html('<div class="error">Failed to load template: ' + response.data.message + '</div>');
135 }
136 $('#quote-container').removeClass('loading');
137 },
138 error: function(xhr, status, error) {
139 $('#quote-container').html('<div class="error">Failed to load template. Please try again.</div>');
140 $('#quote-container').removeClass('loading');
141 }
142 });
143 }
144
145 // Listen for template changes
146 $('.template-card').on('click', function(e) {
147 const templateId = $(this).data('template-id');
148
149 // Check if this is a premium template in free version
150 const isPremium = $(this).attr('data-is-premium') === 'true';
151 const isFreeVersion = !window.easyInvoice || !window.easyInvoice.isPro;
152
153 if (isPremium && isFreeVersion) {
154 // Show premium upgrade modal instead of selecting the template
155 if (typeof EasyInvoiceConfirmation !== 'undefined' && EasyInvoiceConfirmation.showFeatureUpgrade) {
156 EasyInvoiceConfirmation.showFeatureUpgrade('<?php _e('Premium Templates', 'easy-invoice'); ?>', '<?php _e('Access all premium templates including Modern, Professional, Classic, and more to give your quotes a unique and professional look.', 'easy-invoice'); ?>');
157 } else {
158 alert('<?php _e('This is a premium feature. Please upgrade to Pro to access all templates.', 'easy-invoice'); ?>');
159 }
160 return;
161 }
162
163 updateLivePreview(templateId);
164 });
165
166
167
168
169
170 });
171 </script>