<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Project;
use App\Models\CompanySettings;
use PDF;

class ProjectReportController extends Controller
{
    // Display landing page
    public function index()
    {
        return view('reports.project-reports-landing');
    }

    // Display project listing report
    public function listing()
    {
        $projects = Project::orderBy('code')->get();
        $company = CompanySettings::first();
        
        return view('reports.project-listing-report', compact('projects', 'company'));
    }

    // Download PDF of project listing
    public function downloadPdf(Request $request)
    {
        $projects = Project::orderBy('code')->get();
        $company = CompanySettings::first();
        
        $pdf = PDF::loadView('reports.project-listing-pdf', compact('projects', 'company'));
        return $pdf->download('project-listing-report.pdf');
    }
}