=== OrderCRM for WooCommerce ===
Contributors: timon-dimon
Tags: order management, woocommerce, sales dashboard, customer management, sales reports
Requires at least: 5.6
Tested up to: 7.0
Requires PHP: 8.0
Stable tag: 3.3.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Requires Plugins: woocommerce

WooCommerce frontend CRM: filter orders, search customers, and view sales charts—no WordPress admin access required.

== Description ==

OrderCRM for WooCommerce transforms your store's order management into a powerful, standalone frontend dashboard. Sales managers can filter orders by status, date, or customer, perform quick searches, and view detailed sales reports with interactive charts — all without accessing the WordPress admin area. Perfect for medium-sized businesses handling up to 1,000 orders per month.

== Why OrderCRM? ==

* 🚀 **Frontend Dashboard** — No admin access required. Your sales team works from a secure, custom interface.
* 🔍 **Advanced Filters** — Filter orders by status, date range, customer name, or order ID in seconds.
* ⚡ **Quick Search** — Find orders and clients instantly with our fast search engine.
* 📊 **Sales Reports** — Visualize revenue trends with beautiful charts and period-based reports.
* 🔒 **Secure by Design** — Sales managers get only the tools they need — no accidental site breakage.

= Recommended Plugins =

For full functionality, we recommend installing these additional plugins:
* **Advanced Shipment Tracking (Free)** - For tracking number management
* **WooCommerce PDF Invoices & Packing Slips** - For invoice generation

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/ordercrm-for-woocommerce` directory, or install through WordPress admin panel (the package includes Composer dependencies under `vendor/` for PDF export — no server-side `composer install` is required for typical ZIP installs)
2. Activate the plugin through the 'Plugins' menu in WordPress (PHP **GD** and **mbstring** extensions are required — activation will stop with a clear message if they are missing)
3. Configure the plugin settings under **OrderCRM** in your admin panel
4. Set up order status groups in the 'Statuses' tab

== Frequently Asked Questions ==

= Does this plugin work with custom order statuses? =

Yes! The plugin is designed to work with any custom order statuses, including those created by other plugins like Advanced Shipment Tracking.

= How do I configure order status groups? =

Go to OrderCRM → Settings → Statuses in your admin panel. You can organize statuses into three groups: "In Progress", "Completed", and "Cancelled".

= Will updating the plugin affect my existing orders? =

No. The plugin includes an automatic update system that safely migrates order statuses without data loss.

= Is this plugin compatible with other WooCommerce plugins? =

Yes, the plugin is designed to work alongside other WooCommerce plugins without conflicts.

= What are the system requirements? =

* WordPress 5.6 or higher
* WooCommerce 5.0 or higher
* PHP 8.0 or higher
* PHP extensions **GD** and **mbstring** (required for sales report PDF export via mPDF)

= Is report PDF stored on the server in uploads? =

No. The PDF is generated on demand and sent in the AJAX response only; it is not saved as a public file in the media library or uploads folder, to reduce exposure of commercial data.

== Screenshots ==

1. Dashboard overview with current orders
2. Customer profile management
3. Order status group configuration
4. Activity log and reporting
5. Sales reports with period filters and product demand summary

== Changelog ==

= 3.3.4 =
* **WordPress.org slug:** folder, main file, text domain, and wp-admin menu slug `ordercrm-for-woocommerce` (`[unique]-for-woocommerce` pattern); display name **OrderCRM for WooCommerce** unchanged.
* **Plugin Check:** readme short description (≤150 chars), 5 tags, Upgrade Notice (≤300 chars), Tested up to **7.0** — zero warnings on local check.
* **CRM logs:** login via `/crm-login/` writes **CRM login** activity (explicit log after `wp_signon`, symmetric with REST logout).
* **Transactional emails:** customer notification when CRM changes order status across transitions without WooCommerce core email hook (e.g. custom statuses).
* **Stability:** output buffering in `OrderCRM_Routes::load_template()`; Chart.js **4.5.1**; wp-admin Roles/Users tab fixes (role slug normalization, readable role names).

= 3.3.3 =
* **wp-admin — Reports tab:** new settings tab (before HPOS Test) to select `product_brand` terms in three columns (A–Z); saved to `reports_selected_product_brands`; Post/Redirect/Get save flow.
* **CRM Reports — selected brands block:** after non-completed orders table, shows TOP-5 products and TOP-5 categories pie for selected brands only (Completed + Processing statuses); **Selected brands:** label lists chosen names; block is hidden on screen and in PDF when no brands are selected.
* **CRM Reports PDF:** includes selected-brands section and `brands_categories_chart_image` snapshot (`#salesBrandsCategoriesChart`) with SVG fallback.
* **UI:** selected-brands block background `#B2BEB5` (distinct from all-products statistics `#DBDBDB`).

