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

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

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