# easy-invoice/2.3.5/assets/js/bulk-send-email-teaser.js

Easy Invoice – Invoice Generator, PDF Quotes &amp; Payments, version 2.3.5. 105 lines.

- Page: https://pluginprobe.com/plugins/easy-invoice/2.3.5/code/assets/js/bulk-send-email-teaser.js
- Raw: https://pluginprobe.com/plugins/easy-invoice/2.3.5/raw/assets/js/bulk-send-email-teaser.js
- Modified: 2026-05-13T03:45:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-invoice/2.3.5/code/assets/js/bulk-send-email-teaser.js#L10-L20`.

```javascript
/* global jQuery, easyInvoiceBulkSendTeaser, EasyInvoiceConfirmation, EasyInvoiceToast */
/**
 * Free-side Pro bulk-action teaser
 *
 * Owns two bulk-action options on the Invoice and Quote listings:
 *   • send_email — "Send Email (Pro)"
 *   • export     — "Export Selected (Pro)"
 *
 * Both options are visible to ALL users (Free + Pro) so the feature is
 * discoverable. When Pro is INACTIVE we intercept submit and open the
 * EasyInvoiceConfirmation upgrade dialog. When Pro IS active this script
 * does nothing — the Pro plugin's own handlers take over.
 *
 * The send_email option is injected by this script (Free templates never
 * shipped it). The export option is already in the Free templates (it pre-
 * dates this work), so we only re-label it with the (Pro) suffix via the
 * <option> tag in the template and intercept its submit here.
 */
(function ($) {
    'use strict';

    if (typeof easyInvoiceBulkSendTeaser === 'undefined') {
        return;
    }

    var cfg = easyInvoiceBulkSendTeaser;
    var t = cfg.i18n || {};

    // If Pro is active, Pro's own JS handles everything.
    if (cfg.hasPro) {
        return;
    }

    // Map of Pro-gated bulk actions → upgrade-dialog copy. Easy to extend
    // when more Pro-only bulk actions land.
    var PRO_ACTIONS = {
        send_email: {
            featureName: t.send_email_feature_name || 'Bulk Send Email',
            description: t.send_email_feature_description ||
                'Select multiple invoices or quotes and send the configured "Available" email to every selected document\'s client in a single click.'
        },
        export: {
            featureName: t.export_feature_name || 'Bulk Export Selected',
            description: t.export_feature_description ||
                'Export your selected invoices or quotes to a clean CSV — perfect for accounting tools, audit trails, or migration to another system.'
        }
    };

    $(function () {
        var $form = $('#bulk-action-form');
        if (!$form.length) {
            return;
        }

        var $select = $form.find('select[name="bulk_action"]');
        if (!$select.length) {
            return;
        }

        // Inject the Send Email option (the templates don't ship it).
        if (!$select.find('option[value="send_email"]').length) {
            $select.append(
                $('<option>', {
                    value: 'send_email',
                    'data-requires-pro': '1'
                }).text(t.send_email_label || 'Send Email (Pro)')
            );
        }

        // Hijack submit only when one of our Pro actions is selected. Attach
        // with native addEventListener in CAPTURE PHASE so we run BEFORE the
        // listing template's own inline jQuery submit handler (especially on
        // the Quote listing, which AJAX-routes every bulk action). Without
        // capture-phase, the user would briefly see the listing's generic
        // confirm dialog before our upgrade popup ever fires.
        $form[0].addEventListener('submit', function (e) {
            var action = $select.val();
            if (!action || !PRO_ACTIONS[action]) {
                return;
            }
            e.preventDefault();
            e.stopImmediatePropagation();
            e.stopPropagation();
            showUpgradePrompt(PRO_ACTIONS[action]);
        }, true);
    });

    function showUpgradePrompt(feature) {
        if (window.EasyInvoiceConfirmation && typeof window.EasyInvoiceConfirmation.showUpgradeDialog === 'function') {
            window.EasyInvoiceConfirmation.showUpgradeDialog({
                featureName: feature.featureName,
                description: feature.description,
                onUpgrade: function () {
                    window.open(cfg.upgradeUrl || 'https://matrixaddons.com/plugins/easy-invoice/#pricing', '_blank');
                }
            });
        } else if (window.EasyInvoiceToast) {
            window.EasyInvoiceToast.warning(
                (t.upgrade_required || 'This action requires Easy Invoice Pro.')
            );
            window.open(cfg.upgradeUrl || 'https://matrixaddons.com/plugins/easy-invoice/#pricing', '_blank');
        }
    }
})(jQuery);

```