= 3.3.2 =
* **Security hardening (Release E, staged):** Stage 5.1 strict nonce mode for CRM REST reads added behind feature-flag `SALES_CRM_STRICT_REST_NONCE` (default OFF), with staged rollout/rollback controls and staging smoke validation.
* **Post-smoke hotfixes:** customer lookup schema compatibility for environments without `wc_customer_lookup.num_orders`; CRM login asset isolation fix to avoid plugin-induced root-relative static requests; logs UI refresh delay reduced to 10 seconds (`sales_crm_logs_cache_invalidate_delay` default).

= 3.3.1 =
* **Security hardening (Release D completed):** legacy invoice storage migration (Stage 4.1) finalized with protected storage, lazy + background migration, and reversible metadata rollback flow.
* **Security hardening:** CRM REST same-origin policy (Stage 4.2) enabled for routes `/sales-crm/v1/*` with `Origin` validation and explicit cross-origin `403` blocking, without frontend/report regressions on staging.

= 3.3.0 =
* **Security hardening (Release B completed):** invoice storage directory is protected (`sales-crm-invoices`, deny direct access) and invoice filenames are now unpredictable (`{order}-{random}.{ext}`) while user download name remains unchanged.
* **Security hardening:** staged verifications passed for Stage 1.1, 1.2, 1.3, 2.1 and 2.2 on test environment without CRM UI regressions.

= 3.2.9 =
* **wp-admin — General tab:** logo settings are now on the **General** settings tab (single form, one Save button). The separate **Logo** tab was removed; legacy `?tab=logo` redirects to General.
* **i18n (ru_RU):** success notice after saving General settings — «Общие настройки сохранены.»

= 3.2.8 =
* **WordPress.org Plugin Check:** full compliance (0 errors, 0 warnings) on release ZIP — directory submission readiness.
* **Compatibility:** Tested up to WordPress 7.0 (`readme.txt` and plugin header synchronized).
* **i18n:** translators comments for placeholder strings in order status labels and frontend messages.
* **Verification:** Plugin Check and staging smoke §19 **2026-07-07** — no CRM UI or workflow changes.

