App\Libraries\HistoryUtils::renderHtml PHP Method

renderHtml() public static method

public static renderHtml ( $accountId )
    public static function renderHtml($accountId)
    {
        $lastClientId = false;
        $clientMap = [];
        $str = '';
        $history = Session::get(RECENTLY_VIEWED, []);
        $history = isset($history[$accountId]) ? $history[$accountId] : [];
        foreach ($history as $item) {
            if ($item->entityType == ENTITY_CLIENT && isset($clientMap[$item->client_id])) {
                continue;
            }
            $clientMap[$item->client_id] = true;
            if ($lastClientId === false || $item->client_id != $lastClientId) {
                $icon = '<i class="fa fa-users" style="width:32px"></i>';
                if ($item->client_id) {
                    $link = url('/clients/' . $item->client_id);
                    $name = $item->client_name;
                    $buttonLink = url('/invoices/create/' . $item->client_id);
                    $button = '<a type="button" class="btn btn-primary btn-sm pull-right" href="' . $buttonLink . '">
                                    <i class="fa fa-plus-circle" style="width:20px" title="' . trans('texts.create_invoice') . '"></i>
                                </a>';
                } else {
                    $link = '#';
                    $name = trans('texts.unassigned');
                    $button = '';
                }
                $str .= sprintf('<li>%s<a href="%s"><div>%s %s</div></a></li>', $button, $link, $icon, $name);
                $lastClientId = $item->client_id;
            }
            if ($item->entityType == ENTITY_CLIENT) {
                continue;
            }
            $icon = '<i class="fa fa-' . EntityModel::getIcon($item->entityType . 's') . '" style="width:24px"></i>';
            $str .= sprintf('<li style="text-align:right; padding-right:18px;"><a href="%s">%s %s</a></li>', $item->url, $item->name, $icon);
        }
        return $str;
    }