PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.1
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.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 / includes / Forms / Quote / QuoteFieldRegistration.php

QuoteFieldRegistration.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.4.1, at includes/Forms/Quote/QuoteFieldRegistration.php

717 lines 28.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Quote Field Registration Class
4 *
5 * @package EasyInvoice
6 * @author Your Name
7 * @copyright Copyright (c) 2023, Your Company
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.0.0
10 */
11
12 namespace EasyInvoice\Forms\Quote;
13
14 use EasyInvoice\Forms\BaseFieldRegistration;
15
16 /**
17 * Quote Field Registration
18 *
19 * Handles registration of quote-specific form fields, tabs, and templates.
20 *
21 * @since 1.0.0
22 */
23 class QuoteFieldRegistration extends BaseFieldRegistration {
24
25 /**
26 * Register default tabs
27 *
28 * @since 1.0.0
29 * @return void
30 */
31 public function registerDefaultTabs(): void {
32 // Define all tabs in a single array for easy modification by pro plugins
33 $all_tabs = $this->getDefaultTabsArray();
34
35 // Apply filter to allow pro plugins to modify tabs
36 $all_tabs = apply_filters('easy_invoice_quote_form_tabs', $all_tabs);
37
38 // Register all tabs from the array
39 foreach ($all_tabs as $tab_id => $tab_config) {
40 $this->registerTab($tab_id, $tab_config);
41 }
42 }
43
44 /**
45 * Get default tabs array
46 *
47 * @since 1.0.0
48 * @return array
49 */
50 private function getDefaultTabsArray(): array {
51 return [
52 'quote-tab' => [
53 'label' => __('Quote Details', 'easy-invoice'),
54 'icon' => 'fas fa-file-invoice',
55 'active' => true,
56 'order' => 1
57 ],
58 'items-tab' => [
59 'label' => __('Items', 'easy-invoice'),
60 'icon' => 'fas fa-list',
61 'active' => false,
62 'order' => 2
63 ],
64 'client-tab' => [
65 'label' => __('Client', 'easy-invoice'),
66 'icon' => 'fas fa-user',
67 'active' => false,
68 'order' => 3
69 ],
70 'discounts-taxes-tab' => [
71 'label' => __('Discounts & Taxes', 'easy-invoice'),
72 'icon' => 'fas fa-percentage',
73 'active' => false,
74 'order' => 4
75 ],
76 'payments-tab' => [
77 'label' => __('Payment', 'easy-invoice'),
78 'icon' => 'fas fa-credit-card',
79 'active' => false,
80 'order' => 5
81 ]
82 ];
83 }
84
85 /**
86 * Register default fields
87 *
88 * @since 1.0.0
89 * @return void
90 */
91 public function registerDefaultFields(): void {
92 // Define all fields in a single array for easy modification by pro plugins
93 $all_fields = $this->getDefaultFieldsArray();
94
95 // Gate basic tax fields on the global Settings → Tax → Enable
96 // Tax setting — matches the invoice builder. When tax is
97 // globally off, the override checkbox / rate / prices-include-tax
98 // are all hidden from the quote builder.
99 if (get_option('easy_invoice_tax_enabled', 'no') !== 'yes') {
100 $tax_field_names = ['tax_enabled', 'tax_rate', 'prices_include_tax'];
101 $all_fields = array_values(array_filter(
102 $all_fields,
103 static fn($f) => !in_array($f['name'] ?? '', $tax_field_names, true)
104 ));
105 }
106
107 // Apply filter to allow pro plugins to modify fields
108 $all_fields = apply_filters('easy_invoice_quote_form_fields', $all_fields);
109
110 // Register all fields from the array
111 foreach ($all_fields as $field_config) {
112 $tab_id = $field_config['tab_id'] ?? '';
113 unset($field_config['tab_id']); // Remove tab_id from config
114
115 if (!empty($tab_id)) {
116 $this->registerField($tab_id, $field_config);
117 }
118 }
119 }
120
121 /**
122 * Get default fields array
123 *
124 * @since 1.0.0
125 * @return array
126 */
127 private function getDefaultFieldsArray(): array {
128 return [
129 // Quote Tab Fields
130 [
131 'tab_id' => 'quote-tab',
132 'id' => 'quote_template',
133 'type' => 'hidden',
134 'label' => __('Quote Template', 'easy-invoice'),
135 'name' => 'quote_template',
136 'required' => false,
137 'grid_cols' => 'sm:col-span-6',
138 'order' => 0,
139 'default_value' => 'standard',
140 'sanitize_callback' => 'sanitize_text_field',
141 'validate_callback' => function($value) {
142 return !empty(trim($value)) ? true : __('Quote template is required.', 'easy-invoice');
143 }
144 ],
145 [
146 'tab_id' => 'quote-tab',
147 'id' => 'quote_title',
148 'type' => 'text',
149 'label' => __('Quote Title', 'easy-invoice'),
150 'name' => 'title',
151 'placeholder' => __('Enter quote title', 'easy-invoice'),
152 'required' => true,
153 'grid_cols' => 'sm:col-span-6',
154 'order' => 1,
155 'default_value' => __('New Quote', 'easy-invoice'),
156 'sanitize_callback' => 'sanitize_text_field',
157 'validate_callback' => function($value) {
158 return !empty(trim($value)) ? true : __('Quote title is required.', 'easy-invoice');
159 }
160 ],
161 [
162 'tab_id' => 'quote-tab',
163 'id' => 'quote_description',
164 'type' => 'textarea',
165 'label' => __('Quote Description', 'easy-invoice'),
166 'name' => 'description',
167 'placeholder' => __('Enter quote description or additional details', 'easy-invoice'),
168 'required' => false,
169 'grid_cols' => 'sm:col-span-6',
170 'rows' => 3,
171 'order' => 2,
172 'description' => __('Optional description or additional details about this quote.', 'easy-invoice'),
173 'sanitize_callback' => 'sanitize_textarea_field',
174 ],
175 [
176 'tab_id' => 'quote-tab',
177 'id' => 'quote-number',
178 'type' => 'text',
179 'label' => __('Quote Number', 'easy-invoice'),
180 'name' => 'number',
181 'placeholder' => __('QT-001', 'easy-invoice'),
182 'required' => true,
183 'readonly' => true,
184 'description' => __('This is the unique number for your quote. It cannot be changed.', 'easy-invoice'),
185 'grid_cols' => 'sm:col-span-3',
186 'order' => 3,
187 'default_value' => function() {
188 // For new quotes, show the next number without incrementing
189 // For existing quotes, this will be overridden by the quote object's getNumber() method
190 if (class_exists('\\EasyInvoice\\Services\\QuoteNumberService')) {
191 $service = new \EasyInvoice\Services\QuoteNumberService();
192 return $service->getNextNumber();
193 }
194 return 'QT-' . str_pad(time(), 6, '0', STR_PAD_LEFT);
195 },
196 'sanitize_callback' => 'sanitize_text_field',
197 'validate_callback' => function($value) {
198 return !empty(trim($value)) ? true : __('Quote number is required.', 'easy-invoice');
199 }
200 ],
201 [
202 'tab_id' => 'quote-tab',
203 'id' => 'quote-date',
204 'type' => 'date',
205 'label' => __('Quote Date', 'easy-invoice'),
206 'name' => 'issue_date',
207 'required' => true,
208 'grid_cols' => 'sm:col-span-3',
209 'order' => 4,
210 'default_value' => current_time('Y-m-d'),
211 'sanitize_callback' => 'sanitize_text_field',
212 'validate_callback' => function($value) {
213 return !empty($value) && strtotime($value) ? true : __('Please enter a valid quote date.', 'easy-invoice');
214 }
215 ],
216 [
217 'tab_id' => 'quote-tab',
218 'id' => 'expiry-date',
219 'type' => 'date',
220 'label' => __('Expiry Date', 'easy-invoice'),
221 'name' => 'expiry_date',
222 'required' => true,
223 'grid_cols' => 'sm:col-span-3',
224 'order' => 5,
225 // Required but shipped with no default, so saving a brand-new quote
226 // always failed first time with "Expiry Date is required" — the same
227 // defect the invoice form had with its issue/due dates. The quote date
228 // field just above already defaults; this one was missed.
229 //
230 // 30 days matches the validity period used elsewhere in the plugin
231 // (see QuoteController's quote defaults). There is no site setting for
232 // quote validity yet; when one is added, read it here.
233 'default_value' => gmdate('Y-m-d', strtotime('+30 days', strtotime(current_time('Y-m-d')))),
234 'sanitize_callback' => 'sanitize_text_field',
235 'validate_callback' => function($value) {
236 return !empty($value) && strtotime($value) ? true : __('Please enter a valid expiry date.', 'easy-invoice');
237 }
238 ],
239 [
240 'tab_id' => 'quote-tab',
241 'id' => 'status',
242 'type' => 'select',
243 'label' => __('Status', 'easy-invoice'),
244 'name' => 'status',
245 'required' => true,
246 'grid_cols' => 'sm:col-span-3',
247 'options' => [
248 'available' => __('Available', 'easy-invoice'),
249 'draft' => __('Draft', 'easy-invoice'),
250 'accepted' => __('Accepted', 'easy-invoice'),
251 'declined' => __('Declined', 'easy-invoice'),
252 'cancelled' => __('Cancelled', 'easy-invoice'),
253 'expired' => __('Expired', 'easy-invoice'),
254 'sent' => __('Sent', 'easy-invoice')
255 ],
256 'order' => 5
257 ],
258 [
259 'tab_id' => 'quote-tab',
260 'id' => 'notes',
261 'type' => 'textarea',
262 'label' => __('Notes', 'easy-invoice'),
263 'name' => 'notes',
264 'placeholder' => __('Additional notes for the client', 'easy-invoice'),
265 'grid_cols' => 'sm:col-span-6',
266 'rows' => 3,
267 'section' => 'notes',
268 'order' => 6,
269 'description' => __('These notes will be visible to your client on the quote.', 'easy-invoice'),
270 ],
271 [
272 'tab_id' => 'quote-tab',
273 'id' => 'internal_notes',
274 'type' => 'textarea',
275 'label' => __('Internal Notes', 'easy-invoice'),
276 'name' => 'internal_notes',
277 'placeholder' => __('Internal notes (not visible to client)', 'easy-invoice'),
278 'grid_cols' => 'sm:col-span-6',
279 'rows' => 3,
280 'section' => 'notes',
281 'order' => 7,
282 'description' => __('Only you and your team can see these notes. Clients will not see them.', 'easy-invoice'),
283 ],
284 [
285 'tab_id' => 'quote-tab',
286 'id' => 'terms',
287 'type' => 'textarea',
288 'label' => __('Quote Terms', 'easy-invoice'),
289 'name' => 'terms',
290 'placeholder' => __('Quote terms and conditions', 'easy-invoice'),
291 'grid_cols' => 'sm:col-span-6',
292 'rows' => 3,
293 'section' => 'notes',
294 'order' => 8,
295 'default_value' => function() {
296 return \EasyInvoice\Controllers\SettingsController::getQuoteTermsConditions();
297 },
298 'description' => __('Specify the terms and conditions for this quote.', 'easy-invoice'),
299 ],
300
301 // Client Tab Fields
302 [
303 'tab_id' => 'client-tab',
304 'id' => 'client_id',
305 'type' => 'select',
306 'label' => __('Select Client', 'easy-invoice'),
307 'name' => 'client_id',
308 'required' => false,
309 'grid_cols' => 'sm:col-span-6',
310 'options' => $this->getClientOptions(),
311 'order' => 1,
312 'description' => __('Choose an existing client or add a new one.', 'easy-invoice'),
313 ],
314
315 // Discounts & Taxes Tab Fields
316 [
317 'tab_id' => 'discounts-taxes-tab',
318 'name' => 'discount_type',
319 'type' => 'select',
320 'label' => __('Discount Type', 'easy-invoice'),
321 'grid_cols' => 'sm:col-span-2',
322 'section' => 'discount',
323 'options' => [
324 'none' => __('No Discount', 'easy-invoice'),
325 'percentage' => __('Percentage', 'easy-invoice'),
326 'fixed' => __('Fixed Amount', 'easy-invoice')
327 ],
328 'order' => 1,
329 'description' => __('Choose how the discount should be applied to this quote.', 'easy-invoice'),
330 ],
331 [
332 'tab_id' => 'discounts-taxes-tab',
333 'name' => 'discount_value',
334 'type' => 'number',
335 'label' => __('Discount Value', 'easy-invoice'),
336 'placeholder' => '0.00',
337 'grid_cols' => 'sm:col-span-2',
338 'section' => 'discount',
339 'min' => '0',
340 'step' => '0.01',
341 'order' => 2,
342 'sanitize_callback' => 'floatval',
343 'validate_callback' => function($value) {
344 return is_numeric($value) && $value >= 0 ? true : __('Discount value must be a non-negative number.', 'easy-invoice');
345 },
346 'description' => __('Enter the discount amount or percentage for this quote.', 'easy-invoice'),
347 ],
348 [
349 // Per-quote "Enable Tax" override — mirrors the
350 // identical field on the invoice builder. See
351 // InvoiceFieldRegistration for the design rationale.
352 'tab_id' => 'discounts-taxes-tab',
353 'name' => 'tax_enabled',
354 'type' => 'checkbox',
355 'label' => __('Apply Tax to This Quote', 'easy-invoice'),
356 'grid_cols' => 'sm:col-span-6',
357 'section' => 'tax',
358 'order' => 2.5,
359 'default_value' => function() {
360 return get_option('easy_invoice_tax_enabled', 'no') === 'yes' ? 'yes' : 'no';
361 },
362 'sanitize_callback' => function($value) {
363 if ($value === 'yes' || $value === '1' || $value === 1 || $value === true || $value === 'on') return 'yes';
364 return 'no';
365 },
366 'description' => __('Override the global tax setting for this quote.', 'easy-invoice'),
367 ],
368 [
369 // Discount calculation timing — belongs in the discount
370 // section (controls when discount applies relative to
371 // tax, not how tax is calculated).
372 'tab_id' => 'discounts-taxes-tab',
373 'name' => 'discount_calculation_method',
374 'type' => 'select',
375 'label' => __('Discount Timing', 'easy-invoice'),
376 'grid_cols' => 'sm:col-span-2',
377 'section' => 'discount',
378 'options' => [
379 'before_tax' => __('Before Tax', 'easy-invoice'),
380 'after_tax' => __('After Tax', 'easy-invoice')
381 ],
382 'default_value' => 'before_tax',
383 'order' => 3,
384 'description' => __('Apply discount before tax (reduces taxable amount) or after tax (tax on full amount)', 'easy-invoice'),
385 ],
386 [
387 // Tax sub-fields sit on one row (3 + 3 = 6 cols) so
388 // Tax Rate and Price Includes Tax appear side-by-side
389 // under the Apply Tax checkbox.
390 'tab_id' => 'discounts-taxes-tab',
391 'name' => 'tax_rate',
392 'type' => 'number',
393 'label' => __('Tax Rate (%)', 'easy-invoice'),
394 'placeholder' => '0.00',
395 'grid_cols' => 'sm:col-span-3',
396 'section' => 'tax',
397 'min' => '0',
398 'max' => '100',
399 'step' => '0.01',
400 'order' => 4,
401 'default_value' => function() {
402 return easy_invoice_get_tax_rate();
403 },
404 'sanitize_callback' => 'floatval',
405 'validate_callback' => function($value) {
406 return is_numeric($value) && $value >= 0 && $value <= 100 ? true : __('Tax rate must be between 0 and 100.', 'easy-invoice');
407 },
408 'description' => __('The tax rate that will be applied to taxable items in this quote.', 'easy-invoice'),
409 ],
410 [
411 'tab_id' => 'discounts-taxes-tab',
412 'name' => 'prices_include_tax',
413 'type' => 'select',
414 'label' => __('Price Includes Tax', 'easy-invoice'),
415 'grid_cols' => 'sm:col-span-3',
416 'section' => 'tax',
417 'options' => [
418 'no' => __('No', 'easy-invoice'),
419 'yes' => __('Yes', 'easy-invoice')
420 ],
421 'order' => 5,
422 'description' => __('Choose whether the prices in this quote include tax or not.', 'easy-invoice'),
423 ],
424
425
426 // Payments Tab Fields
427
428 // Currency Section in Payment Tab
429 [
430 'tab_id' => 'payments-tab',
431 'id' => 'currency_code',
432 'type' => 'select',
433 'label' => __('Currency', 'easy-invoice'),
434 'name' => 'currency_code',
435 'grid_cols' => 'sm:col-span-3',
436 'section' => 'currency',
437 'options' => array_merge(
438 ['global' => __('Use from Global Settings', 'easy-invoice')],
439 \EasyInvoice\Helpers\CurrencyHelper::getCurrencyOptions()
440 ),
441 'default_value' => 'global',
442 'order' => 1,
443 'description' => __('Select the currency for this quote or use global settings.', 'easy-invoice'),
444 ],
445 [
446 'tab_id' => 'payments-tab',
447 'id' => 'currency_position',
448 'type' => 'select',
449 'label' => __('Currency Symbol Position', 'easy-invoice'),
450 'name' => 'currency_position',
451 'grid_cols' => 'sm:col-span-3',
452 'section' => 'currency',
453 'options' => [
454 'global' => __('Use from Global Settings', 'easy-invoice'),
455 'before' => __('Before Amount', 'easy-invoice'),
456 'after' => __('After Amount', 'easy-invoice'),
457 ],
458 'default_value' => 'global',
459 'order' => 2,
460 'description' => __('Choose where to display the currency symbol or use global setting.', 'easy-invoice'),
461 ],
462 ];
463 }
464
465 /**
466 * Register default templates
467 *
468 * @since 1.0.0
469 * @return void
470 */
471 public function registerDefaultTemplates(): void {
472 // Define all templates in a single array for easy modification by pro plugins
473 $all_templates = $this->getDefaultTemplatesArray();
474
475 // Apply filter to allow pro plugins to modify templates
476 $all_templates = apply_filters('easy_invoice_quote_templates', $all_templates);
477
478 // Register all templates from the array
479 foreach ($all_templates as $template_id => $template_config) {
480 $this->registerTemplate($template_id, $template_config);
481 }
482 }
483
484 /**
485 * Get default templates array
486 *
487 * @since 1.0.0
488 * @return array
489 */
490 private function getDefaultTemplatesArray(): array {
491 // Check if this is the free version (no pro plugin active)
492 $is_free_version = !easy_invoice_has_pro();
493
494 return [
495 'standard' => [
496 'name' => __('Standard', 'easy-invoice'),
497 'description' => __('A clean, professional quote template', 'easy-invoice'),
498 'icon' => 'fas fa-file-invoice',
499 'order' => 1,
500 'is_free' => true
501 ],
502 'legacy' => [
503 'name' => __('Legacy', 'easy-invoice'),
504 'description' => __('Clean, minimalist design with traditional business layout', 'easy-invoice'),
505 'icon' => 'fas fa-file-alt',
506 'order' => 2,
507 'is_free' => true
508 ],
509 'modern' => [
510 'name' => __('Modern', 'easy-invoice'),
511 'description' => __('A contemporary quote template', 'easy-invoice'),
512 'icon' => 'fas fa-star',
513 'order' => 3,
514 'is_free' => !$is_free_version
515 ],
516 'minimal' => [
517 'name' => __('Minimal', 'easy-invoice'),
518 'description' => __('A simple, clean quote template', 'easy-invoice'),
519 'icon' => 'fas fa-minus',
520 'order' => 4,
521 'is_free' => !$is_free_version
522 ]
523 ];
524 }
525
526 /**
527 * Register default item fields
528 *
529 * @since 1.0.0
530 * @return void
531 */
532 public function registerDefaultItemFields(): void {
533 // Define all item fields in a single array for easy modification by pro plugins
534 $all_item_fields = $this->getDefaultItemFieldsArray();
535
536 // Apply filter to allow pro plugins to modify item fields
537 $all_item_fields = apply_filters('easy_invoice_quote_item_fields', $all_item_fields);
538
539 // Register all item fields from the array
540 foreach ($all_item_fields as $field_config) {
541 $this->registerItemField($field_config);
542 }
543 }
544
545 /**
546 * Get default item fields array
547 *
548 * @since 1.0.0
549 * @return array
550 */
551 private function getDefaultItemFieldsArray(): array {
552 $fields = [
553 [
554 'id' => 'title',
555 'type' => 'text',
556 'label' => __('Item Title', 'easy-invoice'),
557 'name' => 'title',
558 'placeholder' => __('Enter item title', 'easy-invoice'),
559 'required' => true,
560 'container_class' => 'sm:col-span-6',
561 'order' => 1,
562 'description' => __('A short name for this item (e.g. Service Fee, Product Name).', 'easy-invoice'),
563 ],
564 [
565 'id' => 'description',
566 'type' => 'textarea',
567 'label' => __('Description', 'easy-invoice'),
568 'name' => 'description',
569 'placeholder' => __('Enter item description', 'easy-invoice'),
570 'container_class' => 'sm:col-span-6',
571 'rows' => 3,
572 'order' => 2,
573 'description' => __('Details about this item for your client.', 'easy-invoice'),
574 ],
575 [
576 'id' => 'quantity',
577 'type' => 'number',
578 'label' => __('Quantity', 'easy-invoice'),
579 'name' => 'quantity',
580 'placeholder' => '0',
581 'required' => true,
582 'container_class' => 'sm:col-span-1',
583 'min' => '0',
584 'step' => '0.01',
585 'default_value' => '0',
586 'order' => 3,
587 'description' => __('How many units of this item are being billed?', 'easy-invoice'),
588 ],
589 [
590 'id' => 'price',
591 'type' => 'number',
592 'label' => __('Price', 'easy-invoice'),
593 'name' => 'price',
594 'placeholder' => '0.00',
595 'required' => true,
596 'container_class' => 'sm:col-span-1',
597 'min' => '0',
598 'step' => '0.01',
599 'default_value' => '0.00',
600 'order' => 4,
601 'description' => __('Unit price for this item.', 'easy-invoice'),
602 ]
603 ];
604
605 // Add adjust field only if setting allows it
606 if (\EasyInvoice\Controllers\SettingsController::shouldShowQuoteAdjustField()) {
607 $fields[] = [
608 'id' => 'adjust_percentage',
609 'type' => 'number',
610 'label' => __('Adjust (%)', 'easy-invoice'),
611 'name' => 'adjust_percentage',
612 'placeholder' => '0.00',
613 'container_class' => 'sm:col-span-1',
614 'min' => '-100',
615 'max' => '1000',
616 'step' => '0.01',
617 'default_value' => '0.00',
618 'order' => 5,
619 'description' => __('Percentage adjustment to apply to this item (positive for markup, negative for discount).', 'easy-invoice'),
620 ];
621 $current_order = 5; // Adjust field is present
622 } else {
623 $current_order = 4; // Adjust field is not present, start after price field
624 }
625
626 // Calculate order for remaining fields
627
628 $fields[] = [
629 'id' => 'total',
630 'type' => 'number',
631 'label' => __('Total', 'easy-invoice'),
632 'name' => 'total',
633 'placeholder' => '0.00',
634 'container_class' => 'sm:col-span-1',
635 'min' => '0',
636 'step' => '0.01',
637 'default_value' => '0.00',
638 'readonly' => true,
639 'order' => $current_order + 1,
640 'description' => __('Total amount for this item (Quantity x Price) with adjustment applied.', 'easy-invoice'),
641 ];
642
643 $fields[] = [
644 'id' => 'taxable',
645 'type' => 'checkbox',
646 'label' => __('Taxable', 'easy-invoice'),
647 'name' => 'taxable',
648 'container_class' => 'sm:col-span-6',
649 'default_value' => '1',
650 'order' => $current_order + 2,
651 'description' => __('Check if this item is subject to tax.', 'easy-invoice'),
652 ];
653
654 return $fields;
655 }
656
657 /**
658 * Get client options for select field
659 *
660 * @since 1.0.0
661 * @return array
662 */
663 private function getClientOptions(): array {
664 $options = ['' => __('Select a client', 'easy-invoice')];
665
666 // Get clients from repository
667 $client_repository = new \EasyInvoice\Repositories\ClientRepository();
668 $clients = $client_repository->all();
669
670 foreach ($clients as $client) {
671 $client_name = $client->getBusinessClientName() ?: ($client->getFirstName() . ' ' . $client->getLastName());
672 $options[$client->getId()] = $client_name;
673 }
674
675 return $options;
676 }
677
678 /**
679 * Get the filter name for tabs
680 *
681 * @since 1.0.0
682 * @return string
683 */
684 protected function getTabFilterName(): string {
685 return 'easy_invoice_quote_register_tab';
686 }
687
688 /**
689 * Get the filter name for fields
690 *
691 * @since 1.0.0
692 * @return string
693 */
694 protected function getFieldFilterName(): string {
695 return 'easy_invoice_quote_register_field';
696 }
697
698 /**
699 * Get the filter name for templates
700 *
701 * @since 1.0.0
702 * @return string
703 */
704 protected function getTemplateFilterName(): string {
705 return 'easy_invoice_quote_register_template';
706 }
707
708 /**
709 * Get the filter name for item fields
710 *
711 * @since 1.0.0
712 * @return string
713 */
714 protected function getItemFieldFilterName(): string {
715 return 'easy_invoice_quote_register_item_field';
716 }
717 }