<!--- 
<!-------------- CONTROLLO ACCESSO --------------->
<cfset liv="k3"><cfinclude template="intranet/controllo.cfm">
<!-------------- CONTROLLO ACCESSO --------------->
 --->


<cfparam name="url.IDdocumento" default="0">
<cfparam name="url_IDdocumento" default="#url.IDdocumento#">
<cfparam name="stampa_batch" default="false">

<cfquery name="datifattura" datasource="#session.dsn#">
    Select *
    From fatture_attivo
    Where IDdocumento = #url_IDdocumento#
</cfquery>
<cfquery name="datiordine" datasource="#session.dsn#">
    Select anticipo, data, Numero_Ordine, oda_cli
    from odv
    Where IDOrdine = #datifattura.IDOrdine#
</cfquery>
<CFQUERY NAME="Soc" datasource="#session.dsn#">
    SELECT *
    FROM anagrafica
    Where IDSocieta = #datifattura.IDSocieta#
</CFQUERY>
<CFQUERY NAME="Usr" DATASOURCE="intranet">
    SELECT Nome, Cognome, UserID
    FROM utenti
    Where IDUtente = #datifattura.Agente#
</CFQUERY>
<CFQUERY NAME="dettagli" datasource="#session.dsn#">
    SELECT *
    FROM odv_dett
    Where IDOrdine = #datifattura.IDOrdine#
    Order by IDDett_ordine
</CFQUERY>
<CFQUERY NAME="modalita_pagamento" DATASOURCE="#session.dsn#">
    SELECT * from modalita_pagamento 
    order by descrizione
</CFQUERY>
<CFQUERY name="banche" DATASOURCE="#session.dsn#"> 
    select * from banche order by banca, descrizione
</CFQUERY>
<!---------------------------------------------------------------------->
<!---------------------------------------------------------------------->
<!---------------------------------------------------------------------->
<cfif datifattura.ndc eq "ndc">
	<cfset nome_pdf = "Nota_di_Credito_PROFORMA_#replace(replace(replace(replace(replace(soc.societa, "-", " ", "all"), " ", "_", "all"), ".", "", "all"), "__", "_", "all"), "__", "_", "all")#">
<cfelse>
	<cfset nome_pdf = "Fattura_PROFORMA_#replace(replace(replace(replace(replace(soc.societa, "-", " ", "all"), " ", "_", "all"), ".", "", "all"), "__", "_", "all"), "__", "_", "all")#">
</cfif>
<cfcontent type="application/pdf">
<cfparam name="url.nomefile" default="#nome_pdf#">
<cfparam name="url.or" default="landscape">
<cfheader name="Content-Disposition" value="attachment; filename=#url.nomefile#.pdf">
<cfdocument format="pdf" pagetype="a4" margintop="0.5" marginbottom="2" marginleft="1" marginright="1" unit="cm">
	<cfif session.logo neq "_nsv" or session.logo neq "_cor" or session.logo neq "_ns2">
    <cfdocumentitem type="footer">
        <html>
        <head>
        <link href="file:///d:/wwwroot/voxnet/intranet/css/main.css" rel="stylesheet" type="text/css">
        <link href="file:///d:/wwwroot/voxnet/intranet/css/standard.css" rel="stylesheet" type="text/css">
        </head>
        <div align="center"><font face="Verdana" color="#000000" size="1">
        Il pagamento dovr&agrave; essere effettuato nei termini indicati sulla fattura medesima, in caso di inadempienza  verr&agrave; applicato il D.L.gs n.192/2012 in attuazione alla Direttiva 2011/7/UE
        <hr size="1" color="#000084">
        <strong><em>s.e.&amp;o.</em></strong></font></div>
        </html>
    </cfdocumentitem>
            <cfelse>
         <cfdocumentitem type="footer">
            <html>
            <head>
            <link href="file://<cfoutput>#expandPath('../css/main.css')#</cfoutput>" rel="stylesheet" type="text/css">
            <link href="file://<cfoutput>#expandPath('../css/standard.css')#</cfoutput>" rel="stylesheet" type="text/css">
            </head>
            </html>
        </cfdocumentitem>
     </cfif>
    <cfinclude template="../_#session.logo#/fattura_proforma_pdf_corpo.cfm">
</cfdocument>
