PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.0
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.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 / includes / Helpers / QuoteInvoiceHelper.php

QuoteInvoiceHelper.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.4.0, at includes/Helpers/QuoteInvoiceHelper.php

65 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace EasyInvoice\Helpers;
4
5 /**
6 * Helper class for managing quote-invoice relationships
7 */
8 class QuoteInvoiceHelper
9 {
10 /**
11 * Check if an invoice was converted from a quote
12 *
13 * @param int $invoice_id
14 * @return bool
15 */
16 public static function isInvoiceConvertedFromQuote($invoice_id)
17 {
18 // Check if this invoice was converted from a quote
19 $quote_id = get_post_meta($invoice_id, '_converted_from_quote', true) ?: get_post_meta($invoice_id, '_easy_invoice_converted_from_quote', true);
20 return !empty($quote_id);
21 }
22
23 /**
24 * Get quote information for an invoice
25 *
26 * @param int $invoice_id
27 * @return array|false Quote information or false if not found
28 */
29 public static function getQuoteInfoFromInvoice($invoice_id)
30 {
31 // Check if this invoice was converted from a quote
32 $quote_id = get_post_meta($invoice_id, '_converted_from_quote', true) ?: get_post_meta($invoice_id, '_easy_invoice_converted_from_quote', true);
33
34 if (!$quote_id) {
35 return false;
36 }
37
38 // Get quote post
39 $quote_post = get_post($quote_id);
40 if (!$quote_post || $quote_post->post_type !== 'easy_invoice_quote') {
41 return false;
42 }
43
44 // Get quote number
45 $quote_number = get_post_meta($quote_id, '_easy_invoice_quote_number', true) ?: get_post_meta($quote_id, '_quote_number', true);
46
47 // Get quote title
48 $quote_title = $quote_post->post_title;
49
50 // Determine icon and tooltip
51 $icon_class = 'fas fa-exchange-alt';
52 /* translators: %s: quote number. */
53 $tooltip_text = sprintf(__('Converted from Quote %s', 'easy-invoice'), $quote_number ?: $quote_title);
54
55 return [
56 'id' => $quote_id,
57 'number' => $quote_number,
58 'title' => $quote_title,
59 'icon_class' => $icon_class,
60 'tooltip_text' => $tooltip_text,
61 'url' => admin_url('admin.php?page=easy-invoice-quote-builder&id=' . $quote_id)
62 ];
63 }
64 }
65