= 3.2.7 =
* **Create order — view-model (T-TPL-4d):** `handle_add_order_page_post()` and `get_add_order_view()` centralize POST dispatch and display data (totals, customer, country options); `add-order.php` template is display-focused. No CRM UI changes.
* **Verification:** staging smoke **2026-07-06** — add-order (#2234, #2237), cross-smoke §19 (order card, products, reports, logout/login); phase-g runner `all_checks_passed: true`.

= 3.2.6 =
* **Create order — customer & discount POST (T-TPL-4c-i):** search/select customer, apply discount %, and clear draft handled in `Sales_CRM_Order_Service::handle_add_order_draft_mutations_post()`; template dispatches a single service call; REST customer selection unchanged.
* **Create order — create POST (T-TPL-4c-ii):** order creation and new customer creation moved to `handle_create_order_post()` and `handle_create_new_customer_post()` (redirect to order card, JS fallback when headers already sent).
* **Verification:** staging smoke **2026-07-06** — 4c-i (search/select, discount, clear); 4c-ii (create with existing customer, create with new customer + phone, order #2223, transactional email); **HPOS on**.

= 3.2.5 =
* **Create order — draft session (T-TPL-4a):** temporary cart and customer data use `Sales_CRM_Order_Draft_Session` (WC session with user-meta fallback); template no longer defines global session helpers.
* **Create order — cart POST (T-TPL-4b):** add / remove / edit quantity handled in `Sales_CRM_Order_Service::handle_temp_cart_post()`; correct message when adding the same simple SKU again (**Product quantity increased.**).
* **Create order — totals:** draft order footer totals (subtotal, VAT, discount) recalculate correctly for simple and variation lines; CRM discount % is kept after **Create customer**.
* **CRM products catalog (T-TPL-3):** product list filters and POST update logic moved to `Sales_CRM_Products_List_Service`; template is display-focused.
* **CRM Reports pie chart:** improved category label layout (less overlap; HTML legend).
* **Verification:** staging smoke **2026-07-06** — add-order cart, totals, discount + new customer; products catalog.

= 3.2.4 =
* **CRM Reports — category pie chart:** on `/crm-dashboard/reports/`, **Statistics among all products** shows TOP-5 products (table) and **TOP-5 categories** (Chart.js pie, integer % to 100, **Other** for the rest); cached per report period.
* **CRM Reports PDF:** category pie chart above the sold-products table; sync and async export paths; SVG fallback when chart PNG is unavailable.
* **CRM Reports layout:** section heading styled like other CRM table blocks (`sales-crm-table-container`).
* **wp-admin — Statuses tab (T-TPL-1):** saving status groups uses Post/Redirect/Get — after **Save**, page refresh (F5) no longer shows browser resubmit warning; standard green success notice; checkbox selections persist correctly. Template is display-only; logic in `Sales_CRM_Admin_Settings`.
* **Verification:** staging smoke **2026-07-03** — reports pie on screen + PDF; Statuses tab Save, PRG, notice.

= 3.2.3 =
* **CRM logs filter:** user dropdown on `/crm-dashboard/logs/` shows names as **Last name First name**, sorted A–Z by last name (same display rules as customer/order profiles).
* **CRM products filter:** **Brand** select on `/crm-dashboard/products/` built from WooCommerce `product_brand` taxonomy (A–Z); combines with search, category, and stock filters; REST `GET /products` accepts `brand` query param. Select is hidden when the taxonomy is not registered.
* **Report PDF:** visible preparation animation on export; optional async generation path (filter `sales_crm_pdf_export_async_enabled`, default **off** — sync download unchanged).
* **Performance:** activity log cache invalidation debounced via Action Scheduler (T-11.4) — faster order/log writes on busy stores; new log rows appear within ~20 s.
* **Verification:** staging smoke **2026-07-02** (phase-g `wave682_*`, `wave683_*`, `wave684_*`).

= 3.2.2 =
* **Report cache (performance):** after order status changes and new orders, CRM report transients clear via WooCommerce Action Scheduler (debounced, typically within 30–60 seconds) instead of heavy synchronous SQL on every mutation — faster order card REST responses. Report numbers stay the same; brief delay before refreshed totals is expected. Filters: `sales_crm_deferred_report_cache_invalidation_enabled`, `sales_crm_report_cache_invalidate_delay`.
* **Fixes:** WooCommerce refunded-order email shim (theme template recursion); admin settings tab labels on WP 6.7+; CRM frontend asset dequeue when `wp_enqueue_scripts` already ran.
* **Verification:** staging smoke **2026-07-01** (phase-g `wave682_*`, report invalidation after debounce). No CRM UI changes.

= 3.2.1 =
* **Transactional emails from CRM:** WooCommerce customer and admin notifications on create order, customer notes, status changes, and AST tracking — reliable delivery via synchronous sending by default (no theme `functions.php` defer filters required).
* **Create order:** status remains `pending` in the database; client receives the standard WooCommerce notification (`customer_on_hold_order`); managers receive New order; `billing_email` required with user-email fallback.
* **Optional defer:** filters `sales_crm_enable_wc_deferred_transactional_emails` and `sales_crm_defer_transactional_emails_on_order_mutation` default to **false**; set to `true` for faster REST TTFB with queue flush on REST/shutdown.
* **Compatibility:** verified with Advanced Shipment Tracking and WooCommerce PDF Invoices & Packing Slips (staging orders #2155, #2159, 2026-07-01). No CRM UI changes.

= 3.2.0 =
* **Background jobs (T-11.0):** WooCommerce Action Scheduler integration via `Sales_CRM_Background_Jobs` (group `sales-crm`); runtime runner `wave68_*` checks.
* **Login/logout log cleanup (T-11.1):** daily housekeeping moved from WP-Cron to Action Scheduler (`sales_crm_delete_old_login_logout_logs`); legacy WP-Cron removed on migrate; filter `sales_crm_login_logout_log_retention_days` (default 62 days). No UX change.
* **WP 6.7+ i18n:** translations load on `init`; lazy admin settings tabs; capability slugs without early `__()` on `plugins_loaded`; early custom order status registration without textdomain before `init`.
* **WooCommerce email compat:** plugin shim when the active theme overrides `customer-refunded-order.php` without `$user_login`.
* **Verification:** staging smoke runner **2026-06-30** (`all_checks_passed: true`, `wave68_login_logout_cleanup_*`).

= 3.1.9 =
* **Templates (T-03):** orders list table (`orders-table.php`) — all display logic moved to `Sales_CRM_Order_Service::build_orders_table_rows()`; customer card sidebar totals use pre-formatted HTML from `get_customer_profile_for_view()`. No UX changes; staging smoke passed.
* **Ops (T-14):** production HTTPS/TLS and cookie-auth verification documented (`PRODUCTION_HTTPS_CHECKLIST.md`); runtime runner checks `wave67_*` (cookie pattern, login nocache, URL scheme on HTTPS).
* **Diagnostics:** phase-g runner prefers sample order ID from REST orders list (`shop_order`) for reliable wave4/wave64 checks.

= 3.1.8 =
* **Hotfix — CRM logout:** sidebar "Logout" uses REST `POST /auth/logout` (class `sales-crm-logout`) instead of `wp_logout_url()` — no WordPress "confirm logout" page; redirect straight to `/crm-login/`.

= 3.1.7 =
* **Hotfix — CRM login (critical):** removed post-login `has_crm_access()` check that logged out valid users with false `no_access` (regression from 3.1.5–3.1.6). Access is enforced on CRM pages after redirect — same as before 3.1.5.
* **wp_signon():** restored `wp_signon( $creds, false )` as in 3.1.4 for production HTTPS cookie compatibility.
* **Login page:** `data-sales-crm-version` on `<body>` for deploy verification when HTML comments are stripped.

= 3.1.6 =
* **Hotfix — CRM login (root cause):** stop reading WordPress core `error` query var on `/crm-login/` (collision caused false "An error occurred during login" banner on HTTPS production). CRM errors now use `crm_login_error` only.
* **Login:** fallback route detection by URI when rewrite query var is missing; fix theme stylesheet MIME error on login page.

= 3.1.5 =
* **Hotfix — CRM login:** fixed false error banner "An error occurred during login" on `/crm-login/` when the form was not submitted (stale nonce redirect, unknown `error` query codes, or cached login HTML).
* **Login:** explicit message for expired form session (`invalid_nonce`); show errors only for known codes; `wp_signon()` uses secure cookies on HTTPS; check CRM access after sign-in; `nocache_headers()` on the login page.

= 3.1.4 =
* **Reports cache (wave 6.3, T-09):** transient caching for heavy CRM reports (sales stats, TOP-5 line items, year list); faster `/crm-reports/` and PDF export on repeat views; cache invalidates on order status change and new orders. No UX changes.
* **Deferred transactional emails (T-10):** WooCommerce emails deferred on all CRM order mutations (status, line items, discount, invoice, AST tracking); faster order card REST responses. Enable **Deferred transactional emails** in WooCommerce → Settings → Advanced → Features for best results.
* **Verification:** staging smoke + runtime runners `wave64_*` and `wave65_*`.

= 3.1.3 =
* **List performance (wave 6.2, T-08):** batch prefetch for customers, orders, and products lists; reduced N+1 without UX changes to tables or REST contracts.
* **Activity logs (T-12 / phase F):** bounded merge total in `get_logs()` — removes unbounded PHP merge for pagination count; faster logs screen on large datasets.
* **Verification:** staging smoke + runtime runners `wave62_*` and `wave63_*`; phase-f scenarios S1–S6 passed.

= 3.1.2 =
* **RBAC (wave 6.1, T-07):** centralized CRM capability checks via `sales_crm_user_can()` and `Sales_CRM_Capabilities`; aligned UI menus, REST permission callbacks, and CRM role settings sync.
* **Order notes:** permission uses `add_order_notes` (with legacy `edit_sales_crm` fallback) consistently in templates and REST.
* **Reports PDF:** export allowed for CRM admin UI or users with `view_reports` capability.
* **Verification:** staging role smoke and runtime runner `wave61_rbac_*` passed.

= 3.1.1 =
* **Architecture (wave 5):** domain classes moved under `includes/modules/` — `orders/`, `customers/`, `logs/`, `products/` with module loaders.
* **Products catalog (T-01):** list/read logic in `Sales_CRM_Products_List_Service`; CRM products page uses a prepared view-model (no SQL in template).
* **REST:** `GET /sales-crm/v1/products` — paginated catalog list with filters (`search`, `category`, `stock`, `page`); stock filter accepts all WooCommerce stock statuses (including custom statuses such as out of production).
* **Products UI:** stock status filter and edit modal both use `wc_get_product_stock_status_options()`; fixes for status-only updates from the dashboard modal.
* **CRM UI → REST (wave 4):** CRM frontend migrated from legacy AJAX to `sales-crm/v1` (orders, customers, products search, order card, catalog edit, logout, invoices, report PDF); see `CHANGELOG.md` for full notes.
* **Fixed:** block adding `outofstock` / `out_of_production` items to orders; faster order status change (deferred transactional emails).

= 3.1.0 =
* **Architecture (wave 3 complete):** `Sales_CRM_Customer_Repository` and `Sales_CRM_Activity_Log_Repository`; DTO read-models for customer list/profile and activity logs; templates `customer.php`, `customers.php`, and `logs.php` use service layer instead of direct DB/user API calls.
* **Activity log:** clearer event sources (manager notes, tracking number, line-item changes); filter "Order note" maps to manual manager notes only.
* **Create order:** reliable intl-tel-input phone mask (country flag, placeholder, BY/UA/RU validation); scripts enqueued via `sales_crm_enqueue_phone_input_assets()`.
* **Fixed:** variation line price 0 when WooCommerce `_price` meta is empty; CRM discount VAT display; customer password reset white screen.
* **Docs:** `docs/reports/WAVE_3_ACCEPTANCE_REPORT.md`; see `CHANGELOG.md` for full developer notes.

= 3.0.3 =
* **Architecture (wave 2 complete):** order logic split into sub-services — `Sales_CRM_Order_Discount_Service`, `Sales_CRM_Order_Line_Item_Service`, `Sales_CRM_Order_Crm_Actions_Service`, shared `Sales_CRM_Order_Mutation_Support`; `Sales_CRM_Order_Service` is a thin facade delegating to them.
* **Create order:** legacy `wc_create_order()` path removed from `add-order.php`; creation always uses `Sales_CRM_Order_Service::create_order_from_crm_session()` (no `WOO_SALES_CRM_V3_ENABLED` branch).
* **Order list:** `Sales_CRM_Order_Repository::query_for_crm_list()` — single entry for CRM status-group filters before `wc_get_orders`.
* **Order card (POST):** all mutations via order service (status, notes, qty, SKU, discount, address, AST); CRM discount meta recalculated after SKU add / line remove when a percent discount is active.
* **VAT label:** `get_vat_rate_label_for_order()` and **VAT (XX%)** in order totals; historical rate from order tax snapshot.
* **Docs:** wave 2 marked closed in `ARCHITECTURE_IDEALSTATE_PLAN.md`; updated `SERVICES_FACADE.md`.
* **VAT with CRM discount:** VAT and subtotal rows in the order totals table are scaled proportionally when a CRM discount is applied (taxable base after discount); without discount, values match WooCommerce `get_total_tax()` / `get_subtotal()`.
* **Order totals row order:** gross total and discount first, then subtotal without VAT and VAT breakdown, then final total with discount (`order-items-table.php`).
* **Docs:** `docs/guides/WOOCOMMERCE_TAX_PRICING_CRM.md` — CRM discount and VAT calculation (with/without discount).
* **Architecture:** `Sales_CRM_Order_Repository` and `Sales_CRM_Service_Factory::order_repository()`; optional **Strangler** path for **Create order** in CRM when `WOO_SALES_CRM_V3_ENABLED` is set in wp-config (`Sales_CRM_Order_Service::create_order_from_crm_session`). Template views use order service helpers (`get_wc_order`, `get_order_statuses_for_ui`, `get_status_display_name`, `get_order_notes_for_display`) instead of scattered WooCommerce calls.
* **Security / refactor (internal):** Phase **B** order notes via WC API; phases **C** (SQL hardening) and **D** (XSS escapes) per project docs; full-tree **WPCS** pass remains the project baseline.
* **Pricing & tax:** CRM order line totals and product/dashboard pricing aligned with WooCommerce tax settings (`wc_prices_include_tax`, WC totals); preview totals for the temporary cart use a short-lived `WC_Order` + `calculate_totals()`.
* **VAT rate label:** order totals show **VAT (XX%)** / **НДС (XX%)** next to the tax amount; rate from the order tax snapshot (historical) with fallback to current WC standard rates; see `docs/guides/WOOCOMMERCE_TAX_PRICING_CRM.md`.
* **Docs:** `ARCHITECTURE_IDEALSTATE_PLAN.md`, template order-logic inventory, Strangler create-order acceptance on staging (see `CHANGELOG.md`).
* **i18n:** new/updated Russian strings for order-service errors and `VAT (%s):` — recompile `languages/sales-crm-ru_RU.mo` if you ship custom PO files.

= 3.0.1 =
* **Architecture:** centralized **facade services** — `Sales_CRM_Customer_Service`, `Sales_CRM_Log_Service` (with `log()` for WC logger and CRM login/logout events), continued use of `Sales_CRM_Order_Service`; `Sales_CRM_Orders` loads customer display data via Customer Service; plugin boot order updated (`customers` → `customer-service` → `orders`).
* **Logging:** CRM activity and admin flows use `Sales_CRM_Log_Service` instead of direct `Sales_CRM_Logger` in touched code; `Sales_CRM_Admin_Settings::get_logs()` uses the same log pipeline as the CRM logs UI.
* **Reports PDF:** more reliable download (output buffer flush before binary, relaxed chart PNG validation with graceful skip, client detects `%PDF` even if `Content-Type` is wrong); AJAX URL uses **relative** `admin-ajax.php`; header band uses **primary color** from settings.
* **Testing:** optional `define( 'SALES_CRM_DISABLE_PDF_RATE_LIMIT', true );` in wp-config disables PDF rate limiting (remove after tests).
* **Mobile block page:** `<body class="mobile-blocked-page">` so **primary color** background from settings applies.
* **i18n:** fixed Russian catalog entry for discount log line (`msgid` must match `__()` placeholders `%1$s` / `%2$d`); recompile `.mo` after `.po` updates.
* Developer changelog: `CHANGELOG.md` (Keep a Changelog); internal docs: `docs/features/SERVICES_FACADE.md`, updated `REPORTS_PDF_EXPORT.md` and `REFACTORING_3_0_STRATEGY.md`.
* **Refactoring phase A (docs):** updated `docs/reports/HPOS_CODE_INVENTORY.md`; added `REFACTORING_SECURITY_AUDIT_MATRIX.md` and `REFACTORING_ACCEPTANCE_CRITERIA.md` (audit matrix + formal acceptance criteria for next phases).

= 3.0.0 =
* **Breaking:** minimum **PHP 8.0** required (PHP 7.x no longer supported). Upgrade PHP before updating; use 2.1.x on older PHP if needed.
* **Baseline for large refactor:** internal strategy uses **Strangler pattern** — new code paths can be gated with `WOO_SALES_CRM_V3_ENABLED` (aligned with CRM 3.0 naming; see `developer/docs/reports/REFACTORING_3_0_STRATEGY.md`).
* Optional: set `define('WOO_SALES_CRM_V3_ENABLED', true);` or `CRM_V3_ENABLED` in **wp-config.php** when you are ready to test the refactored branch (default remains legacy). Old names `WOO_SALES_CRM_V2_ENABLED` / `CRM_V2_ENABLED` are still read for backward compatibility.
* Version alignment: `version.php`, plugin header, and Stable tag set to **3.0.0**; Composer `require` PHP **^8.0**.
* HPOS-related order migrations already use WooCommerce APIs where previously adjusted (see project docs).

= 2.1.2 =
* Reports: **Download PDF** — export the selected period to PDF (mPDF); chart embedded as PNG from the on-screen canvas
* Reports PDF: full list of non-completed orders for the period; product table includes all aggregated rows with total quantity greater than one (screen still shows TOP-5)
* Reports PDF: header logo from CRM settings; page numbers; currency uses the `rub.` string in PDF output where the ruble glyph is unreliable in PDF fonts
* Security: PDF output is not cached under `uploads`; delivery only through authenticated AJAX (`view_reports` / administrator)
* Anti-abuse: rate limiting for PDF generation (default: about once per hour per user, optional IP-based limit; filterable)
* Activation: require PHP extensions **GD** and **mbstring** (aligned with mPDF)
* Bundled `composer.json`, `composer.lock`, and `vendor/` (mPDF) for “upload and run” installs; developer docs: `docs/features/REPORTS_PDF_EXPORT.md`
* Russian translations updated for PDF and activation messages

= 2.1.1 =
* Reports: choose month, quarter, or year; Apply filter; year dropdown lists only years that have orders (classic posts + HPOS)
* Reports: Chart.js graphs adapted to period (daily / quarterly multi-series / yearly by month)
* Reports: "Products for period (TOP-5)" — aggregate quantities by SKU from Completed + In Progress status groups (per CRM settings)
* Reports: "Orders for period" lists non-completed orders only; pagination uses CRM "items per page" setting
* Reports: amounts shown with store currency via wc_price(); chart bootstrapped from reports-chart.js (no inline scripts in template)
* Updated Russian translations for new strings

= 1.2.9.3 =
* Added CRM order identification icon (dashicons-desktop) in order lists
* CRM-created orders now display a blue desktop icon next to order numbers
* Icon appears in dashboard, orders, and customer sections
* Added tooltip showing which manager created the order via CRM
* Enhanced order tracking for CRM vs. regular website orders
* Improved visual distinction between order creation methods

= 1.2.8.7 =
* Customer search fix: Completely redesigned customer search algorithm
* Fixed incomplete customer search results - now finds all customers with matching names
* Enhanced search functionality across all CRM sections (customers list, order creation)
* Improved search by first name, last name, full name, and phone numbers
* Added comprehensive search across WordPress user fields and meta fields
* Eliminated duplicate results in customer search
* Performance optimization: Enhanced logging system with intelligent caching
* Optimized log retrieval with 5-minute caching for improved performance
* Improved SQL queries for system logs and order notes processing
* Enhanced pagination and filtering for better user experience
* Reduced database load through efficient log processing
* Added automatic cache clearing when new logs are created
* Optimized memory usage for large log datasets
* Improved overall CRM dashboard responsiveness
* Performance optimization: Enhanced logging system with intelligent caching
* Optimized log retrieval with 5-minute caching for improved performance
* Improved SQL queries for system logs and order notes processing
* Enhanced pagination and filtering for better user experience
* Reduced database load through efficient log processing
* Added automatic cache clearing when new logs are created
* Optimized memory usage for large log datasets
* Improved overall CRM dashboard responsiveness

= 1.2.8.6 =
* Critical bug fix: Resolved empty products display issue in CRM dashboard
* Performance optimization with improved SQL queries and caching system
* Replaced inefficient nested SQL subqueries with optimized JOIN operations
* Implemented comprehensive caching for product search, categories, and filters
* Fixed critical memory usage issue with unlimited product loading (limit -1)
* Added new Sales_CRM_Cache_Manager class for intelligent caching
* Optimized database queries for 3-5x faster performance
* Implemented automatic cache clearing on product and category changes
* Reduced memory usage by 70-90% through result limiting
* Added 90%+ cache hit rate for frequently accessed data
* Enhanced overall system responsiveness and scalability

= 1.2.8.4 =
* Complete Russian localization with 376+ translated strings
* Full interface translation for all frontend and backend elements
* Improved localization system with automatic language detection
* Fixed product search functionality by SKU and category filtering
* Resolved display issues with added items in order creation
* Enhanced JavaScript localization replacing hardcoded English strings
* Optimized translation file compilation and loading system
* Added debugging support for translation loading
* Comprehensive localization coverage: menus, forms, notifications, modals
* Improved user experience for Russian-speaking users

= 1.2.8.0 =
* Added default plugin logo implementation across all CRM pages
* Implemented automatic fallback to default logo when no custom logo is uploaded
* Enhanced logo display on login, mobile-blocked, no-access pages and main CRM layout
* Added new methods in admin settings class for logo management with default fallback
* Improved user experience with consistent branding across all CRM interfaces
* Maintained backward compatibility with existing custom logo functionality

= 1.2.7.8 =
* Implemented PHPCS (PHP CodeSniffer) for automatic code formatting
* Added WordPress coding standards compliance with adapted rules for plugins
* Created comprehensive development tools and automation scripts
* Organized project structure according to WordPress/WooCommerce standards
* Added detailed documentation for code formatting and development workflow
* Prepared plugin for production deployment with clean file structure
* Enhanced code quality and maintainability standards

= 1.2.7.7 =
* Added HPOS (High-Performance Order Storage) compatibility testing
* Implemented new "HPOS Test" tab in admin settings with two-column layout
* Enhanced HPOS status detection with multiple fallback methods
* Improved error handling for HPOS compatibility checks
* Added comprehensive HPOS compatibility information and testing instructions
* Removed debug logging for production use
* Cleaned up test files and prepared for release

= 1.2.7.6 =
* Migrated from PHP sessions to WC()->session for better compatibility
* Fixed customer data persistence issues in order creation
* Improved menu order: moved "Products" above "Reports"
* Enhanced AJAX customer selection functionality
* Optimized temporary data storage using WooCommerce session system
* Added fallback to user meta for authenticated users

= 1.2.7.4 =
* Added automatic update system for order statuses
* Implemented flexible status group management
* Fixed compatibility issues with Advanced Shipment Tracking
* Improved order display logic in dashboard
* Added comprehensive error handling
* Removed debug logging for production use

= 1.2.7.2 =
* Enhanced customer search functionality
* Improved order tracking system
* Bug fixes and performance improvements

= 1.2.7.1 =
* Initial release with core CRM functionality
* Basic order and customer management
* Activity logging system

== Upgrade Notice ==

= 3.3.4 =
WordPress.org slug is now `ordercrm-for-woocommerce` — rename the plugin folder after update. CRM login events appear in Logs again. Plugin Check readme compliance.

= 3.3.3 =
Optional brand sales reports in CRM and PDF export (OrderCRM → Reports). Existing reports unchanged when no brands are selected.

= 3.2.9 =
Admin settings: logo upload moved to the **General** tab (the **Logo** tab is removed). Bookmarks to `?tab=logo` still open General settings. No CRM frontend changes.

= 3.2.8 =
Compatibility and quality release: tested with WordPress 7.0; Plugin Check compliance for WordPress.org directory. No CRM UI or workflow changes.

= 3.2.7 =
Internal refactor of the create-order page (view-model in Order Service). No CRM UI or workflow changes. Staging verified: add-order, order card, products, reports.

= 3.2.3 =
CRM UX: logs user filter shows last name first (A–Z); products page adds a Brand filter when WooCommerce Brands (`product_brand`) is enabled. PDF export shows a progress animation. Activity log cache clears in the background — no action required.

= 3.2.2 =
Performance and stability: order mutations no longer block on full report cache SQL; reports refresh in the background within about a minute. Includes small fixes for WooCommerce email templates, WP 6.7 admin i18n, and theme asset loading. No CRM UI changes.

= 3.2.1 =
Transactional email fix: CRM order actions now send WooCommerce emails reliably (create order, notes, status, AST tracking). Default is synchronous delivery — no theme code changes needed. Compatible with PDF Invoices attachment on new-order emails when that plugin is configured.

= 3.2.0 =
Maintenance release: login/logout activity log cleanup now uses WooCommerce Action Scheduler (more reliable than WP-Cron). No CRM UI changes. After update, optional check: WooCommerce → Status → Scheduled Actions — recurring job `sales_crm_delete_old_login_logout_logs` in group `sales-crm`.

= 3.1.9 =
Maintenance release: centralized orders table display logic (no UI change). Recommended after update: quick smoke on Dashboard, All Orders, Reports, and Customer card.

= 3.1.8 =
Hotfix: CRM logout no longer opens the WordPress wp-login.php confirmation screen.

= 3.1.7 =
Critical hotfix: restores CRM login for administrators and CRM users blocked by false "no access" after 3.1.5–3.1.6. Update immediately.

= 3.1.6 =
Hotfix: fixes false CRM login error on production HTTPS (WordPress `error` query var collision). Purge cache for `/crm-login/` after update.

= 3.1.5 =
Hotfix: CRM login page no longer shows a false error on first visit. Clear page cache for `/crm-login/` after update if your host caches HTML.

= 3.1.4 =
Reports cache (T-09) and deferred emails on all order mutations (T-10): faster CRM reports and order card updates. No UX changes — run your usual CRM smoke (reports, order status, PDF) after update.

= 3.1.3 =
List and activity-log performance (T-08, T-12): faster CRM lists and logs screen on large stores. No UX changes — run your usual CRM smoke and REST/phase runners after update.

= 3.1.2 =
RBAC alignment (wave 6.1): unified CRM capability checks across UI, REST, and role settings. Re-save CRM roles in admin if custom permissions look stale; run your usual CRM smoke and REST runner after update.

= 3.1.1 =
Modular architecture (wave 5), products list service, and `GET /products` REST. Stock filter shows all WooCommerce stock statuses. Run CRM smoke on `/crm-dashboard/products/` and your usual REST runner after update.

= 3.1.0 =
Wave 3 complete: customer and activity-log repositories, thinner templates, activity-log filter fixes, phone mask on create-order, variation price hotfix. Run your usual CRM smoke test after update; Plugin Check recommended before org release.

= 3.0.3 =
Wave 2 architecture complete: unified CRM order creation, order sub-services, and order-card POST via service layer. Run your usual CRM + HPOS smoke tests after update.

= 3.0.2 =
Order data access refactored (repository + order service); optional Strangler flag for creating orders from CRM. Security phases B–D and tax alignment included—run your usual CRM + HPOS smoke tests. Re-compile Russian `.mo` if you maintain custom translations.

= 3.0.1 =
Service-layer cleanup, PDF export reliability, mobile blocked page styling, and translation fix for discount log strings. Re-compile `languages/sales-crm-ru_RU.mo` if you ship custom PO files. Remove `SALES_CRM_DISABLE_PDF_RATE_LIMIT` from wp-config if you added it for testing.

= 3.0.0 =
**PHP 8.0+ required.** Upgrade PHP on the server before updating from 2.1.x. Feature flag `WOO_SALES_CRM_V3_ENABLED` (optional in wp-config) controls the Strangler / refactored branch for 3.0; default is off.

= 2.1.2 =
Report PDF export (mPDF), PHP GD + mbstring required at activation, bundled vendor for PDF. Re-compile Russian .mo if you ship custom translations.

= 2.1.1 =
Enhanced CRM Reports: flexible periods, charts, TOP-5 products by demand, and clearer order list for the selected range. Update translations (.mo) if you use Russian.

= 1.2.8.4 =
Major localization update! Complete Russian translation with 376+ translated strings and important functionality fixes. Automatic translation loading - no configuration needed.

= 1.2.7.4 =
This update includes a new automatic update system that will safely migrate your existing order statuses. No manual intervention required.

== Support ==

For support and feature requests, please use the [WordPress.org support forum](https://wordpress.org/support/plugin/ordercrm-for-woocommerce/) for this plugin.

== Credits ==

Developed by [Dima Dumchikov](http://facebook.com/dima.dumchikov)

== License ==

This plugin is licensed under the GPL v2 or later.
