2025-06-26 18:47:11 +02:00

93 lines
2.6 KiB
Transact-SQL

-- Stored procedure
--[sp_writePDF_New] 1,1,'PLM',null
--sp_writePDF_New @idReport=11,@idCliente=752, @utente='F012965',@img=null,@pdfDopoContrattoSei=0,@indicePaginaCopertina=0,@indicePaginaNavigatore=-1
CREATE PROCEDURE [dbo].[sp_writePDF_New]
@idReport as int,
@idCliente as int,
@utente as varchar(70) = null,
@img as image = null,
@pdfDopoContrattoSei as bit = 0,
-- Modifica necessaria per disclaimer differenziati
-- tra il lucchetto aperto o chiuso in getsioni documenti
@indicePaginaCopertina as smallint = -1,
@indicePaginaNavigatore as smallint = -1
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Identificativo AS INT
select @idCliente = isnull(@idCliente,-1)
INSERT INTO [dbo].[ReportperClienteDati]
([DtCreazione]
,[FlgArchiviato]
,[IdReport]
,[IdCliente]
,[Utente]
)
VALUES
(getdate()
,0
,@idReport
,@idCliente
,@utente
)
SET @Identificativo=@@identity
INSERT INTO [dbo].[ReportFisico]
([FileReport]
,[Identificativo]
,[IndiceNavigatore]
,[IndiceCopertina]
,[ReportDopoC6])
VALUES
(@img
,@Identificativo
,@indicePaginaNavigatore
,@indicePaginaCopertina
,@pdfDopoContrattoSei)
declare @nome as varchar(50)
declare @cognome as varchar(50)
declare @cf as varchar(16)
declare @tprep as int
declare @codContratto as varchar(11)
select @nome = nome from cliente where idcliente = @idcliente
select @cognome = cognome from cliente where idcliente = @idcliente
select @cf = codFiscale from cliente where idcliente = @idcliente
select @codContratto = codiceContratto from cliente where idcliente = @idcliente
select @tprep = tpreport from ReportperClienteDati,report where identificativo = @identificativo and reportPerclienteDati.idReport = report.idreport
--select * from report where idReport = 2347
--select top 1 * from reportPerclienteDati
--select * from report where idReport = 2347
--select * from reportPerclienteDati
--where identificativo = 7872
INSERT INTO [SEIReport].[dbo].[RepositoryMetadati]
([idInrepository]
,[rete]
,[cod_agente]
,[cod_fiscale]
,[idCliente]
,[cognome]
,[nome]
,[tipoReport]
,[dataGenerazione]
,[flagLock]
,[flagStoricizzato]
,[flagDefinitivo]
,[repository]
,[CodiceContratto])
VALUES(
@identificativo,
--mettere anche idCliente che è tra i parametri
substring(@utente,1,1),
substring(@utente,2,7),
@cf,
@idCliente,
@cognome,
@nome,
@tprep,
getDate(),
0,
0,
1,
0,
@codContratto)
return @Identificativo
END