<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller; // Pastikan ini ada
use App\Models\Sale;
use Illuminate\Http\Request;

class PrintController extends Controller
{
    public function printSuratJalan($id)
    {
        // Ambil data penjualan beserta item dan relasinya
        $sale = Sale::with(['items', 'customer', 'branch', 'user'])->findOrFail($id);

        return view('prints.delivery-order', compact('sale'));
    }

    public function printInvoice($id)
    {
        $sale = Sale::with(['items', 'customer', 'branch', 'user'])->findOrFail($id);
        return view('prints.invoice', compact('sale'));
    }

    public function printNcr($id)
{
    // Ambil Brand Name dari setting
    $brandName = \App\Models\AppSetting::getSetting()->brand_name;
    
    $sale = Sale::with(['items.product', 'customer', 'branch', 'user'])->findOrFail($id);
    
    return view('prints.invoice-ncr', compact('sale', 'brandName'));
}
}