<?php

namespace Modules\Taxation\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Models\Companies;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Employee\Repositories\EmployeeInterface;

class InvoiceController extends Controller
{

    private $employeeRepository;

    public function __construct(EmployeeInterface $employeeRepository)
    {
        $this->employeeRepository = $employeeRepository;
    }
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        $data['title'] = 'Invoice List';
        $data['invoices'] = [];
        return view('taxation::invoice.index', $data);
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        $data['title'] = 'Create Invoice';
        $data['companyList'] = Companies::pluck('title', 'company_id');
        $data['employeeList'] = $this->employeeRepository->pluck();

        return view('taxation::invoice.create', $data);
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request): RedirectResponse
    {
        //
    }

    /**
     * Show the specified resource.
     */
    public function show($id)
    {
        return view('taxation::invoice.show');
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit($id)
    {
        return view('taxation::invoice.edit');
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, $id): RedirectResponse
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy($id)
    {
        //
    }

    public function cloneProduct(Request $request)
    {
        $data = [];
        $numInc = $request->numberInc;
        $script = true;
        return response()->json([
            'view' => view('taxation::invoice.clone-product', compact('data', 'numInc', 'script'))->render(),
        ]);
    }
}