<?php
/**
 * Packing slip document type.
 *
 * @package Kramar
 * @since   1.0.0
 */

declare( strict_types=1 );

namespace Kramar\Modules\Invoices;

defined( 'ABSPATH' ) || exit;

/**
 * Packing slip — items + quantities + addresses, no prices.
 *
 * @since 1.0.0
 */
final class Packing_Slip extends Document {

	/** {@inheritDoc} */
	public function get_type(): string {
		return 'packing-slip';
	}

	/** {@inheritDoc} */
	public function get_title_label(): string {
		return __( 'PACKING SLIP', 'kramar' );
	}

	/** {@inheritDoc} */
	public function shows_prices(): bool {
		return false;
	}

	/** {@inheritDoc} */
	public function get_document_data(): array {
		$o = $this->order;
		return [
			'number'         => '',
			'date'           => wp_date( wc_date_format() ),
			'order_number'   => (string) $o->get_order_number(),
			'order_date'     => wc_format_datetime( $o->get_date_created() ),
			'payment_method' => '',
		];
	}

	/**
	 * Generate packing slip PDF (not stored — generated on demand).
	 *
	 * @since 1.0.0
	 *
	 * @return string Raw PDF content.
	 */
	public function generate(): string {
		$html = Block_Renderer::render( $this );
		return Pdf_Renderer::render( $html, $this->settings['paper_size'] ?? 'a4' );
	}

	/**
	 * @since 1.0.0
	 */
	public function get_filename(): string {
		return 'packing-slip-' . $this->order->get_order_number() . '.pdf';
	}
}
