<?php

namespace Modules\Facture\Outil;

use Helpers\Session\ParseBase1;
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, (new ParseBase1())->getPath()->ispi)
            .'&prgname=FIC_LAD&arguments=-A'
            . urlencode(str_replace('\\', '\\\\', $facture['FIC_LAD']))
            . ",-A"
            . $facture['TYPE_URL_LAD']; // TODO url encode ?
    }
}
