<?php

declare(strict_types=1);

namespace prj\ex\outputs\bills;

class notices_out {
    public static function late_rent(bool $view_as_pdf): array {
        $output['pdf'] = $view_as_pdf;
        $output['entity'] = "ZXC99";
        $output['full_name'] = "Robert Miller";
        $output['address'] = "3030 Someplace Ave";
        $output['address2'] = "Grand Rapids, MI 49503";
        $output['past_due'] = "1139.00";
        $output['paid'] = "200.00";
        $output['todays_date'] = \tts\time_zones::convert_time_zone(array('format' => 'legal_date'));
        $output['wrap'] = ($view_as_pdf) ? "" : 'class="non-pdf-paper-wrap"';
        $output['apt'] = '208';
        $output['signatures'] = [
          ['here' => 'Manager', 'name' => 'Mark Smith'],
          ['here' => 'Customer']
        ];
        return $output;
    }
    
    public static function gen_pdf_for_late_payment(string $html_code): void {
        $style_sheet = file_get_contents(\tts\site_helper::get_root() . \tts\site_helper::get_project() . 'views/default/bills/notice_of_late_payment_css.php');

        require_once TTS_VENDOR . 'autoload.php';
        $mpdf = new \Mpdf\Mpdf(['tempDir' => \tts\site_helper::get_root() . '/tmp/mpdf']); // chown www-data, chmod 775

        $mpdf->AddFontDirectory(PROJECT_ASSETS_DIR . '/fonts');
        $mpdf->fontdata['jennasue'] = ['R'=>"JennaSue.ttf"];
        $mpdf->available_unifonts[] = 'jennasue';
        $mpdf->AddFont('jennasue', 'R');
        $mpdf->SetFont('jennasue');

        $mpdf->WriteHTML($style_sheet,\Mpdf\HTMLParserMode::HEADER_CSS);
        $mpdf->WriteHTML($html_code,\Mpdf\HTMLParserMode::HTML_BODY);
        $mpdf->Output();
    }
}

