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

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

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