Changeset 3351156
- Timestamp:
- 08/27/2025 11:31:41 AM (6 months ago)
- Location:
- easy-invoice
- Files:
-
- 10 edited
- 1 copied
-
tags/2.0.6 (copied) (copied from easy-invoice/trunk)
-
tags/2.0.6/easy-invoice.php (modified) (2 diffs)
-
tags/2.0.6/includes/Controllers/QuoteController.php (modified) (11 diffs)
-
tags/2.0.6/includes/Controllers/SettingsController.php (modified) (1 diff)
-
tags/2.0.6/readme.txt (modified) (2 diffs)
-
tags/2.0.6/templates/quotes/single.php (modified) (1 diff)
-
trunk/easy-invoice.php (modified) (2 diffs)
-
trunk/includes/Controllers/QuoteController.php (modified) (11 diffs)
-
trunk/includes/Controllers/SettingsController.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/templates/quotes/single.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
easy-invoice/tags/2.0.6/easy-invoice.php
r3349197 r3351156 4 4 * Plugin URI: https://matrixaddons.com/plugins/easy-invoice 5 5 * Description: A beautiful, full-featured invoicing solution for WordPress. Create professional invoices, quotes, and manage payments with ease. 6 * Version: 2.0. 56 * Version: 2.0.6 7 7 * Author: MatrixAddons 8 8 * Author URI: https://matrixaddons.com … … 25 25 26 26 // Define plugin constants. 27 define( 'EASY_INVOICE_VERSION', '2.0. 5' );27 define( 'EASY_INVOICE_VERSION', '2.0.6' ); 28 28 define( 'EASY_INVOICE_PLUGIN_FILE', __FILE__ ); 29 29 define( 'EASY_INVOICE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -
easy-invoice/tags/2.0.6/includes/Controllers/QuoteController.php
r3345595 r3351156 883 883 switch ($accept_action) { 884 884 case 'convert': 885 // Convert quote to invoice 886 $invoice_id = $this->convertQuoteToInvoice($quote); 885 // Convert quote to invoice (Draft status) 886 $invoice_id = $this->convertQuoteToInvoice($quote, 'draft'); 887 if ($invoice_id) { 888 $this->quote_log_service->logConversionToInvoice($quote_id, $invoice_id); 889 } 890 $action_message = __('Quote converted to invoice successfully.', 'easy-invoice'); 891 break; 892 893 case 'convert_available': 894 // Convert quote to invoice (Available status) 895 $invoice_id = $this->convertQuoteToInvoice($quote, 'available'); 887 896 if ($invoice_id) { 888 897 $this->quote_log_service->logConversionToInvoice($quote_id, $invoice_id); … … 892 901 893 902 case 'convert_send': 894 // Convert quote to invoice and send to client 895 $invoice_id = $this->convertQuoteToInvoice($quote );903 // Convert quote to invoice and send to client (Available status) 904 $invoice_id = $this->convertQuoteToInvoice($quote, 'available'); 896 905 if ($invoice_id) { 897 906 $this->sendInvoiceToClient($invoice_id); … … 901 910 902 911 case 'duplicate': 903 // Create new invoice, keep quote as-is 904 $invoice_id = $this->createInvoiceFromQuote($quote );912 // Create new invoice, keep quote as-is (Draft status) 913 $invoice_id = $this->createInvoiceFromQuote($quote, 'draft'); 905 914 if ($invoice_id) { 906 915 $this->quote_log_service->logDuplicationToInvoice($quote_id, $invoice_id); … … 910 919 911 920 case 'duplicate_send': 912 // Create new invoice and send to client, keep quote as-is 913 $invoice_id = $this->createInvoiceFromQuote($quote );921 // Create new invoice and send to client, keep quote as-is (Available status) 922 $invoice_id = $this->createInvoiceFromQuote($quote, 'available'); 914 923 if ($invoice_id) { 915 924 $this->sendInvoiceToClient($invoice_id); … … 930 939 } 931 940 941 // Get URLs for the new invoice 942 $invoice_url = null; 943 $secure_url = null; 944 945 if ($invoice_id) { 946 // Get regular invoice URL 947 $invoice_url = get_permalink($invoice_id); 948 949 // If permalink is not available, construct a fallback URL 950 if (!$invoice_url || $invoice_url === get_permalink(0)) { 951 $invoice_url = home_url('/invoice/' . $invoice_id . '/'); 952 } 953 954 // Get secure URL for the new invoice if it exists (Pro version) 955 if (class_exists('\EasyInvoicePro\Controllers\PermalinkController')) { 956 $secure_url = \EasyInvoicePro\Controllers\PermalinkController::getInvoiceSecureLinkUrl($invoice_id); 957 } 958 } 959 932 960 wp_send_json_success([ 933 961 'message' => $action_message, 934 962 'invoice_id' => $invoice_id, 963 'invoice_url' => $invoice_url, 964 'secure_url' => $secure_url, 935 965 'toast' => [ 936 966 'type' => 'success', … … 944 974 * 945 975 * @param \EasyInvoice\Models\Quote $quote The quote to convert 976 * @param string $status The status for the new invoice ('draft' or 'available') 946 977 * @return int|null The invoice ID if successful, null otherwise 947 978 */ 948 private function convertQuoteToInvoice($quote ): ?int {979 private function convertQuoteToInvoice($quote, $status = 'draft'): ?int { 949 980 try { 950 981 // Get invoice repository … … 955 986 'title' => $quote->getTitle() ?: 'Invoice from Quote ' . $quote->getNumber(), 956 987 'number' => $this->generateInvoiceNumber(), 957 'status' => 'draft',988 'status' => $status, 958 989 'issue_date' => date('Y-m-d'), 959 990 'due_date' => date('Y-m-d', strtotime('+30 days')), … … 995 1026 $quote->save(); 996 1027 1028 // Ensure secure link is generated for the new invoice (Pro version) 1029 if (class_exists('\EasyInvoicePro\Controllers\PermalinkController')) { 1030 // Trigger the save_post hook to generate secure link 1031 do_action('save_post_easy_invoice', $invoice->getId(), get_post($invoice->getId())); 1032 } 1033 997 1034 return $invoice->getId(); 998 1035 } … … 1009 1046 * 1010 1047 * @param \EasyInvoice\Models\Quote $quote The quote to duplicate 1048 * @param string $status The status for the new invoice ('draft' or 'available') 1011 1049 * @return int|null The invoice ID if successful, null otherwise 1012 1050 */ 1013 private function createInvoiceFromQuote($quote ): ?int {1051 private function createInvoiceFromQuote($quote, $status = 'draft'): ?int { 1014 1052 try { 1015 1053 // Get invoice repository … … 1020 1058 'title' => 'Invoice from Quote ' . $quote->getNumber(), 1021 1059 'number' => $this->generateInvoiceNumber(), 1022 'status' => 'draft',1060 'status' => $status, 1023 1061 'issue_date' => date('Y-m-d'), 1024 1062 'due_date' => date('Y-m-d', strtotime('+30 days')), … … 1059 1097 $quote->setCustomField('related_invoice_id', $invoice->getId()); 1060 1098 $quote->save(); 1099 1100 // Ensure secure link is generated for the new invoice (Pro version) 1101 if (class_exists('\EasyInvoicePro\Controllers\PermalinkController')) { 1102 // Trigger the save_post hook to generate secure link 1103 do_action('save_post_easy_invoice', $invoice->getId(), get_post($invoice->getId())); 1104 } 1061 1105 1062 1106 return $invoice->getId(); -
easy-invoice/tags/2.0.6/includes/Controllers/SettingsController.php
r3349197 r3351156 261 261 'default' => 'convert', 262 262 'options' => [ 263 'convert' => __('Convert quote to invoice', 'easy-invoice'), 264 'convert_send' => __('Convert quote to invoice and send to client', 'easy-invoice'), 265 'duplicate' => __('Create new invoice, keep quote as-is', 'easy-invoice'), 266 'duplicate_send' => __('Create new invoice and send to client, keep quote as-is', 'easy-invoice'), 263 'convert' => __('Convert quote to invoice - Draft', 'easy-invoice'), 264 'convert_available' => __('Convert quote to invoice - Available', 'easy-invoice'), 265 'convert_send' => __('Convert quote to invoice and send to client - Available', 'easy-invoice'), 266 'duplicate' => __('Create new invoice, keep quote as-is - Draft', 'easy-invoice'), 267 'duplicate_send' => __('Create new invoice and send to client, keep quote as-is - Available', 'easy-invoice'), 267 268 'do_nothing' => __('Do nothing', 'easy-invoice'), 268 269 ], -
easy-invoice/tags/2.0.6/readme.txt
r3349197 r3351156 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 2.0. 57 Stable tag: 2.0.6 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 134 134 135 135 == Changelog == 136 = 2.0.6 - 2025-08-27 = 137 * Fixed - Accept quote issue fixed 138 136 139 137 140 = 2.0.5 - 2025-08-24 = -
easy-invoice/tags/2.0.6/templates/quotes/single.php
r3349197 r3351156 1454 1454 success: function(response) { 1455 1455 if (response.success) { 1456 showModalMessage('success', response.data && response.data.message ? response.data.message : '<?php _e('Quote accepted successfully', 'easy-invoice'); ?>', function() { location.reload(); }); 1456 // Check if an invoice was created and redirect to it 1457 if (response.data && response.data.invoice_id) { 1458 // Use the PHP-generated URL (secure URL first, then regular URL) 1459 let invoiceUrl = response.data.secure_url || response.data.invoice_url; 1460 1461 if (invoiceUrl) { 1462 showModalMessage('success', response.data.message || '<?php _e('Quote accepted successfully! Redirecting to invoice...', 'easy-invoice'); ?>', function() { 1463 window.location.href = invoiceUrl; 1464 }); 1465 } else { 1466 // Fallback to reload if no URL available 1467 showModalMessage('success', response.data.message || '<?php _e('Quote accepted successfully', 'easy-invoice'); ?>', function() { location.reload(); }); 1468 } 1469 } else { 1470 // No invoice created, just show success message 1471 showModalMessage('success', response.data && response.data.message ? response.data.message : '<?php _e('Quote accepted successfully', 'easy-invoice'); ?>', function() { location.reload(); }); 1472 } 1457 1473 } else { 1458 1474 resetButtonLoading(confirmBtn, originalText); -
easy-invoice/trunk/easy-invoice.php
r3349197 r3351156 4 4 * Plugin URI: https://matrixaddons.com/plugins/easy-invoice 5 5 * Description: A beautiful, full-featured invoicing solution for WordPress. Create professional invoices, quotes, and manage payments with ease. 6 * Version: 2.0. 56 * Version: 2.0.6 7 7 * Author: MatrixAddons 8 8 * Author URI: https://matrixaddons.com … … 25 25 26 26 // Define plugin constants. 27 define( 'EASY_INVOICE_VERSION', '2.0. 5' );27 define( 'EASY_INVOICE_VERSION', '2.0.6' ); 28 28 define( 'EASY_INVOICE_PLUGIN_FILE', __FILE__ ); 29 29 define( 'EASY_INVOICE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -
easy-invoice/trunk/includes/Controllers/QuoteController.php
r3345595 r3351156 883 883 switch ($accept_action) { 884 884 case 'convert': 885 // Convert quote to invoice 886 $invoice_id = $this->convertQuoteToInvoice($quote); 885 // Convert quote to invoice (Draft status) 886 $invoice_id = $this->convertQuoteToInvoice($quote, 'draft'); 887 if ($invoice_id) { 888 $this->quote_log_service->logConversionToInvoice($quote_id, $invoice_id); 889 } 890 $action_message = __('Quote converted to invoice successfully.', 'easy-invoice'); 891 break; 892 893 case 'convert_available': 894 // Convert quote to invoice (Available status) 895 $invoice_id = $this->convertQuoteToInvoice($quote, 'available'); 887 896 if ($invoice_id) { 888 897 $this->quote_log_service->logConversionToInvoice($quote_id, $invoice_id); … … 892 901 893 902 case 'convert_send': 894 // Convert quote to invoice and send to client 895 $invoice_id = $this->convertQuoteToInvoice($quote );903 // Convert quote to invoice and send to client (Available status) 904 $invoice_id = $this->convertQuoteToInvoice($quote, 'available'); 896 905 if ($invoice_id) { 897 906 $this->sendInvoiceToClient($invoice_id); … … 901 910 902 911 case 'duplicate': 903 // Create new invoice, keep quote as-is 904 $invoice_id = $this->createInvoiceFromQuote($quote );912 // Create new invoice, keep quote as-is (Draft status) 913 $invoice_id = $this->createInvoiceFromQuote($quote, 'draft'); 905 914 if ($invoice_id) { 906 915 $this->quote_log_service->logDuplicationToInvoice($quote_id, $invoice_id); … … 910 919 911 920 case 'duplicate_send': 912 // Create new invoice and send to client, keep quote as-is 913 $invoice_id = $this->createInvoiceFromQuote($quote );921 // Create new invoice and send to client, keep quote as-is (Available status) 922 $invoice_id = $this->createInvoiceFromQuote($quote, 'available'); 914 923 if ($invoice_id) { 915 924 $this->sendInvoiceToClient($invoice_id); … … 930 939 } 931 940 941 // Get URLs for the new invoice 942 $invoice_url = null; 943 $secure_url = null; 944 945 if ($invoice_id) { 946 // Get regular invoice URL 947 $invoice_url = get_permalink($invoice_id); 948 949 // If permalink is not available, construct a fallback URL 950 if (!$invoice_url || $invoice_url === get_permalink(0)) { 951 $invoice_url = home_url('/invoice/' . $invoice_id . '/'); 952 } 953 954 // Get secure URL for the new invoice if it exists (Pro version) 955 if (class_exists('\EasyInvoicePro\Controllers\PermalinkController')) { 956 $secure_url = \EasyInvoicePro\Controllers\PermalinkController::getInvoiceSecureLinkUrl($invoice_id); 957 } 958 } 959 932 960 wp_send_json_success([ 933 961 'message' => $action_message, 934 962 'invoice_id' => $invoice_id, 963 'invoice_url' => $invoice_url, 964 'secure_url' => $secure_url, 935 965 'toast' => [ 936 966 'type' => 'success', … … 944 974 * 945 975 * @param \EasyInvoice\Models\Quote $quote The quote to convert 976 * @param string $status The status for the new invoice ('draft' or 'available') 946 977 * @return int|null The invoice ID if successful, null otherwise 947 978 */ 948 private function convertQuoteToInvoice($quote ): ?int {979 private function convertQuoteToInvoice($quote, $status = 'draft'): ?int { 949 980 try { 950 981 // Get invoice repository … … 955 986 'title' => $quote->getTitle() ?: 'Invoice from Quote ' . $quote->getNumber(), 956 987 'number' => $this->generateInvoiceNumber(), 957 'status' => 'draft',988 'status' => $status, 958 989 'issue_date' => date('Y-m-d'), 959 990 'due_date' => date('Y-m-d', strtotime('+30 days')), … … 995 1026 $quote->save(); 996 1027 1028 // Ensure secure link is generated for the new invoice (Pro version) 1029 if (class_exists('\EasyInvoicePro\Controllers\PermalinkController')) { 1030 // Trigger the save_post hook to generate secure link 1031 do_action('save_post_easy_invoice', $invoice->getId(), get_post($invoice->getId())); 1032 } 1033 997 1034 return $invoice->getId(); 998 1035 } … … 1009 1046 * 1010 1047 * @param \EasyInvoice\Models\Quote $quote The quote to duplicate 1048 * @param string $status The status for the new invoice ('draft' or 'available') 1011 1049 * @return int|null The invoice ID if successful, null otherwise 1012 1050 */ 1013 private function createInvoiceFromQuote($quote ): ?int {1051 private function createInvoiceFromQuote($quote, $status = 'draft'): ?int { 1014 1052 try { 1015 1053 // Get invoice repository … … 1020 1058 'title' => 'Invoice from Quote ' . $quote->getNumber(), 1021 1059 'number' => $this->generateInvoiceNumber(), 1022 'status' => 'draft',1060 'status' => $status, 1023 1061 'issue_date' => date('Y-m-d'), 1024 1062 'due_date' => date('Y-m-d', strtotime('+30 days')), … … 1059 1097 $quote->setCustomField('related_invoice_id', $invoice->getId()); 1060 1098 $quote->save(); 1099 1100 // Ensure secure link is generated for the new invoice (Pro version) 1101 if (class_exists('\EasyInvoicePro\Controllers\PermalinkController')) { 1102 // Trigger the save_post hook to generate secure link 1103 do_action('save_post_easy_invoice', $invoice->getId(), get_post($invoice->getId())); 1104 } 1061 1105 1062 1106 return $invoice->getId(); -
easy-invoice/trunk/includes/Controllers/SettingsController.php
r3349197 r3351156 261 261 'default' => 'convert', 262 262 'options' => [ 263 'convert' => __('Convert quote to invoice', 'easy-invoice'), 264 'convert_send' => __('Convert quote to invoice and send to client', 'easy-invoice'), 265 'duplicate' => __('Create new invoice, keep quote as-is', 'easy-invoice'), 266 'duplicate_send' => __('Create new invoice and send to client, keep quote as-is', 'easy-invoice'), 263 'convert' => __('Convert quote to invoice - Draft', 'easy-invoice'), 264 'convert_available' => __('Convert quote to invoice - Available', 'easy-invoice'), 265 'convert_send' => __('Convert quote to invoice and send to client - Available', 'easy-invoice'), 266 'duplicate' => __('Create new invoice, keep quote as-is - Draft', 'easy-invoice'), 267 'duplicate_send' => __('Create new invoice and send to client, keep quote as-is - Available', 'easy-invoice'), 267 268 'do_nothing' => __('Do nothing', 'easy-invoice'), 268 269 ], -
easy-invoice/trunk/readme.txt
r3349197 r3351156 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 2.0. 57 Stable tag: 2.0.6 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 134 134 135 135 == Changelog == 136 = 2.0.6 - 2025-08-27 = 137 * Fixed - Accept quote issue fixed 138 136 139 137 140 = 2.0.5 - 2025-08-24 = -
easy-invoice/trunk/templates/quotes/single.php
r3349197 r3351156 1454 1454 success: function(response) { 1455 1455 if (response.success) { 1456 showModalMessage('success', response.data && response.data.message ? response.data.message : '<?php _e('Quote accepted successfully', 'easy-invoice'); ?>', function() { location.reload(); }); 1456 // Check if an invoice was created and redirect to it 1457 if (response.data && response.data.invoice_id) { 1458 // Use the PHP-generated URL (secure URL first, then regular URL) 1459 let invoiceUrl = response.data.secure_url || response.data.invoice_url; 1460 1461 if (invoiceUrl) { 1462 showModalMessage('success', response.data.message || '<?php _e('Quote accepted successfully! Redirecting to invoice...', 'easy-invoice'); ?>', function() { 1463 window.location.href = invoiceUrl; 1464 }); 1465 } else { 1466 // Fallback to reload if no URL available 1467 showModalMessage('success', response.data.message || '<?php _e('Quote accepted successfully', 'easy-invoice'); ?>', function() { location.reload(); }); 1468 } 1469 } else { 1470 // No invoice created, just show success message 1471 showModalMessage('success', response.data && response.data.message ? response.data.message : '<?php _e('Quote accepted successfully', 'easy-invoice'); ?>', function() { location.reload(); }); 1472 } 1457 1473 } else { 1458 1474 resetButtonLoading(confirmBtn, originalText);
Note: See TracChangeset
for help on using the changeset viewer.