=== LAFU Sales Reports for WooCommerce ===
Contributors: elsama101
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.5.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: woocommerce, reports, sales, csv, pdf

Scheduled CSV and PDF WooCommerce order reports by email with HPOS support.

== Description ==

**LAFU Sales Reports for WooCommerce** sends order summaries on the days you choose each month. Reports include paid orders in a clear **from–through** date range (site timezone), with CSV and PDF attachments.

= Features =

* **CSV and PDF** exports with payment method, tax total, and order total.
* **Comma-separated To / Cc / Bcc** recipients and customizable email subject.
* **Day-of-month schedule** (1–28) with a repeater UI.
* **Manual send** with optional custom date range (month-to-date by default).
* **Report filters** by payment method, customer, product, or category.
* **Customization** tab for column labels and payment method names.
* **Logs** tab and JSON settings export/import.
* **HPOS compatible** — works with WooCommerce custom order tables.
* **`wp_mail`** delivery (SMTP plugins supported).
= WooCommerce =

Requires WooCommerce 7.0+. Tested with WooCommerce 9.8 and WordPress 7.0.

== Installation ==

1. Install and activate **WooCommerce**.
2. Upload the `lafu-sales-reports-for-woocommerce` folder to `/wp-content/plugins/`.
3. Activate **LAFU Sales Reports for WooCommerce**.
4. Open **WooCommerce → Sales Reports**, set recipients and schedule days, then save.

== Frequently Asked Questions ==

= Does this require WooCommerce? =

Yes. The plugin registers under the WooCommerce admin menu and queries orders via WooCommerce APIs.

= Does it work with HPOS (custom order tables)? =

Yes. The plugin declares compatibility with WooCommerce High-Performance Order Storage.

= How do I translate the admin and reports? =

Use WordPress.org translations or a translation plugin for the `lafu-sales-reports-for-woocommerce` text domain.

= Can I send a test report before the schedule runs? =

Yes. Use **Generate & Send now** on the Reports tab. Leave the date fields empty for month-to-date, or set a custom range.

== Screenshots ==

1. Reports tab — recipients, order statuses, columns, filters, schedule, and manual send.
2. Settings tab — report file label, column labels, and payment method labels.
3. Logs tab — sent report history and settings import/export.

== For developers ==

The plugin exposes a small, stable API so other plugins can reuse the report engine. The plugin itself still ships and uses a single report; these are extension points only.

* `LAFU_SRFW_Plugin::run_report( array $settings, string $mode = 'manual', array $range = null )` — generate and email a report from your own settings array.
* `LAFU_SRFW_Plugin::get_report_setting_defaults()` — the default settings shape.
* `LAFU_SRFW_Plugin::sanitize_report_settings( array $data )` — sanitize an arbitrary settings array into the canonical shape.
* `LAFU_SRFW_Plugin::compute_report_range( array $settings, bool $is_manual = false )` — the date range a report would use.
* `do_action( 'lafu_srfw_run_scheduled_reports', int $today_dom )` — fires daily so add-ons can run extra scheduled reports.

The global instance is available as `$GLOBALS['lafu_srfw_plugin']`.

== Changelog ==

= 1.5.3 =
* Fixed a PHP syntax error in the admin settings view.

= 1.5.2 =
* Maintenance release: packaging cleanup and readme updates. No functional changes.

= 1.5.1 =
* Housekeeping: cleaner plugin package and minor maintenance. No functional changes.

= 1.5.0 =
* Added a documented developer API (`run_report()`, settings helpers, and the `lafu_srfw_run_scheduled_reports` action) so add-ons can reuse the report engine. The plugin still ships and uses a single report.

= 1.4.2 =
* Simplified the free plugin to a single report configuration.
* Use literal hook name prefixes so dynamic action names are clearly namespaced.
* Harden CSV exports against spreadsheet formula injection.
* Corrected readme FAQ and screenshots to match the Reports / Settings tabs.

= 1.4.1 =
* Scheduled days now start empty so you choose exactly when reports send (no preset days).
* Removed bundled directory image assets from the plugin package.

= 1.4.0 =
* Fix: no fatal errors if WooCommerce is deactivated — the plugin pauses cleanly until WooCommerce is back.
* Improved: small admin UI polish and translation refresh.

= 1.3.0 =
* Tested with WordPress 7.0.
* Redesigned admin: a Reports tab, a separate Settings tab, and clearer navigation.
* WooCommerce-style dropdowns with type-ahead search now initialize reliably on the plugin screen.
* Clearer admin notice when WooCommerce is missing.
* Various small UI and stability fixes.

= 1.2.0 =
* Refactored monolithic plugin class into focused traits (admin, orders, PDF, CSV, scheduler, settings).
* Added LAFU_SRFW_Constants, LAFU_SRFW_Utils, and utility test suite.
* Paginated WooCommerce order queries (100 per batch) instead of unbounded `limit => -1`.
* WooCommerce dependency header, HPOS compatibility declaration, and admin notice when WooCommerce is missing.
* Report filters (payment method, user, product, category).
* 20 additional bundled translations (excluding Hebrew).
* `.distignore` for WordPress.org releases; removed unused large SVG asset.
* Removed dead CSS and duplicate `lafu_wcsr_generate_now` admin hook.

= 1.1.6 =
* Added payment method label overrides in Customization.
* Payment method defaults now prefer gateway/plugin titles (with PPCP defaulting to PayPal).
* Improved payment method customization UI with clearer section spacing and reliable detected-method listing.

= 1.1.5 =
* Report payment method label now prefers a clean gateway name (for example Kustom, Stripe) instead of long gateway titles.

= 1.1.3 =
* Removed legacy/stray Download button from manual report actions; only Generate and Email remain.

= 1.1.2 =
* Order queries use `date_after` / `date_before` (full local day bounds) for reliable ranges with HPOS.
* Reports include processing, completed, and refunded orders by default. Adjust in settings or via the `lafu_srfw_report_order_statuses` filter.

= 1.1.1 =
* Optional custom order date range for “Send report now” (test sends).

= 1.1.0 =
* Interval-based date ranges for scheduled sends; CSV/PDF tax and payment method; i18n + Finnish.

= 1.0.0 =
* Initial release.
