<?php

namespace Modules\Facture\Outil;

use Helpers\Outil\Outils;

class ImageFacture
{
    
    /**
     * @param array<mixed> $facture FacEnt
     */
    public static function getUrlImageFacture($facture)
    {
        $http = Outils::getPreferredProtocol();
        
        if (trim($facture['FIC_LAD'] ?? '') == '') {
            return '';
        }
        return
            str_replace('http://', $http, $_SESSION['ispiurl'])
            .'&prgname=FIC_LAD&arguments=-A'
            . urlencode(str_replace('\\', '\\\\', $facture['FIC_LAD']))
            . ",-A"
            . $facture['TYPE_URL_LAD']; // TODO url encode ?
    }
}
