Customer Print Invoice V1.0
===========================

Designed for CE Phoenix Cart 1.1.0.6 and PHP 8.2.

What it does
------------

Adds a Print Invoice button to eligible customer orders on My Orders and to
the individual order-details page. An Admin status checklist determines which
orders are eligible. The checkout confirmation email receives a secure link
only when its initial status is selected.

The invoice is lightweight HTML. It opens the browser print dialog immediately,
allowing the customer to print on paper or select the browser's Save as PDF
destination. There is no server-side PDF library or PDF-generation delay.

Installation
------------

1. Upload the contents of the supplied catalog folder to the root of the
   Phoenix catalog, preserving the directory structure.

   If the Phoenix Admin directory has been renamed, upload the contents of the
   supplied catalog/admin directory into the actual Admin directory instead.

2. In Admin, open Orders > Customer Print Invoice. Select every status for
   which customers may print a genuine invoice, then save. No statuses are
   enabled by default.

   Example: a shop might enable Awaiting Approval, In Pack, Despatched and
   Delivered when all four statuses represent paid orders. Select statuses
   according to the shop's own payment and accounting policy.

3. Sign in to a customer account with orders in both an enabled and a disabled
   status. Confirm that Print Invoice is shown only for the enabled order.
   A direct print_my_invoice.php URL for the disabled order must return the
   customer to My Orders.

4. Place test orders and confirm that the confirmation email includes the
   invoice link only when the order's initial status is enabled. If a notified
   Admin status update moves an order from a disabled status into an enabled
   status, the status-update email receives the link instead.

There is no module to install, no manual SQL to run, no PDF dependency and no
Phoenix core file is edited or replaced. Saving the Admin checklist creates one
configuration record automatically. Existing checkout and status-update
notification templates are not replaced; links are added through Phoenix
hooks.

Security
--------

The email link contains no session ID or access token. A customer who is not
signed in is sent through Phoenix's normal login-required pipeline. Before an
invoice is shown, the add-on validates that:

* the order ID is a positive integer;
* the order belongs to the signed-in customer; and
* the order has a Phoenix public status in the active language; and
* the current order status is enabled in the Admin invoice checklist.

Button visibility and email links use the same whitelist, but the invoice page
always performs its own independent check. Changing an order ID manually or
using an old link therefore cannot bypass the Admin setting. Orders in disabled
statuses receive no customer invoice and no customer pro-forma document.

Invalid or unauthorised requests return the customer to My Orders without
revealing whether another order exists. All order and store text is reduced to
plain text and escaped before output. Responses are marked private and no-store.

Customising the appearance
--------------------------

Edit:

ext/customer_print_invoice/customer_print_invoice.css

This dedicated stylesheet does not alter the storefront user.css file. The
default colour and visual treatment match Fancier Invoice and Packing Slip V2.

Language
--------

All new visible text is held in:

includes/languages/english/customer_print_invoice.php
admin/includes/languages/english/customer_print_invoice.php
admin/includes/languages/english/modules/boxes/orders_customer_print_invoice.php

Copy these files to the corresponding language directories and translate the
constant values when adding another language.

Released under the GNU General Public License.
