﻿var valori = "";
var parametri = "";

function Stampa(strParamName, strParamValue, strTitolo, strReport) {
    valori = strParamValue;
    AvviaStampa(strParamName, strTitolo, strReport, 'PDF');
}

function AvviaStampa(parametri, titoloreport, funzione, formato) {
    if (valori) {
        if (valori == '') valori = '';
    } else valori = '';
    StampaGenerica(parametri, valori, titoloreport, funzione, formato);
}

function StampaGenerica(parametri, valori, titoloreport, funzione, formato) {
    if (SetElemento("parametri", parametri) && SetElemento("valori", valori) && SetElemento("titoloreport", titoloreport) && SetElemento("funzione", funzione) && SetElemento("formato", formato)) InviaForm("FormStampa");
    else alert("Errore impostazione parametri per la richiesta di stampa");
}

function SetElemento(idelemento, valori) {
    var obj = document.getElementById(idelemento);
    if (obj) {
        obj.value = valori;
        return true;
    } else return false;
}

function InviaForm(formId) {
    var obj = document.getElementById(formId);
    if (obj) FormStampa.submit();
    else alert("Impossibile inviare dati per la stampa");
}
