<?php

// Code within app\Helpers\Helper.php

namespace App\Helpers;

class EmailTemplates {

    public static function setServicesTemplate($services) {

        $html = "";
        if (count($services) > 0) {
            $html = '<h4 style="margin-bottom:0">Shopping Cart</h4>';
            $html .= '<table border="1" cellpadding="5" cellspacing="0" bordercolor="#DDDDDD" style="margin-bottom: 20px; width: 100%;">';
            $html .= '<thead>';
            $html .= '<tr>';
            $html .= '<th width="55%" style="text-align:left">Title</th>';
            $html .= '<th width="15%" style="text-align:center">Quantity</th>';
            $html .= '<th width="15%" style="text-align:center">Price</th>';
            $html .= '<th width="15%" style="text-align:center">Total</th>';
            $html .= '</tr>';
            $html .= '</thead>';
            $html .= '<tbody>';
            foreach ($services as $service) {
                $html .= '<tr>';
                $html .= '<td>' . $service->Title . '</td>';
                $html .= '<td style="text-align:right">' . $service->Quantity . '</td>';
                $html .= '<td style="text-align:right">' . env('CURRENCY_SYMBOL') . $service->Price . '</td>';
                $html .= '<td style="text-align:right">' . env('CURRENCY_SYMBOL') . $service->Total . '</td>';
                $html .= '</tr>';
            }
            $html .= '</tbody>';
            $html .= '</table>';
        }
        return $html;
    }

    public static function setPackageTemplate($facilities) {

        $count = count($facilities);
        $html = '<h3 style="text-align: left;color: #F7941D; font-family: "Gilroy-bold", sans-serif;">What\'s Covered</h3>';
        $html .= '<table style="width: 620px; font-size: 18px; font-weight: bolder; line-height: 1.5; color: #4D4D4D;">';
        $html .= '<tbody>';

        $html .= '<tr>';



        $i = 1;
        foreach ($facilities as $facility) {
            $html .= '<td><span style="color: #F7941D;"><img height="15px" width="15px" src="https://www.vhv.rs/dpng/d/454-4541492_tick-black-png-icons-orange-check-mark-png.png"></span>';
            $html .= $facility['title'] ?? '';
            $html .= '</td>';

            if ($i == 2) {

                $html .= "</tr><tr>";
                $i = 0;
            }
            $i++;
        }
        $html .= '</tr>';

        $html .= '</tbody>';
        $html .= '</table>';

        return $html;
    }

}
