Aggiunto progetto GPW_Data
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
SELECT *
|
||||
FROM TMP_importFasi tf
|
||||
INNER JOIN ETS_ScipHalf.dbo.commesse c ON dbo.f_padLeft(tf.NumComm, 4,'0')=c.NrComme AND dbo.f_padLeft(tf.anno, 4,'0')=c.Anno
|
||||
|
||||
select * from AnagClienti
|
||||
select * from AnagProgetti
|
||||
select * from AnagFasi
|
||||
|
||||
|
||||
SELECT * FROM ETS_ScipHalf.dbo.commesse
|
||||
|
||||
-- step 0: creo clienti!
|
||||
SELECT DISTINCT Commitente INTO TMP_RawClienti
|
||||
FROM ETS_ScipHalf.dbo.commesse
|
||||
|
||||
INSERT INTO AnagClienti(RagSociale)
|
||||
SELECT Commitente from TMP_RawClienti
|
||||
|
||||
-- step 1: creo progetti (tutti) INATTIVI
|
||||
INSERT INTO AnagProgetti(idxCliente, nomeProj, descrProj, attivo, codExt, avvio, chiusura)
|
||||
SELECT ac.idxCliente, NrComme+'-'+Anno as nomeProj, Descrizione as descrProj, 0, NrProtocollo as codExt, dataApe as avvio, DataSca as chiusura
|
||||
FROM ETS_ScipHalf.dbo.commesse c
|
||||
INNER JOIN AnagClienti ac ON c.Commitente=ac.RagSociale
|
||||
|
||||
-- step 2: indico attivi solo i progetti che ho trovato da tam import
|
||||
UPDATE ap
|
||||
SET Attivo = 1
|
||||
FROM AnagProgetti ap INNER JOIN TMP_importFasi tif ON ap.nomeProj = dbo.f_padLeft(tif.NumComm, 4,'0') +'-'+dbo.f_padLeft(tif.anno, 4,'0')
|
||||
|
||||
|
||||
-- step 3: creo fasi MACRO (ancestor) da TUTTI i progetti ATTIVI
|
||||
INSERT INTO AnagFasi( idxProgetto, codFase, idxFaseAncest, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo, budgetTime, budgetMoney)
|
||||
SELECT idxProgetto, '' as codFase, 0 as idxFaseAncest, nomeProj, descrProj, 0 as enabTime, 0 as enabMon, Attivo, 0 as bdgTim, 0 as bdgMon
|
||||
FROM AnagProgetti ap
|
||||
WHERE attivo = 1
|
||||
|
||||
-- step 4: creo vere (sotto) fasi
|
||||
INSERT INTO AnagFasi( idxProgetto, codFase, idxFaseAncest, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo, budgetTime, budgetMoney)
|
||||
SELECT af.idxProgetto, '' as codFase, af.idxFase AS idxFaseAncest, tif.NomeFase, tif.NomeFase, 1 as enabTime, 0 as enabMon, 1, 0 as bdgTim, 0 as bdgMon
|
||||
FROM AnagFasi af
|
||||
INNER JOIN TMP_importFasi tif ON af.nomeFase = dbo.f_padLeft(tif.NumComm, 4,'0') +'-'+dbo.f_padLeft(tif.anno, 4,'0')
|
||||
|
||||
-- step 5: sistemo progetti con date apertura/chiusura nulle e oldIdx nulli...
|
||||
UPDATE AnagProgetti
|
||||
SET avvio = '1900-01-01'
|
||||
where avvio IS NULL
|
||||
|
||||
UPDATE AnagProgetti
|
||||
SET chiusura = '2100-12-31'
|
||||
where chiusura IS NULL
|
||||
|
||||
UPDATE AnagProgetti
|
||||
SET OldIdx =-1
|
||||
WHERE OldIdx is null
|
||||
|
||||
|
||||
--- update finale
|
||||
-- inserisco commesse mancanti
|
||||
INSERT INTO AnagFasi( idxProgetto, codFase, idxFaseAncest, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo, budgetTime, budgetMoney)
|
||||
SELECT idxProgetto, '' as codFase, 0 as idxFaseAncest, nomeProj, descrProj, 0 as enabTime, 0 as enabMon, Attivo, 0 as bdgTim, 0 as bdgMon
|
||||
FROM AnagProgetti ap
|
||||
WHERE attivo = 0
|
||||
|
||||
-- inserisco sottofasi (fasi) mancanti a "generale"
|
||||
INSERT INTO AnagFasi( idxProgetto, codFase, idxFaseAncest, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo, budgetTime, budgetMoney)
|
||||
SELECT af.idxProgetto, '' as codFase, af.idxFase AS idxFaseAncest, 'GENERALE', 'GENERALE', 1 as enabTime, 0 as enabMon, 0, 0 as bdgTim, 0 as bdgMon
|
||||
FROM AnagFasi af
|
||||
WHERE af.idxFase > 493
|
||||
@@ -0,0 +1,208 @@
|
||||
alter table Giustificativi add
|
||||
constraint DF_Giustificativi_automatico default (0) for automatico
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
set ANSI_NULLS on
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* stp_ricalcolaPeriodoLav
|
||||
*
|
||||
* Aggiorna la tab dei periodi lavorati ricalcolando la giornata del record interessato
|
||||
*
|
||||
* creato da: S.E.L. - 2008.06.09
|
||||
* ultima modifica: S.E.L. - 2012.02.06
|
||||
*----------------------------------*/
|
||||
alter PROCEDURE stp_ricalcolaPeriodoLav
|
||||
(
|
||||
@idxDipendente AS INT,
|
||||
@dataRif AS DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
DECLARE @round AS INT
|
||||
SET @round = ( SELECT valInt FROM AnagKeyValue WHERE nomeVar = 'minutiRound' )
|
||||
|
||||
-- creo la tabella temporanea con riga incrementale
|
||||
DECLARE @entrate TABLE
|
||||
(
|
||||
idxDipendente INT NULL,
|
||||
oraTimbrata DATETIME NULL,
|
||||
RowNum INT NOT NULL
|
||||
)
|
||||
DECLARE @uscite TABLE
|
||||
(
|
||||
idxDipendente INT NULL,
|
||||
oraTimbrata DATETIME NULL,
|
||||
RowNum INT NOT NULL
|
||||
)
|
||||
|
||||
-- elimino i periodi della data indicata...
|
||||
DELETE FROM PeriodiLav
|
||||
WHERE (idxDipendente = @idxDipendente) AND (CONVERT(varchar(8), entrata, 112) = CONVERT(varchar(8), @dataRif, 112))
|
||||
|
||||
|
||||
-- ENTRATE!!!
|
||||
INSERT INTO @entrate
|
||||
SELECT idxDipendente,
|
||||
DATEADD(n, (ROUND(dbo.TimeSpanUnits('m', dbo.TimeOnly(dateadd(n,-1,dataOra))) / @round, 2) + 1) * @round , dbo.DateOnly(dataOra)) AS oraTimbrata
|
||||
,ROW_NUMBER() OVER(ORDER BY dataOra) AS 'RowNum'
|
||||
FROM Timbrature
|
||||
WHERE (idxDipendente = @idxDipendente)
|
||||
AND dbo.DateOnly(dataOra) = dbo.DateOnly(@dataRif)
|
||||
AND (entrata = 1)
|
||||
|
||||
-- USCITE!!!
|
||||
INSERT INTO @uscite
|
||||
SELECT idxDipendente
|
||||
, DATEADD(n, (ROUND(dbo.TimeSpanUnits('m', dbo.TimeOnly(dateadd(n,-1,dataOra))) / @round, 2) + 1) * @round , dbo.DateOnly(dataOra)) AS oraTimbrata
|
||||
, ROW_NUMBER() OVER(ORDER BY dataOra) AS 'RowNum'
|
||||
FROM Timbrature
|
||||
WHERE (idxDipendente = @idxDipendente) AND dbo.DateOnly(dataOra) = dbo.DateOnly(@dataRif) AND (entrata = 0)
|
||||
|
||||
|
||||
|
||||
INSERT INTO PeriodiLav(idxDipendente, entrata, uscita, rowNum)
|
||||
SELECT cte_in.idxDipendente, cte_in.oraTimbrata, cte_out.oraTimbrata, cte_in.RowNum
|
||||
FROM @entrate AS cte_in LEFT OUTER JOIN @uscite AS cte_out ON cte_in.idxDipendente=cte_out.idxDipendente AND cte_in.RowNum=cte_out.RowNum
|
||||
|
||||
|
||||
-- inserisco eventuali singole timbrature uscita come in/out uguali
|
||||
INSERT INTO PeriodiLav(idxDipendente, entrata, uscita, rowNum)
|
||||
SELECT cte_out.idxDipendente, cte_out.oraTimbrata, cte_out.oraTimbrata, cte_out.RowNum
|
||||
FROM @entrate AS cte_in RIGHT OUTER JOIN @uscite AS cte_out ON cte_in.idxDipendente=cte_out.idxDipendente AND cte_in.RowNum=cte_out.RowNum
|
||||
WHERE cte_in.RowNum IS NULL
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* stp_timbratureExpl_ByUserDate
|
||||
*
|
||||
* Recupera la tab delletimbrature expl x utente e intervallo date
|
||||
* mod: S.E.L. - 2012.09.17
|
||||
*----------------------------------*/
|
||||
alter PROCEDURE stp_timbratureExpl_ByUserDate
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataFrom DATETIME,
|
||||
@dataTo DATETIME,
|
||||
@showWE BIT = 1 -- imposto visualizzazione week-end a true di default
|
||||
)
|
||||
AS
|
||||
|
||||
-- imposto LUN x inizio settimana
|
||||
SET DATEFIRST 1
|
||||
|
||||
SELECT *
|
||||
FROM TimbratureExpl
|
||||
WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND dataLav >= @dataFrom AND dataLav < @dataTo
|
||||
AND DATEPART(dw, dataLav) <= CASE WHEN @showWE=0 THEN 5 ELSE 7 END --solo lun-ven, 1-5
|
||||
ORDER BY dataLav DESC
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
set ANSI_NULLS on
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* stp_ricalcolaTimbExpl_byPeriodoUser
|
||||
*
|
||||
* Ricalcola le TimbratureExpl x utente e intervallo date
|
||||
* mod: S.E.L. - 2012.09.17
|
||||
*----------------------------------*/
|
||||
create PROCEDURE stp_ricalcolaTimbExpl_byPeriodoUser
|
||||
(
|
||||
@idxDipendente INT = 0,
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
SET DATEFIRST 1
|
||||
-- quanti giorni mi servono? conto giorni del mese
|
||||
DECLARE @numD INT
|
||||
SET @numD = ( SELECT DATEDIFF(dd, @inizio, @fine) )
|
||||
|
||||
-- contatore per ciclo
|
||||
DECLARE @currRow INT = 0
|
||||
DECLARE @currIdxDip INT = 0
|
||||
DECLARE @currDate DATETIME
|
||||
|
||||
|
||||
-- creo la tabella temporanea con riga incrementale
|
||||
DECLARE @dateAndUser TABLE
|
||||
(
|
||||
Riga int IDENTITY(1,1) NOT NULL,
|
||||
DATA DATETIME NULL,
|
||||
idxDipendente INT NULL
|
||||
)
|
||||
|
||||
-- elenco delle date DEL MESE (compresi sab/dom) fino a max data odierna
|
||||
;WITH myCTE AS
|
||||
(
|
||||
SELECT dbo.DateOnly(DATEADD(dd, (N-1), @inizio)) as Data, idxDipendente
|
||||
FROM Tally, Dipendenti
|
||||
WHERE N <= @numD
|
||||
AND (idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
)
|
||||
|
||||
-- inserisco valori cte in temp table!
|
||||
INSERT INTO @dateAndUser
|
||||
SELECT * FROM myCTE
|
||||
|
||||
-- eseguo update! Iterazione sulle righe della CTE
|
||||
WHILE 1 = 1
|
||||
BEGIN
|
||||
|
||||
-- Get next customerId
|
||||
SELECT TOP 1 @currRow=Riga, @currIdxDip=idxDipendente, @currDate=Data
|
||||
FROM @dateAndUser
|
||||
WHERE Riga > @currRow
|
||||
ORDER BY Riga
|
||||
|
||||
-- Exit loop if no more customers
|
||||
IF @@ROWCOUNT = 0 BREAK;
|
||||
|
||||
-- ESEGUO!
|
||||
--select @currIdxDip, @currDate
|
||||
EXEC stp_ricalcolaTimbratureExpl @currIdxDip, @currDate
|
||||
|
||||
END
|
||||
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(200, GETDATE())
|
||||
GO
|
||||
@@ -0,0 +1,79 @@
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
set ANSI_NULLS on
|
||||
go
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- stp_DipendentiAndAnomalie
|
||||
--
|
||||
-- Elenco dipendenti con email, data, tipo anomalia... (con AND!!!)
|
||||
-- mod: S.E.L. - 2013.01.10
|
||||
------------------------------------------------------------------------
|
||||
create PROCEDURE stp_DipendentiAndAnomalie
|
||||
(
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME,
|
||||
@notOkApp BIT = 0, -- 0 = tutte, 1 solo con anomalia
|
||||
@notOkTim BIT = 0, -- 0 = tutte, 1 solo con anomalia
|
||||
@notOkLav BIT = 0 -- 0 = tutte, 1 solo con anomalia
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT DISTINCT d.idxDipendente, te.CognomeNome, d.email
|
||||
FROM TimbratureExpl te INNER JOIN Dipendenti d ON te.idxDipendente = d.idxDipendente
|
||||
WHERE ((dataLav >= @inizio) AND (dataLav <= @fine))
|
||||
AND isOkApp = CASE WHEN @notOkApp = 1 THEN 0 ELSE isOkApp END
|
||||
AND isOkTim = CASE WHEN @notOkTim = 1 THEN 0 ELSE isOkTim END
|
||||
AND isOkLav = CASE WHEN @notOkLav = 1 THEN 0 ELSE isOkLav END
|
||||
ORDER BY te.CognomeNome
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- stp_timbratureExpl_getByAnomalia
|
||||
--
|
||||
-- Recupera la tab timbrature expl filtrando per tipo di anomalia (con AND!!!)
|
||||
-- mod: S.E.L. - 2013.01.10
|
||||
------------------------------------------------------------------------
|
||||
create PROCEDURE stp_timbratureExpl_getByAnomalia
|
||||
(
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME,
|
||||
@notOkApp BIT = 0, -- 0 = tutte, 1 solo con anomalia
|
||||
@notOkTim BIT = 0, -- 0 = tutte, 1 solo con anomalia
|
||||
@notOkLav BIT = 0 -- 0 = tutte, 1 solo con anomalia
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT *
|
||||
FROM TimbratureExpl
|
||||
WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND ((dataLav >= @inizio) AND (dataLav <= @fine))
|
||||
AND isOkApp = CASE WHEN @notOkApp = 1 THEN 0 ELSE isOkApp END
|
||||
AND isOkTim = CASE WHEN @notOkTim = 1 THEN 0 ELSE isOkTim END
|
||||
AND isOkLav = CASE WHEN @notOkLav = 1 THEN 0 ELSE isOkLav END
|
||||
ORDER BY dataLav DESC
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(210, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,495 @@
|
||||
create table zzz_RawDataPaymo(
|
||||
idx int not null identity constraint PK_zzz_RawDataPaymo primary key,
|
||||
Cliente nvarchar(250),
|
||||
Dipendente nvarchar(250),
|
||||
Progetto nvarchar(250),
|
||||
TaskList nvarchar(250),
|
||||
Task nvarchar(250),
|
||||
Inizio datetime,
|
||||
Fine datetime,
|
||||
Descrizione nvarchar(2500),
|
||||
Ore float
|
||||
);
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table RegAttivita drop
|
||||
constraint DF_RegAttivita_money ,
|
||||
column money;
|
||||
go
|
||||
|
||||
alter table RegAttivita add
|
||||
importo decimal(19,4) constraint DF_RegAttivita_money default ((0));
|
||||
go
|
||||
|
||||
create index ix_idxDip on RegAttivita(idxDipendente)
|
||||
include(idxFase,inizio);
|
||||
go
|
||||
|
||||
create index ix_idxFase on RegAttivita(idxFase);
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_updateQuery
|
||||
*
|
||||
* update attività
|
||||
*
|
||||
* mod: S.E.L. 2012.11.12
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RA_updateQuery
|
||||
(
|
||||
@idxDipendente int,
|
||||
@idxFase int,
|
||||
@inizio datetime,
|
||||
@fine datetime,
|
||||
@descrizione nvarchar(500),
|
||||
@importo decimal(19, 4),
|
||||
@Original_idxRA int
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
UPDATE RegAttivita
|
||||
SET idxDipendente = @idxDipendente, idxFase = @idxFase, inizio = @inizio, fine = @fine, descrizione = @descrizione, importo = @importo
|
||||
WHERE (idxRA = @Original_idxRA);
|
||||
|
||||
SELECT idxRA, idxDipendente, idxFase, inizio, fine, descrizione, oreTot, importo FROM RegAttivita WHERE (idxRA = @Original_idxRA)
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_getByKey
|
||||
*
|
||||
* recupera elenco attività da chiave
|
||||
*
|
||||
* mod: S.E.L. 2012.11.12
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RA_getByKey
|
||||
(
|
||||
@idxRA INT
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT idxRA, idxDipendente, idxFase, inizio, fine, CASE WHEN ISNULL(descrizione,'') = '' THEN '-' ELSE ISNULL(descrizione,'') END AS descrizione, oreTot, importo
|
||||
FROM RegAttivita
|
||||
WHERE idxRA = @idxRA
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_getByIdxDipData
|
||||
*
|
||||
* recupera elenco attività da idxDipendente + date
|
||||
*
|
||||
* mod: S.E.L. 2012.11.06
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RA_getByIdxDipData
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataFrom DATETIME,
|
||||
@dataTo DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT idxRA, idxDipendente, idxFase, inizio, fine, CASE WHEN ISNULL(descrizione,'') = '' THEN '-' ELSE ISNULL(descrizione,'') END AS descrizione, oreTot, importo
|
||||
FROM RegAttivita
|
||||
WHERE (idxDipendente = @idxDipendente) AND (inizio BETWEEN @dataFrom AND @dataTo) OR
|
||||
(idxDipendente = @idxDipendente) AND (fine BETWEEN @dataFrom AND @dataTo)
|
||||
ORDER BY inizio
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_clona
|
||||
*
|
||||
* clona un attività inserendola in coda alle altre del giorno x lo stesso utente, per pari durata
|
||||
*
|
||||
* mod: S.E.L. 2013.01.17
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_RA_clona
|
||||
(
|
||||
@idxRA INT
|
||||
)
|
||||
AS
|
||||
|
||||
-- variabili
|
||||
DECLARE @inizio DATETIME
|
||||
DECLARE @dataRif DATETIME
|
||||
DECLARE @idxDip INT
|
||||
-- calcolo dati attività indicata
|
||||
SELECT @idxDip=idxDipendente, @dataRif=dbo.DateOnly(inizio)
|
||||
FROM RegAttivita
|
||||
WHERE idxRA=@idxRA
|
||||
|
||||
-- calcolo fine ultima attività del giorno x l'utente
|
||||
SELECT TOP 1 @inizio = fine
|
||||
FROM RegAttivita
|
||||
WHERE idxDipendente = @idxDip
|
||||
AND dbo.DateOnly(fine) = @dataRif
|
||||
ORDER BY fine DESC
|
||||
|
||||
-- ora inserisco la vera nuova attività!
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
SELECT idxDipendente, idxFase, @inizio, DATEADD(minute, oreTot*60, @inizio), descrizione, importo
|
||||
FROM RegAttivita
|
||||
WHERE (idxRA = @idxRA)
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_deleteQuery
|
||||
*
|
||||
* delete attività da chiave
|
||||
*
|
||||
* mod: S.E.L. 2012.11.12
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RA_deleteQuery
|
||||
(
|
||||
@Original_idxRA int
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
DELETE FROM [dbo].[RegAttivita] WHERE ([idxRA] = @Original_idxRA)
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
create table AnagClassiOrarie(
|
||||
codClasse nvarchar(10) not null constraint PK_AnagClassiOrarie primary key,
|
||||
descrClasse nvarchar(250),
|
||||
peso decimal(6,3)
|
||||
);
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'codice univoco', 'SCHEMA', 'dbo', 'TABLE', 'AnagClassiOrarie', 'COLUMN', 'codClasse';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'peso (per calcolo ore "produttive")', 'SCHEMA', 'dbo', 'TABLE', 'AnagClassiOrarie', 'COLUMN', 'peso';
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table AnagFasi alter column
|
||||
nomeFase nvarchar(250);
|
||||
go
|
||||
|
||||
alter table AnagFasi add
|
||||
codClasse nvarchar(10);
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'codice univoco', 'SCHEMA', 'dbo', 'TABLE', 'AnagFasi', 'COLUMN', 'codClasse';
|
||||
go
|
||||
|
||||
alter table AnagFasi add
|
||||
constraint FK_AnagFasi_AnagClassiOrarie foreign key(codClasse) references AnagClassiOrarie(codClasse) on update cascade;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
-- =============================================
|
||||
-- Author: S.E. Locatelli
|
||||
-- Create date: 2012.10.31
|
||||
-- Description: Gestione trigger calcolo codFase e idxProgetto
|
||||
-- =============================================
|
||||
alter TRIGGER trg_AF_calcCodFaseIdxProj
|
||||
ON AnagFasi
|
||||
AFTER INSERT,UPDATE
|
||||
AS
|
||||
BEGIN
|
||||
IF (@@ROWCOUNT = 0) -- SE NESSUNA RIGA AGGIORNATA O INSERITA ESCO
|
||||
RETURN
|
||||
|
||||
-- SET NOCOUNT ON added to prevent extra result sets from
|
||||
-- interfering with SELECT statements.
|
||||
SET NOCOUNT ON;
|
||||
|
||||
-- calcolo il codFase ed idxProgetto x record corrente
|
||||
UPDATE AF
|
||||
SET AF.codFase = dbo.f_calcolaCodFase(i.idxFase)
|
||||
,AF.idxProgetto = CASE WHEN dbo.f_calcolaIdxProgetto(i.idxFase) > 0
|
||||
THEN dbo.f_calcolaIdxProgetto(i.idxFase)
|
||||
ELSE i.idxProgetto
|
||||
END
|
||||
FROM AnagFasi AF
|
||||
INNER JOIN inserted i ON AF.idxFase = i.idxFase
|
||||
|
||||
-- aggiorno IN CASCATA i record child x idxProgetto!!!
|
||||
UPDATE AF
|
||||
SET AF.idxProgetto = CASE WHEN dbo.f_calcolaIdxProgetto(i.idxFase) > 0
|
||||
THEN dbo.f_calcolaIdxProgetto(i.idxFase)
|
||||
ELSE i.idxProgetto
|
||||
END
|
||||
,AF.codClasse = i.codClasse
|
||||
FROM AnagFasi AF
|
||||
INNER JOIN inserted i ON AF.idxFaseAncest = i.idxFase
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_import_paymoRaw
|
||||
*
|
||||
* importa tracciato dati da paymo x utente e date indicate
|
||||
*
|
||||
* mod: S.E.L. 2012.11.20
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_import_paymoRaw
|
||||
(
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
/**************************************************
|
||||
* inizio importando eventuali clienti...
|
||||
**************************************************/
|
||||
;WITH myCteClienti AS
|
||||
(
|
||||
SELECT DISTINCT Cliente FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagClienti(RagSociale, nota, Attivo)
|
||||
SELECT cte.Cliente, cte.Cliente, 1
|
||||
FROM AnagClienti anag
|
||||
RIGHT OUTER JOIN myCteClienti cte ON anag.RagSociale = cte.Cliente
|
||||
WHERE anag.idxCliente IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali progetti
|
||||
**************************************************/
|
||||
;WITH myCteProgetti AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagProgetti(idxCliente, nomeProj, descrProj, Attivo)
|
||||
SELECT cli.idxCliente, cte.Progetto, cte.Progetto, 1
|
||||
FROM AnagProgetti anag
|
||||
RIGHT OUTER JOIN myCteProgetti cte ON anag.nomeProj = cte.Progetto INNER JOIN AnagClienti Cli ON Cli.RagSociale = cte.Cliente
|
||||
WHERE anag.idxProgetto IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali fasi
|
||||
**************************************************/
|
||||
;WITH myCteFasi AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto, TaskList FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, '', cte.TaskList, cte.TaskList, 1, 0, 1
|
||||
FROM myCteFasi cte INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.TaskList
|
||||
WHERE anag.idxFase IS NULL
|
||||
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali sottofasi
|
||||
**************************************************/
|
||||
;WITH myCteSubFasi AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto, TaskList, Task FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, idxFaseAncest, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, Fas.idxFase as idxFaseAncest, '', cte.task, cte.task, 1, 0, 1
|
||||
FROM myCteSubFasi cte
|
||||
INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale
|
||||
INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.TaskList AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.Task AND anag.idxFaseAncest = Fas.idxFase
|
||||
WHERE anag.idxFaseAncest IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo records!
|
||||
**************************************************/
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione)
|
||||
SELECT Dip.idxDipendente, Fas.idxFase, cte.Inizio, cte.Fine, cte.Descrizione
|
||||
FROM zzz_RawDataPaymo cte
|
||||
INNER JOIN Dipendenti Dip ON cte.Dipendente = dip.codDipendenteExt
|
||||
INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale
|
||||
INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.TaskList AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
INNER JOIN AnagFasi SFas ON SFas.nomeFase = cte.Task AND SFas.idxProgetto = Pro.idxProgetto AND SFas.idxFaseAncest=fas.idxFase
|
||||
LEFT OUTER JOIN RegAttivita dati ON dati.inizio = cte.Inizio AND dati.fine = cte.Fine AND dati.descrizione = cte.Descrizione AND dati.idxDipendente = Dip.idxDipendente
|
||||
WHERE dati.idxRA IS NULL
|
||||
|
||||
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table Dipendenti add
|
||||
codDipendenteExt nvarchar(50);
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'nome/codice dipendente per sistema esterno da importare', 'SCHEMA', 'dbo', 'TABLE', 'Dipendenti', 'COLUMN', 'codDipendenteExt';
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_import_paymoRaw
|
||||
*
|
||||
* importa tracciato dati da paymo x utente e date indicate
|
||||
*
|
||||
* mod: S.E.L. 2012.11.20
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_import_paymoRaw
|
||||
(
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
/**************************************************
|
||||
* inizio importando eventuali clienti...
|
||||
**************************************************/
|
||||
;WITH myCteClienti AS
|
||||
(
|
||||
SELECT DISTINCT Cliente FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagClienti(RagSociale, nota, Attivo)
|
||||
SELECT cte.Cliente, cte.Cliente, 1
|
||||
FROM AnagClienti anag
|
||||
RIGHT OUTER JOIN myCteClienti cte ON anag.RagSociale = cte.Cliente
|
||||
WHERE anag.idxCliente IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali progetti
|
||||
**************************************************/
|
||||
;WITH myCteProgetti AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagProgetti(idxCliente, nomeProj, descrProj, Attivo)
|
||||
SELECT cli.idxCliente, cte.Progetto, cte.Progetto, 1
|
||||
FROM AnagProgetti anag
|
||||
RIGHT OUTER JOIN myCteProgetti cte ON anag.nomeProj = cte.Progetto INNER JOIN AnagClienti Cli ON Cli.RagSociale = cte.Cliente
|
||||
WHERE anag.idxProgetto IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali fasi
|
||||
**************************************************/
|
||||
;WITH myCteFasi AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto, TaskList FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, '', cte.TaskList, cte.TaskList, 1, 0, 1
|
||||
FROM myCteFasi cte INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.TaskList
|
||||
WHERE anag.idxFase IS NULL
|
||||
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali sottofasi
|
||||
**************************************************/
|
||||
;WITH myCteSubFasi AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto, TaskList, Task FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, idxFaseAncest, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, Fas.idxFase as idxFaseAncest, '', cte.task, cte.task, 1, 0, 1
|
||||
FROM myCteSubFasi cte
|
||||
INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale
|
||||
INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.TaskList AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.Task AND anag.idxFaseAncest = Fas.idxFase
|
||||
WHERE anag.idxFaseAncest IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo records!
|
||||
**************************************************/
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione)
|
||||
SELECT Dip.idxDipendente, Fas.idxFase, cte.Inizio, cte.Fine, cte.Descrizione
|
||||
FROM zzz_RawDataPaymo cte
|
||||
INNER JOIN Dipendenti Dip ON cte.Dipendente = dip.codDipendenteExt
|
||||
INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale
|
||||
INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.TaskList AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
INNER JOIN AnagFasi SFas ON SFas.nomeFase = cte.Task AND SFas.idxProgetto = Pro.idxProgetto AND SFas.idxFaseAncest=fas.idxFase
|
||||
LEFT OUTER JOIN RegAttivita dati ON dati.inizio = cte.Inizio AND dati.fine = cte.Fine AND dati.descrizione = cte.Descrizione AND dati.idxDipendente = Dip.idxDipendente
|
||||
WHERE dati.idxRA IS NULL
|
||||
|
||||
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AD_deleteQuery
|
||||
*
|
||||
* elimina un dipendente da anagrafica
|
||||
*
|
||||
* mod: S.E.L. 2012.10.29
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AD_deleteQuery
|
||||
(
|
||||
@Original_idxDipendente int
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
DELETE FROM [Dipendenti] WHERE (([idxDipendente] = @Original_idxDipendente))
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(230, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,239 @@
|
||||
create schema import;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_import_paymoRaw
|
||||
*
|
||||
* importa tracciato dati da paymo x utente e date indicate
|
||||
*
|
||||
* mod: S.E.L. 2012.11.20
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE import.stp_import_PaymoDataRaw
|
||||
(
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
/**************************************************
|
||||
* inizio importando eventuali clienti...
|
||||
**************************************************/
|
||||
;WITH myCteClienti AS
|
||||
(
|
||||
SELECT DISTINCT Cliente FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagClienti(RagSociale, nota, Attivo)
|
||||
SELECT cte.Cliente, cte.Cliente, 1
|
||||
FROM AnagClienti anag
|
||||
RIGHT OUTER JOIN myCteClienti cte ON anag.RagSociale = cte.Cliente
|
||||
WHERE anag.idxCliente IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali progetti
|
||||
**************************************************/
|
||||
;WITH myCteProgetti AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagProgetti(idxCliente, nomeProj, descrProj, Attivo)
|
||||
SELECT cli.idxCliente, cte.Progetto, cte.Progetto, 1
|
||||
FROM AnagProgetti anag
|
||||
RIGHT OUTER JOIN myCteProgetti cte ON anag.nomeProj = cte.Progetto INNER JOIN AnagClienti Cli ON Cli.RagSociale = cte.Cliente
|
||||
WHERE anag.idxProgetto IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali fasi
|
||||
**************************************************/
|
||||
;WITH myCteFasi AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto, TaskList FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, '', cte.TaskList, cte.TaskList, 1, 0, 1
|
||||
FROM myCteFasi cte INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.TaskList
|
||||
WHERE anag.idxFase IS NULL
|
||||
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali sottofasi
|
||||
**************************************************/
|
||||
;WITH myCteSubFasi AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto, TaskList, Task FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, idxFaseAncest, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, Fas.idxFase as idxFaseAncest, '', cte.task, cte.task, 1, 0, 1
|
||||
FROM myCteSubFasi cte
|
||||
INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale
|
||||
INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.TaskList AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.Task AND anag.idxFaseAncest = Fas.idxFase
|
||||
WHERE anag.idxFaseAncest IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo records!
|
||||
**************************************************/
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione)
|
||||
SELECT Dip.idxDipendente, Fas.idxFase, cte.Inizio, cte.Fine, cte.Descrizione
|
||||
FROM zzz_RawDataPaymo cte
|
||||
INNER JOIN Dipendenti Dip ON cte.Dipendente = dip.codDipendenteExt
|
||||
INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale
|
||||
INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.TaskList AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
INNER JOIN AnagFasi SFas ON SFas.nomeFase = cte.Task AND SFas.idxProgetto = Pro.idxProgetto AND SFas.idxFaseAncest=fas.idxFase
|
||||
LEFT OUTER JOIN RegAttivita dati ON dati.inizio = cte.Inizio AND dati.fine = cte.Fine AND dati.descrizione = cte.Descrizione AND dati.idxDipendente = Dip.idxDipendente
|
||||
WHERE dati.idxRA IS NULL
|
||||
|
||||
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_import_paymoRaw
|
||||
*
|
||||
* importa tracciato dati da paymo x utente e date indicate
|
||||
*
|
||||
* mod: S.E.L. 2012.11.20
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE import.stp_import_SpsDataRaw
|
||||
(
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
/**************************************************
|
||||
* inizio importando eventuali clienti...
|
||||
**************************************************/
|
||||
;WITH myCteClienti AS
|
||||
(
|
||||
SELECT DISTINCT Cliente FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagClienti(RagSociale, nota, Attivo)
|
||||
SELECT cte.Cliente, cte.Cliente, 1
|
||||
FROM AnagClienti anag
|
||||
RIGHT OUTER JOIN myCteClienti cte ON anag.RagSociale = cte.Cliente
|
||||
WHERE anag.idxCliente IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali progetti
|
||||
**************************************************/
|
||||
;WITH myCteProgetti AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagProgetti(idxCliente, nomeProj, descrProj, Attivo)
|
||||
SELECT cli.idxCliente, cte.Progetto, cte.Progetto, 1
|
||||
FROM AnagProgetti anag
|
||||
RIGHT OUTER JOIN myCteProgetti cte ON anag.nomeProj = cte.Progetto INNER JOIN AnagClienti Cli ON Cli.RagSociale = cte.Cliente
|
||||
WHERE anag.idxProgetto IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali fasi
|
||||
**************************************************/
|
||||
;WITH myCteFasi AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto, TaskList FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, '', cte.TaskList, cte.TaskList, 1, 0, 1
|
||||
FROM myCteFasi cte INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.TaskList
|
||||
WHERE anag.idxFase IS NULL
|
||||
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali sottofasi
|
||||
**************************************************/
|
||||
;WITH myCteSubFasi AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto, TaskList, Task FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, idxFaseAncest, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, Fas.idxFase as idxFaseAncest, '', cte.task, cte.task, 1, 0, 1
|
||||
FROM myCteSubFasi cte
|
||||
INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale
|
||||
INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.TaskList AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.Task AND anag.idxFaseAncest = Fas.idxFase
|
||||
WHERE anag.idxFaseAncest IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo records!
|
||||
**************************************************/
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione)
|
||||
SELECT Dip.idxDipendente, Fas.idxFase, cte.Inizio, cte.Fine, cte.Descrizione
|
||||
FROM zzz_RawDataPaymo cte
|
||||
INNER JOIN Dipendenti Dip ON cte.Dipendente = dip.codDipendenteExt
|
||||
INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale
|
||||
INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.TaskList AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
INNER JOIN AnagFasi SFas ON SFas.nomeFase = cte.Task AND SFas.idxProgetto = Pro.idxProgetto AND SFas.idxFaseAncest=fas.idxFase
|
||||
LEFT OUTER JOIN RegAttivita dati ON dati.inizio = cte.Inizio AND dati.fine = cte.Fine AND dati.descrizione = cte.Descrizione AND dati.idxDipendente = Dip.idxDipendente
|
||||
WHERE dati.idxRA IS NULL
|
||||
|
||||
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
drop procedure stp_import_paymoRaw;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table AnagClienti add
|
||||
codExt nvarchar(50);
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'codice esterno', 'SCHEMA', 'dbo', 'TABLE', 'AnagClienti', 'COLUMN', 'codExt';
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(251, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,51 @@
|
||||
/**************************************************
|
||||
* update cognome nome dipendenti
|
||||
**************************************************/
|
||||
UPDATE Dipendenti
|
||||
SET codDipendenteExt = Nome + ' ' + Cognome
|
||||
|
||||
UPDATE Dipendenti
|
||||
SET codDipendenteExt='Bohdan Khomonchak'
|
||||
WHERE cognome='Khomonchak'
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo records!
|
||||
**************************************************/
|
||||
-- faccio un sort x dipendente-giorno x accodare i records
|
||||
|
||||
-- faccio un sort x dipendente-giorno x accodare i records
|
||||
;WITH myCteStep1 AS
|
||||
(
|
||||
SELECT CognomeNome
|
||||
,Data
|
||||
, ROW_NUMBER() OVER(PARTITION BY CognomeNome,Data ORDER BY CognomeNome,Data) as riga
|
||||
, codCom
|
||||
, Fase
|
||||
, attivita
|
||||
, durata*60 as minuti
|
||||
, descrizione
|
||||
FROM zzz_rawData_SPS
|
||||
)
|
||||
|
||||
, myCteStep2 AS
|
||||
(
|
||||
SELECT *
|
||||
, DATEADD(MINUTE,480+120*(riga-1),Data) AS Inizio
|
||||
, DATEADD(MINUTE,480+120*(riga-1)+minuti,Data) AS Fine
|
||||
FROM myCteStep1
|
||||
)
|
||||
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione)
|
||||
SELECT Dip.idxDipendente, Fas.idxFase, cte.Inizio,cte.Fine, ISNULL(cte.Descrizione,'-')
|
||||
FROM myCteStep2 cte
|
||||
INNER JOIN Dipendenti Dip ON cte.CognomeNome = dip.codDipendenteExt
|
||||
INNER JOIN AnagProgetti Pro ON cte.codCom = Pro.codExt -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.Fase AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
INNER JOIN AnagFasi SFas ON SFas.nomeFase = cte.attivita AND SFas.idxProgetto = Pro.idxProgetto AND SFas.idxFaseAncest=fas.idxFase
|
||||
LEFT OUTER JOIN RegAttivita dati ON dati.inizio = cte.Inizio AND dati.fine = cte.Fine AND dati.descrizione = cte.Descrizione AND dati.idxDipendente = Dip.idxDipendente
|
||||
WHERE dati.idxRA IS NULL
|
||||
|
||||
|
||||
--- forzo ricalcolo attività expl!
|
||||
EXEC stp_ricalcolaRegAttivitaExpl_byPeriodoUser 0, '20120101', '20130120'
|
||||
@@ -0,0 +1,656 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table AnagProgetti add
|
||||
avvio datetime,
|
||||
chiusura datetime;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
create index ix_RA_inizio on RegAttivita(inizio)
|
||||
include(idxDipendente,idxFase,fine);
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
alter TRIGGER trg_RegAtt_upsert
|
||||
ON RegAttivita
|
||||
/*----------------------------------
|
||||
* Trigger su insert/update
|
||||
*
|
||||
* Aggiorna la tab dei RegAttivitaExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2013.01.21
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
|
||||
FOR INSERT, UPDATE
|
||||
AS
|
||||
|
||||
IF(UPDATE(idxDipendente) OR UPDATE(inizio) OR UPDATE(fine) OR UPDATE(idxFase))
|
||||
BEGIN
|
||||
-- dichiarazione variabili
|
||||
DECLARE @inizio DATETIME
|
||||
DECLARE @fine DATETIME
|
||||
DECLARE @idxDipendente INT
|
||||
|
||||
-- recupero valori x inserting
|
||||
SELECT @inizio = DATEADD(DAY,-1,CONVERT(DATE,i.inizio)), @fine = DATEADD(DAY,1,CONVERT(DATE,i.inizio)), @idxDipendente = i.idxDipendente FROM inserted i
|
||||
|
||||
--chiamo la stored di ricalcolo
|
||||
EXEC stp_ricalcolaRegAttivitaExpl_byPeriodoUser @idxDipendente, @inizio, @fine
|
||||
END
|
||||
go
|
||||
|
||||
alter TRIGGER trg_RegAtt_delete
|
||||
ON RegAttivita
|
||||
/*----------------------------------
|
||||
* Trigger su delete
|
||||
*
|
||||
* Aggiorna la tab RegAttivitaExpl ricalcolando la giornata del record interessato
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2013.01.21
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
|
||||
FOR DELETE
|
||||
AS
|
||||
|
||||
-- dichiarazione variabili
|
||||
DECLARE @inizio DATETIME
|
||||
DECLARE @fine DATETIME
|
||||
DECLARE @idxDipendente INT
|
||||
|
||||
-- recupero valori x inserting
|
||||
SELECT @inizio = DATEADD(DAY,-1,CONVERT(DATE,d.inizio)), @fine = DATEADD(DAY,1,CONVERT(DATE,d.inizio)), @idxDipendente = d.idxDipendente FROM deleted d
|
||||
|
||||
--chiamo la stored di ricalcolo
|
||||
EXEC stp_ricalcolaRegAttivitaExpl_byPeriodoUser @idxDipendente, @inizio, @fine
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table RegAttivita drop
|
||||
constraint DF_RegAttivita_money ,
|
||||
constraint FK_RegAttivita_AnagFasi ,
|
||||
constraint FK_RegAttivita_Dipendenti ;
|
||||
go
|
||||
|
||||
exec sp_rename 'PK_RegAttivita', 'tmp__PK_RegAttivita', 'OBJECT';
|
||||
go
|
||||
|
||||
exec sp_rename 'RegAttivita', 'tmp__RegAttivita_0', 'OBJECT';
|
||||
go
|
||||
|
||||
drop trigger trg_RegAtt_upsert;
|
||||
go
|
||||
|
||||
drop trigger trg_RegAtt_delete;
|
||||
go
|
||||
|
||||
create table RegAttivita(
|
||||
idxRA int not null identity constraint PK_RegAttivita primary key,
|
||||
idxDipendente int not null,
|
||||
idxFase int not null,
|
||||
inizio datetime not null,
|
||||
fine datetime not null,
|
||||
descrizione nvarchar(500),
|
||||
oreTot decimal(18,0),
|
||||
importo decimal(19,4) constraint DF_RegAttivita_money default ((0))
|
||||
);
|
||||
go
|
||||
|
||||
alter table RegAttivita add
|
||||
constraint FK_RegAttivita_AnagFasi foreign key(idxFase) references AnagFasi(idxFase) on update cascade,
|
||||
constraint FK_RegAttivita_Dipendenti foreign key(idxDipendente) references Dipendenti(idxDipendente) on update cascade;
|
||||
go
|
||||
|
||||
create index ix_idxDip on RegAttivita(idxDipendente)
|
||||
include(idxFase,inizio);
|
||||
go
|
||||
|
||||
create index ix_idxFase on RegAttivita(idxFase);
|
||||
go
|
||||
|
||||
create index ix_inizio on RegAttivita(inizio,idxDipendente)
|
||||
include(fine);
|
||||
go
|
||||
|
||||
create index ix_RA_inizio on RegAttivita(inizio)
|
||||
include(idxDipendente,idxFase,fine);
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', '([dbo].[f_hourInterval]([inizio],[fine]))', 'SCHEMA', 'dbo', 'TABLE', 'RegAttivita', 'COLUMN', 'oreTot';
|
||||
go
|
||||
|
||||
set identity_insert RegAttivita on;
|
||||
go
|
||||
|
||||
insert into RegAttivita(idxRA,idxDipendente,idxFase,inizio,fine,descrizione,oreTot,importo) select idxRA,idxDipendente,idxFase,inizio,fine,descrizione,convert(decimal(18,0), oreTot),importo from tmp__RegAttivita_0;
|
||||
go
|
||||
|
||||
set identity_insert RegAttivita off;
|
||||
go
|
||||
|
||||
drop table tmp__RegAttivita_0;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
create TRIGGER trg_RegAtt_upsert
|
||||
ON RegAttivita
|
||||
/*----------------------------------
|
||||
* Trigger su insert/update
|
||||
*
|
||||
* Aggiorna la tab dei RegAttivitaExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2013.01.21
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
|
||||
FOR INSERT, UPDATE
|
||||
AS
|
||||
|
||||
IF(UPDATE(idxDipendente) OR UPDATE(inizio) OR UPDATE(fine) OR UPDATE(idxFase))
|
||||
BEGIN
|
||||
-- dichiarazione variabili
|
||||
DECLARE @inizio DATETIME
|
||||
DECLARE @fine DATETIME
|
||||
DECLARE @idxDipendente INT
|
||||
|
||||
-- recupero valori x inserting
|
||||
SELECT @inizio = DATEADD(DAY,-1,CONVERT(DATE,i.inizio)), @fine = DATEADD(DAY,1,CONVERT(DATE,i.inizio)), @idxDipendente = i.idxDipendente FROM inserted i
|
||||
|
||||
--chiamo la stored di ricalcolo
|
||||
EXEC stp_ricalcolaRegAttivitaExpl_byPeriodoUser @idxDipendente, @inizio, @fine
|
||||
END
|
||||
go
|
||||
|
||||
create TRIGGER trg_RegAtt_delete
|
||||
ON RegAttivita
|
||||
/*----------------------------------
|
||||
* Trigger su delete
|
||||
*
|
||||
* Aggiorna la tab RegAttivitaExpl ricalcolando la giornata del record interessato
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2013.01.21
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
|
||||
FOR DELETE
|
||||
AS
|
||||
|
||||
-- dichiarazione variabili
|
||||
DECLARE @inizio DATETIME
|
||||
DECLARE @fine DATETIME
|
||||
DECLARE @idxDipendente INT
|
||||
|
||||
-- recupero valori x inserting
|
||||
SELECT @inizio = DATEADD(DAY,-1,CONVERT(DATE,d.inizio)), @fine = DATEADD(DAY,1,CONVERT(DATE,d.inizio)), @idxDipendente = d.idxDipendente FROM deleted d
|
||||
|
||||
--chiamo la stored di ricalcolo
|
||||
EXEC stp_ricalcolaRegAttivitaExpl_byPeriodoUser @idxDipendente, @inizio, @fine
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/******************************************************************************
|
||||
* Function f_hourInterval
|
||||
*
|
||||
* calcola intervallo orario tra 2 date/time
|
||||
*******************************************************************************/
|
||||
alter FUNCTION f_hourInterval
|
||||
(
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
|
||||
RETURNS DECIMAL(19,4)
|
||||
AS
|
||||
BEGIN
|
||||
-- sommo e restituisco tot ore
|
||||
RETURN CAST(dbo.f_minuteInterval(@inizio,@fine) AS DECIMAL(19,4))/60
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table RegAttivita drop
|
||||
constraint DF_RegAttivita_money ,
|
||||
constraint FK_RegAttivita_AnagFasi ,
|
||||
constraint FK_RegAttivita_Dipendenti ;
|
||||
go
|
||||
|
||||
exec sp_rename 'PK_RegAttivita', 'tmp__PK_RegAttivita', 'OBJECT';
|
||||
go
|
||||
|
||||
exec sp_rename 'RegAttivita', 'tmp__RegAttivita_1', 'OBJECT';
|
||||
go
|
||||
|
||||
drop trigger trg_RegAtt_delete;
|
||||
go
|
||||
|
||||
drop trigger trg_RegAtt_upsert;
|
||||
go
|
||||
|
||||
create table RegAttivita(
|
||||
idxRA int not null identity constraint PK_RegAttivita primary key,
|
||||
idxDipendente int not null,
|
||||
idxFase int not null,
|
||||
inizio datetime not null,
|
||||
fine datetime not null,
|
||||
descrizione nvarchar(500),
|
||||
oreTot as ([dbo].[f_hourInterval]([inizio],[fine])),
|
||||
importo decimal(19,4) constraint DF_RegAttivita_money default ((0))
|
||||
);
|
||||
go
|
||||
|
||||
alter table RegAttivita add
|
||||
constraint FK_RegAttivita_AnagFasi foreign key(idxFase) references AnagFasi(idxFase) on update cascade,
|
||||
constraint FK_RegAttivita_Dipendenti foreign key(idxDipendente) references Dipendenti(idxDipendente) on update cascade;
|
||||
go
|
||||
|
||||
create index ix_idxDip on RegAttivita(idxDipendente)
|
||||
include(idxFase,inizio);
|
||||
go
|
||||
|
||||
create index ix_idxFase on RegAttivita(idxFase);
|
||||
go
|
||||
|
||||
create index ix_inizio on RegAttivita(inizio,idxDipendente)
|
||||
include(fine);
|
||||
go
|
||||
|
||||
create index ix_RA_inizio on RegAttivita(inizio)
|
||||
include(idxDipendente,idxFase,fine);
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', '([dbo].[f_hourInterval]([inizio],[fine]))', 'SCHEMA', 'dbo', 'TABLE', 'RegAttivita', 'COLUMN', 'oreTot';
|
||||
go
|
||||
|
||||
set identity_insert RegAttivita on;
|
||||
go
|
||||
|
||||
insert into RegAttivita(idxRA,idxDipendente,idxFase,inizio,fine,descrizione,importo) select idxRA,idxDipendente,idxFase,inizio,fine,descrizione,importo from tmp__RegAttivita_1;
|
||||
go
|
||||
|
||||
set identity_insert RegAttivita off;
|
||||
go
|
||||
|
||||
drop table tmp__RegAttivita_1;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
create TRIGGER trg_RegAtt_delete
|
||||
ON RegAttivita
|
||||
/*----------------------------------
|
||||
* Trigger su delete
|
||||
*
|
||||
* Aggiorna la tab RegAttivitaExpl ricalcolando la giornata del record interessato
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2013.01.21
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
|
||||
FOR DELETE
|
||||
AS
|
||||
|
||||
-- dichiarazione variabili
|
||||
DECLARE @inizio DATETIME
|
||||
DECLARE @fine DATETIME
|
||||
DECLARE @idxDipendente INT
|
||||
|
||||
-- recupero valori x inserting
|
||||
SELECT @inizio = DATEADD(DAY,-1,CONVERT(DATE,d.inizio)), @fine = DATEADD(DAY,1,CONVERT(DATE,d.inizio)), @idxDipendente = d.idxDipendente FROM deleted d
|
||||
|
||||
--chiamo la stored di ricalcolo
|
||||
EXEC stp_ricalcolaRegAttivitaExpl_byPeriodoUser @idxDipendente, @inizio, @fine
|
||||
go
|
||||
|
||||
create TRIGGER trg_RegAtt_upsert
|
||||
ON RegAttivita
|
||||
/*----------------------------------
|
||||
* Trigger su insert/update
|
||||
*
|
||||
* Aggiorna la tab dei RegAttivitaExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2013.01.21
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
|
||||
FOR INSERT, UPDATE
|
||||
AS
|
||||
|
||||
IF(UPDATE(idxDipendente) OR UPDATE(inizio) OR UPDATE(fine) OR UPDATE(idxFase))
|
||||
BEGIN
|
||||
-- dichiarazione variabili
|
||||
DECLARE @inizio DATETIME
|
||||
DECLARE @fine DATETIME
|
||||
DECLARE @idxDipendente INT
|
||||
|
||||
-- recupero valori x inserting
|
||||
SELECT @inizio = DATEADD(DAY,-1,CONVERT(DATE,i.inizio)), @fine = DATEADD(DAY,1,CONVERT(DATE,i.inizio)), @idxDipendente = i.idxDipendente FROM inserted i
|
||||
|
||||
--chiamo la stored di ricalcolo
|
||||
EXEC stp_ricalcolaRegAttivitaExpl_byPeriodoUser @idxDipendente, @inizio, @fine
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_Expl_getData
|
||||
*
|
||||
* recupera elenco progetti con filtraggio ore totali per
|
||||
* - dipendente
|
||||
* - periodo
|
||||
*
|
||||
* mod: S.E.L. 2012.11.06
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_AP_Expl_getData
|
||||
(
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@dataFrom DATETIME = '19000101',
|
||||
@dataTo DATETIME = '21000101',
|
||||
@idxCliente INT = 0, -- 0 = tutti
|
||||
@showPrjArch BIT = 1 -- 1 = mostra tutti
|
||||
)
|
||||
AS
|
||||
|
||||
-- controllo se date nulle importo a min/max
|
||||
DECLARE @firstDate DATETIME
|
||||
DECLARE @lastDate DATETIME
|
||||
|
||||
SELECT @firstDate = MIN(inizio), @lastDate=DATEADD(DAY,1,MAX(inizio)) FROM RegAttivita
|
||||
SELECT @dataFrom=ISNULL(@dataFrom, @firstDate) , @dataTo=ISNULL(@dataTo, @lastDate)
|
||||
|
||||
|
||||
;WITH myCTE AS
|
||||
(
|
||||
SELECT ap.idxProgetto, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagProgetti AS ap INNER JOIN
|
||||
AnagClienti AS ac ON ac.idxCliente=ap.idxCliente INNER JOIN
|
||||
AnagFasi AS af ON ap.idxProgetto = af.idxProgetto INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE (ra.idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND (ra.inizio >= @dataFrom AND ra.inizio <= @dataTo)
|
||||
AND (ac.idxCliente = @idxCliente OR @idxCliente = 0)
|
||||
AND (ap.Attivo = CASE WHEN @showPrjArch <> 0 THEN ap.Attivo ELSE 1 END)
|
||||
GROUP BY ap.idxProgetto
|
||||
)
|
||||
SELECT ac.RagSociale
|
||||
, ap.idxProgetto
|
||||
, ap.idxCliente
|
||||
, ap.nomeProj
|
||||
, ap.descrProj
|
||||
, ISNULL(ap.budgetTime,0) AS budgetTime
|
||||
, ISNULL(ap.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(ap.OldIdx,-1) AS OldIdx
|
||||
, ap.Attivo
|
||||
, ISNULL(ap.codExt,'') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
FROM AnagClienti AS ac INNER JOIN
|
||||
AnagProgetti AS ap ON ac.idxCliente = ap.idxCliente LEFT OUTER JOIN
|
||||
myCte AS cte ON cte.idxProgetto = ap.idxProgetto
|
||||
--ORDER BY cte.totOre DESC
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_clonaLastRA_Utente
|
||||
*
|
||||
* clona un attività utente: se c'è da ultima altrimenti da zero x una certa data
|
||||
*
|
||||
* mod: S.E.L. 2013.01.17
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_RA_clonaLastRA_Utente
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME -- data x cui creare un record attività
|
||||
)
|
||||
AS
|
||||
|
||||
-- variabili
|
||||
DECLARE @idxFase INT
|
||||
DECLARE @idxRA INT
|
||||
|
||||
-- arrotondo data richiesta solo all'ora...
|
||||
SELECT @dataRif = DATEADD(HOUR, DATEPART(HOUR,@dataRif), CONVERT(DATETIME,(CONVERT(DATE,@dataRif))))
|
||||
|
||||
-- cerco se esista ultima reg attività utente...
|
||||
SELECT @idxRA=ISNULL(idxRA,0) FROM RegAttivita WHERE idxDipendente = @idxDipendente
|
||||
|
||||
-- se non ho trovato records, ovvero idxRA = 0, prendo ultima fase da elenco
|
||||
IF (@idxRA = 0)
|
||||
BEGIN
|
||||
-- calcolo ultima fase inserita...
|
||||
SELECT TOP 1 @idxFase=ISNULL(idxFase,0) FROM AnagFasi ORDER BY idxFase DESC
|
||||
-- se trovata fase inserisco!
|
||||
IF(@idxFase > 0)
|
||||
BEGIN
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (@idxDipendente, @idxFase, @dataRif, DATEADD(HOUR,1,@dataRif), '...',0)
|
||||
END
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
-- inserisco su data richeista duplicazione dell'ultima attività utente...
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
SELECT idxDipendente, idxFase, @dataRif, DATEADD(minute, DATEDIFF(MINUTE, inizio, fine), @dataRif), descrizione, importo
|
||||
FROM RegAttivita
|
||||
WHERE (idxRA = @idxRA)
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
create PROCEDURE stp_RA_InsertQuery
|
||||
(
|
||||
@idxDipendente int,
|
||||
@idxFase int,
|
||||
@inizio datetime,
|
||||
@fine datetime,
|
||||
@descrizione nvarchar(500),
|
||||
@importo decimal(19, 4)
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
INSERT INTO RegAttivita
|
||||
(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (@idxDipendente,@idxFase,@inizio,@fine,@descrizione,@importo)
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RAD_Expl_getByIdxDipData
|
||||
*
|
||||
* recupera elenco attività (con Expl dei dati da anagrafica) da idxDipendente + dataRif
|
||||
*
|
||||
* mod: S.E.L. 2013.01.23
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RAD_Expl_getByIdxDipData
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT RegAttivita.idxDipendente, RegAttivita.inizio, RegAttivita.fine, CASE WHEN ISNULL(descrizione, '') = '' THEN '-' ELSE ISNULL(descrizione, '')
|
||||
END AS descrizione, RegAttivita.oreTot, RegAttivita.oreTot * 60 AS minTot, RegAttivita.importo, AnagClienti.RagSociale, AnagProgetti.nomeProj,
|
||||
AnagFasi.nomeFase, RegAttivita.idxRA
|
||||
FROM RegAttivita INNER JOIN
|
||||
AnagFasi ON RegAttivita.idxFase = AnagFasi.idxFase INNER JOIN
|
||||
AnagProgetti ON AnagFasi.idxProgetto = AnagProgetti.idxProgetto INNER JOIN
|
||||
AnagClienti ON AnagProgetti.idxCliente = AnagClienti.idxCliente
|
||||
WHERE (RegAttivita.idxDipendente = @idxDipendente) AND (CAST(RegAttivita.inizio AS DATE) = CAST(@dataRif AS DATE) OR
|
||||
CAST(RegAttivita.fine AS DATE) = CAST(@dataRif AS DATE))
|
||||
ORDER BY RegAttivita.inizio
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* stp_ricalcolaRegAttivitaExpl_byPeriodoUser
|
||||
*
|
||||
* Ricalcola le RegAttivitaExpl x utente e intervallo date
|
||||
* mod: S.E.L. - 2013.01.21
|
||||
*----------------------------------*/
|
||||
alter PROCEDURE stp_ricalcolaRegAttivitaExpl_byPeriodoUser
|
||||
(
|
||||
@idxDipendente INT = 0,
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
-- dichiaro variabili x calcolo tempo execuzione e num records!
|
||||
DECLARE @startProc DATETIME = GETDATE()
|
||||
DECLARE @totRecords INT = 0
|
||||
|
||||
BEGIN
|
||||
|
||||
|
||||
-- faccio una tab temporanea con tallyTable x calcolo periodo intero...
|
||||
DECLARE @numD INT
|
||||
SET @numD = ( SELECT DATEDIFF(dd, @inizio, @fine ) )
|
||||
|
||||
-- crea eventuali record mancanti: data, dip, cognome-nome
|
||||
INSERT INTO RegAttivitaExpl(dataLav, idxDipendente)
|
||||
SELECT ty.Data, ty.idxDipendente
|
||||
FROM (
|
||||
SELECT CONVERT(DATE,DATEADD(dd, -N, @fine)) as Data, idxDipendente
|
||||
FROM Tally, Dipendenti
|
||||
WHERE N <= @numD -- solo dati desiderati
|
||||
AND (idxDipendente = @idxDipendente OR @idxDipendente = 0) --filtro su dipendenti
|
||||
) ty LEFT OUTER JOIN RegAttivitaExpl rae ON ty.Data=rae.dataLav AND ty.idxDipendente=rae.idxDipendente
|
||||
WHERE rae.dataLav IS NULL -- righe mancanti!
|
||||
|
||||
-- resetto a zero le eventuali righe che non hanno attività registrate
|
||||
UPDATE rae
|
||||
SET minRegAtt = 0
|
||||
,descrProj = ''
|
||||
FROM RegAttivitaExpl rae
|
||||
LEFT OUTER JOIN (
|
||||
SELECT DISTINCT idxDipendente, CONVERT(DATE,inizio) AS data
|
||||
FROM dbo.RegAttivita
|
||||
WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0) AND (inizio >= DATEADD(DAY,-1,@inizio) AND inizio <= @fine)
|
||||
GROUP BY idxDipendente, CONVERT(DATE,inizio)
|
||||
|
||||
) vra ON rae.dataLav = vra.data AND rae.idxDipendente=vra.idxDipendente
|
||||
WHERE vra.data IS NULL -- righe mancanti!
|
||||
AND ((rae.idxDipendente = @idxDipendente OR @idxDipendente = 0) AND (rae.dataLav >= @inizio AND rae.dataLav < @fine)) -- solo x dip e periodo selezionati
|
||||
|
||||
-- tab temp del record date progetti
|
||||
;WITH myCteRA AS(
|
||||
SELECT idxDipendente, CONVERT(DATE,inizio) AS data, SUM(oreTot) AS oreTot, SUM(dbo.f_minuteInterval(inizio, fine)) as minTot, dbo.f_ProgettiByDate(idxDipendente, CONVERT(DATE,inizio)) AS progetti
|
||||
FROM dbo.RegAttivita
|
||||
WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0) AND (inizio >= DATEADD(DAY,-1,@inizio) AND inizio <= @fine)
|
||||
GROUP BY idxDipendente, CONVERT(DATE,inizio)
|
||||
)
|
||||
|
||||
-- aggiorno la tab delle RegAttivitaExpl
|
||||
UPDATE rae
|
||||
SET minRegAtt = minTot
|
||||
,descrProj = ISNULL(progetti,'')
|
||||
FROM RegAttivitaExpl rae
|
||||
INNER JOIN myCteRA vra ON rae.dataLav = vra.data AND rae.idxDipendente=vra.idxDipendente
|
||||
|
||||
-- aggiorno cognome nome
|
||||
BEGIN TRY
|
||||
UPDATE rae
|
||||
SET CognomeNome = ISNULL(vcn.CognomeNome,'')
|
||||
FROM RegAttivitaExpl rae INNER JOIN v_cognomeNome vcn ON rae.idxDipendente = vcn.idxDipendente
|
||||
WHERE ISNULL(rae.CognomeNome,'') = ''
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
-- non faccio nulla
|
||||
END CATCH
|
||||
END
|
||||
|
||||
SELECT @numD = @numD * COUNT(*) FROM Dipendenti WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
|
||||
SELECT @startProc AS startTime, GETDATE() AS endTime, @numD AS numRec, DATEDIFF(ms, @startProc, GETDATE()) AS totMs, CAST(@numD AS FLOAT) * 1000 / DATEDIFF(ms, @startProc, GETDATE()) AS recPerSec
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(255, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,470 @@
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
set identity_insert dbo.zzz_rawData_SPS on
|
||||
go
|
||||
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (255, N'1932_101', '2012-09-18 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Stampo 2 impronte + modello del pezzo', '2013-01-21 00:00:00.000', N'Daniele Vanotti', 9.5, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (256, N'1932_101', '2012-09-18 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Stampo 2 impronte + modello del pezzo', '2013-01-22 00:00:00.000', N'Daniele Vanotti', 10.5, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (257, N'1932_101', '2012-09-18 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Stampo 2 impronte + modello del pezzo', '2013-01-23 00:00:00.000', N'Daniele Vanotti', 9.5, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (258, N'1932_101', '2012-09-18 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Stampo 2 impronte + modello del pezzo', '2013-01-24 00:00:00.000', N'Daniele Vanotti', 9.5, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (259, N'1950_338', '2012-12-04 00:00:00.000', N'Gilardoni Vittorio Srl', N'Progettazione conchigia + casse anima', '2013-01-21 00:00:00.000', N'Andrea Manzinali', 5, N'attrezzature2D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (260, N'1950_338', '2012-12-04 00:00:00.000', N'Gilardoni Vittorio Srl', N'Progettazione conchigia + casse anima', '2013-01-22 00:00:00.000', N'Andrea Manzinali', 1, N'attrezzature2D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (261, N'1950_338', '2012-12-04 00:00:00.000', N'Gilardoni Vittorio Srl', N'Progettazione conchigia + casse anima', '2013-01-24 00:00:00.000', N'Andrea Manzinali', 0.5, N'attrezzature2D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (262, N'1950_338', '2012-12-04 00:00:00.000', N'Gilardoni Vittorio Srl', N'Progettazione conchigia + casse anima', '2013-01-25 00:00:00.000', N'Andrea Manzinali', 0.5, N'attrezzature2D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (263, N'1957_101', '2013-01-07 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Progetto stampo trancia', '2013-01-21 00:00:00.000', N'Davide Colleoni', 7, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (264, N'1957_101', '2013-01-07 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Progetto stampo trancia', '2013-01-22 00:00:00.000', N'Davide Colleoni', 9, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (265, N'1957_101', '2013-01-07 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Progetto stampo trancia', '2013-01-23 00:00:00.000', N'Davide Colleoni', 9, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (266, N'1957_101', '2013-01-07 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Progetto stampo trancia', '2013-01-24 00:00:00.000', N'Davide Colleoni', 9, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (267, N'1957_101', '2013-01-07 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Progetto stampo trancia', '2013-01-25 00:00:00.000', N'Davide Colleoni', 6, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (268, N'1957_101', '2013-01-07 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Progetto stampo trancia', '2013-01-21 00:00:00.000', N'Ivan Ferraroli', 8, N'attrezzature3D', N'trancia 277 culle')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (269, N'1957_101', '2013-01-07 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Progetto stampo trancia', '2013-01-22 00:00:00.000', N'Ivan Ferraroli', 8, N'attrezzature3D', N'trancia 277 distanziali')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (270, N'1957_101', '2013-01-07 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Progetto stampo trancia', '2013-01-23 00:00:00.000', N'Ivan Ferraroli', 8, N'attrezzature3D', N'trancia 277 ')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (271, N'1957_101', '2013-01-07 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Progetto stampo trancia', '2013-01-24 00:00:00.000', N'Ivan Ferraroli', 8, N'attrezzature3D', N'trancia 277')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (272, N'1957_101', '2013-01-07 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Progetto stampo trancia', '2013-01-25 00:00:00.000', N'Ivan Ferraroli', 8, N'attrezzature3D', N'trancia-rinomina-distinta')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (273, N'1958_173', '2013-01-07 00:00:00.000', N'Persico', N'Sella di raffreddamento', '2013-01-24 00:00:00.000', N'Walter Salvi', 1, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (274, N'1959_173', '2013-01-07 00:00:00.000', N'Persico', N'Sella di raffreddamento', '2013-01-24 00:00:00.000', N'Walter Salvi', 1.5, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (275, N'1960_173', '2013-01-07 00:00:00.000', N'Persico', N'Sella di raffreddamento', '2013-01-24 00:00:00.000', N'Walter Salvi', 1, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (276, N'1961_173', '2013-01-07 00:00:00.000', N'Persico', N'Sella di raffreddamento', '2013-01-24 00:00:00.000', N'Walter Salvi', 1, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (277, N'1962_101', '2013-01-08 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Modifiche stampo - HONDA DX - EX 1836', '2013-01-25 00:00:00.000', N'Davide Colleoni', 3, N'attrezzature3D', N'RIGENERAZIONE COLATA')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (278, N'1964_101', '2013-01-08 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Modello del pezzo + Progetto stampo a 1 impronta', '2013-01-21 00:00:00.000', N'Andrea Manzinali', 3, N'prodotto3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (279, N'1964_101', '2013-01-08 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Modello del pezzo + Progetto stampo a 1 impronta', '2013-01-22 00:00:00.000', N'Andrea Manzinali', 7, N'prodotto3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (280, N'1964_101', '2013-01-08 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Modello del pezzo + Progetto stampo a 1 impronta', '2013-01-23 00:00:00.000', N'Andrea Manzinali', 9, N'prodotto3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (281, N'1964_101', '2013-01-08 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Modello del pezzo + Progetto stampo a 1 impronta', '2013-01-24 00:00:00.000', N'Andrea Manzinali', 8, N'prodotto3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (282, N'1964_101', '2013-01-08 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Modello del pezzo + Progetto stampo a 1 impronta', '2013-01-25 00:00:00.000', N'Andrea Manzinali', 4.5, N'prodotto3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (283, N'1964_101', '2013-01-08 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Modello del pezzo + Progetto stampo a 1 impronta', '2013-01-26 00:00:00.000', N'Andrea Manzinali', 4, N'prodotto3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (284, N'1968_101', '2013-01-10 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Rotazione stampo', '2013-01-21 00:00:00.000', N'Walter Salvi', 2, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (285, N'1968_101', '2013-01-10 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Rotazione stampo', '2013-01-22 00:00:00.000', N'Walter Salvi', 9.5, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (286, N'1968_101', '2013-01-10 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Rotazione stampo', '2013-01-23 00:00:00.000', N'Walter Salvi', 9.5, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (287, N'1968_101', '2013-01-10 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Rotazione stampo', '2013-01-24 00:00:00.000', N'Walter Salvi', 4.5, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (288, N'1968_101', '2013-01-10 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Rotazione stampo', '2013-01-25 00:00:00.000', N'Walter Salvi', 8.5, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (289, N'1968_101', '2013-01-10 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Rotazione stampo', '2013-01-21 00:00:00.000', N'Bohdan Khomonchak', 4, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (290, N'1968_101', '2013-01-10 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Rotazione stampo', '2013-01-22 00:00:00.000', N'Bohdan Khomonchak', 4, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (291, N'1968_101', '2013-01-10 00:00:00.000', N'Fonderie Mario Mazzucconi', N'Rotazione stampo', '2013-01-23 00:00:00.000', N'Bohdan Khomonchak', 4, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (292, N'1969_173', '2013-01-11 00:00:00.000', N'Persico', N'Stampo completo', '2013-01-21 00:00:00.000', N'Walter Salvi', 7.5, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (293, N'1969_173', '2013-01-11 00:00:00.000', N'Persico', N'Stampo completo', '2013-01-24 00:00:00.000', N'Walter Salvi', 0.5, N'attrezzature3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (294, N'1970_341', '2013-01-16 00:00:00.000', N'PANMECCANICA', N'introduzione delle lavorazioni + disegni 2D', '2013-01-21 00:00:00.000', N'Matteo Leggeri', 8, N'prodotto3D', N'')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (295, N'1970_341', '2013-01-16 00:00:00.000', N'PANMECCANICA', N'introduzione delle lavorazioni + disegni 2D', '2013-01-22 00:00:00.000', N'Matteo Leggeri', 8, N'prodotto3D', N'6 ore corpo valvola + 2 ore coperchio')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (296, N'1970_341', '2013-01-16 00:00:00.000', N'PANMECCANICA', N'introduzione delle lavorazioni + disegni 2D', '2013-01-23 00:00:00.000', N'Matteo Leggeri', 9, N'prodotto3D', N'5 ore coperchio--- 4ore power unit')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (297, N'1970_341', '2013-01-16 00:00:00.000', N'PANMECCANICA', N'introduzione delle lavorazioni + disegni 2D', '2013-01-24 00:00:00.000', N'Matteo Leggeri', 8, N'prodotto3D', N'power unit')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (298, N'1970_341', '2013-01-16 00:00:00.000', N'PANMECCANICA', N'introduzione delle lavorazioni + disegni 2D', '2013-01-25 00:00:00.000', N'Matteo Leggeri', 8, N'prodotto3D', N'power unit')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (299, N'1970_341', '2013-01-16 00:00:00.000', N'PANMECCANICA', N'introduzione delle lavorazioni + disegni 2D', '2013-01-26 00:00:00.000', N'Matteo Leggeri', 2, N'attrezzature2D', N'corpo valvola')
|
||||
INSERT INTO dbo.zzz_rawData_SPS
|
||||
(ID, codCom, inizioCom, cliente, Fase, Data, CognomeNome, durata, attivita, descrizione)
|
||||
VALUES (300, N'1970_341', '2013-01-16 00:00:00.000', N'PANMECCANICA', N'introduzione delle lavorazioni + disegni 2D', '2013-01-26 00:00:00.000', N'Matteo Leggeri', 2, N'prodotto3D', N'power unit')
|
||||
go
|
||||
|
||||
set identity_insert dbo.zzz_rawData_SPS off
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
set identity_insert dbo.RegAttivita on
|
||||
go
|
||||
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (257, 2, 4, '2013-01-21 08:00:00.000', '2013-01-21 13:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (258, 2, 4, '2013-01-22 10:00:00.000', '2013-01-22 11:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (259, 2, 4, '2013-01-24 10:00:00.000', '2013-01-24 10:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (260, 2, 4, '2013-01-25 08:00:00.000', '2013-01-25 08:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (261, 2, 15, '2013-01-21 10:00:00.000', '2013-01-21 13:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (262, 2, 15, '2013-01-22 08:00:00.000', '2013-01-22 15:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (263, 2, 15, '2013-01-23 08:00:00.000', '2013-01-23 17:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (264, 2, 15, '2013-01-24 08:00:00.000', '2013-01-24 16:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (265, 2, 15, '2013-01-25 10:00:00.000', '2013-01-25 14:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (266, 2, 15, '2013-01-26 08:00:00.000', '2013-01-26 12:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (267, 3, 8, '2013-01-21 08:00:00.000', '2013-01-21 15:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (268, 3, 8, '2013-01-22 08:00:00.000', '2013-01-22 17:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (269, 3, 8, '2013-01-23 08:00:00.000', '2013-01-23 17:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (270, 3, 8, '2013-01-24 08:00:00.000', '2013-01-24 17:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (271, 3, 8, '2013-01-25 08:00:00.000', '2013-01-25 14:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (272, 3, 13, '2013-01-25 10:00:00.000', '2013-01-25 13:00:00.000', N'RIGENERAZIONE COLATA', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (273, 4, 3, '2013-01-21 08:00:00.000', '2013-01-21 17:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (274, 4, 3, '2013-01-22 08:00:00.000', '2013-01-22 18:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (275, 4, 3, '2013-01-23 08:00:00.000', '2013-01-23 17:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (276, 4, 3, '2013-01-24 08:00:00.000', '2013-01-24 17:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (277, 6, 9, '2013-01-24 12:00:00.000', '2013-01-24 13:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (278, 6, 10, '2013-01-24 14:00:00.000', '2013-01-24 15:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (279, 6, 11, '2013-01-24 16:00:00.000', '2013-01-24 17:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (280, 6, 12, '2013-01-24 18:00:00.000', '2013-01-24 19:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (281, 6, 19, '2013-01-21 10:00:00.000', '2013-01-21 12:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (282, 6, 19, '2013-01-22 08:00:00.000', '2013-01-22 17:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (283, 6, 19, '2013-01-23 08:00:00.000', '2013-01-23 17:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (284, 6, 19, '2013-01-24 08:00:00.000', '2013-01-24 12:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (285, 6, 19, '2013-01-25 08:00:00.000', '2013-01-25 16:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (286, 6, 20, '2013-01-21 08:00:00.000', '2013-01-21 15:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (287, 6, 20, '2013-01-24 10:00:00.000', '2013-01-24 10:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (288, 7, 8, '2013-01-21 08:00:00.000', '2013-01-21 16:00:00.000', N'trancia 277 culle', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (289, 7, 8, '2013-01-22 08:00:00.000', '2013-01-22 16:00:00.000', N'trancia 277 distanziali', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (290, 7, 8, '2013-01-23 08:00:00.000', '2013-01-23 16:00:00.000', N'trancia 277 ', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (291, 7, 8, '2013-01-24 08:00:00.000', '2013-01-24 16:00:00.000', N'trancia 277', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (292, 7, 8, '2013-01-25 08:00:00.000', '2013-01-25 16:00:00.000', N'trancia-rinomina-distinta', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (293, 8, 70, '2013-01-26 08:00:00.000', '2013-01-26 10:00:00.000', N'corpo valvola', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (294, 8, 70, '2013-01-21 08:00:00.000', '2013-01-21 16:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (295, 8, 70, '2013-01-22 08:00:00.000', '2013-01-22 16:00:00.000', N'6 ore corpo valvola + 2 ore coperchio', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (296, 8, 70, '2013-01-23 08:00:00.000', '2013-01-23 17:00:00.000', N'5 ore coperchio--- 4ore power unit', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (297, 8, 70, '2013-01-24 08:00:00.000', '2013-01-24 16:00:00.000', N'power unit', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (298, 8, 70, '2013-01-25 08:00:00.000', '2013-01-25 16:00:00.000', N'power unit', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (299, 8, 70, '2013-01-26 10:00:00.000', '2013-01-26 12:00:00.000', N'power unit', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (300, 11, 19, '2013-01-21 08:00:00.000', '2013-01-21 12:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (301, 11, 19, '2013-01-22 08:00:00.000', '2013-01-22 12:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (302, 11, 19, '2013-01-23 08:00:00.000', '2013-01-23 12:00:00.000', N'', 0.0000)
|
||||
go
|
||||
|
||||
set identity_insert dbo.RegAttivita off
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-20', 5, N'Spreafico Roberto [900008]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-20', 9, N'Gervasoni Lucia [900013]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-20', 10, N'Rota Nodari Giambattista [900002]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-21', 5, N'Spreafico Roberto [900008]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-21', 9, N'Gervasoni Lucia [900013]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-21', 10, N'Rota Nodari Giambattista [900002]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-22', 5, N'Spreafico Roberto [900008]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-22', 9, N'Gervasoni Lucia [900013]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-22', 10, N'Rota Nodari Giambattista [900002]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-23', 5, N'Spreafico Roberto [900008]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-23', 9, N'Gervasoni Lucia [900013]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-23', 10, N'Rota Nodari Giambattista [900002]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-24', 5, N'Spreafico Roberto [900008]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-24', 9, N'Gervasoni Lucia [900013]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-24', 10, N'Rota Nodari Giambattista [900002]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-24', 11, N'Khomonchak Bohdan [900014]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-25', 4, N'Vanotti Daniele [900006]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-25', 5, N'Spreafico Roberto [900008]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-25', 9, N'Gervasoni Lucia [900013]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-25', 10, N'Rota Nodari Giambattista [900002]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-25', 11, N'Khomonchak Bohdan [900014]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-26', 3, N'Colleoni Davide [900010]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-26', 4, N'Vanotti Daniele [900006]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-26', 5, N'Spreafico Roberto [900008]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-26', 6, N'Salvi Walter [900004]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-26', 7, N'Ferraroli Ivan [900016]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-26', 9, N'Gervasoni Lucia [900013]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-26', 10, N'Rota Nodari Giambattista [900002]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-26', 11, N'Khomonchak Bohdan [900014]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-27', 2, N'Manzinali Andrea [900011]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-27', 3, N'Colleoni Davide [900010]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-27', 4, N'Vanotti Daniele [900006]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-27', 5, N'Spreafico Roberto [900008]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-27', 6, N'Salvi Walter [900004]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-27', 7, N'Ferraroli Ivan [900016]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-27', 8, N'Leggeri Matteo [900015]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-27', 9, N'Gervasoni Lucia [900013]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-27', 10, N'Rota Nodari Giambattista [900002]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-27', 11, N'Khomonchak Bohdan [900014]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-28', 2, N'Manzinali Andrea [900011]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-28', 3, N'Colleoni Davide [900010]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-28', 4, N'Vanotti Daniele [900006]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-28', 5, N'Spreafico Roberto [900008]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-28', 6, N'Salvi Walter [900004]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-28', 7, N'Ferraroli Ivan [900016]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-28', 8, N'Leggeri Matteo [900015]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-28', 9, N'Gervasoni Lucia [900013]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-28', 10, N'Rota Nodari Giambattista [900002]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-28', 11, N'Khomonchak Bohdan [900014]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-29', 2, N'Manzinali Andrea [900011]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-29', 3, N'Colleoni Davide [900010]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-29', 4, N'Vanotti Daniele [900006]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-29', 5, N'Spreafico Roberto [900008]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-29', 6, N'Salvi Walter [900004]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-29', 7, N'Ferraroli Ivan [900016]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-29', 8, N'Leggeri Matteo [900015]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-29', 9, N'Gervasoni Lucia [900013]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-29', 10, N'Rota Nodari Giambattista [900002]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-29', 11, N'Khomonchak Bohdan [900014]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-30', 2, N'Manzinali Andrea [900011]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-30', 3, N'Colleoni Davide [900010]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-30', 4, N'Vanotti Daniele [900006]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-30', 5, N'Spreafico Roberto [900008]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-30', 6, N'Salvi Walter [900004]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-30', 7, N'Ferraroli Ivan [900016]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-30', 8, N'Leggeri Matteo [900015]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-30', 9, N'Gervasoni Lucia [900013]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-30', 10, N'Rota Nodari Giambattista [900002]', 0, N'')
|
||||
INSERT INTO dbo.RegAttivitaExpl
|
||||
VALUES ('2013-01-30', 11, N'Khomonchak Bohdan [900014]', 0, N'')
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(256, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,299 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_import_SpsDataRaw
|
||||
*
|
||||
* importa tracciato dati SPS x utente e date indicate
|
||||
*
|
||||
* mod: S.E.L. 2012.11.20
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE import.stp_import_SpsDataRaw
|
||||
(
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
/**************************************************
|
||||
* inizio importando eventuali clienti...
|
||||
**************************************************/
|
||||
;WITH myCteClienti AS
|
||||
(
|
||||
select * from ZZZ_SPS_AnagClienti
|
||||
)
|
||||
INSERT INTO AnagClienti(RagSociale, indirizzo, cap, citta, prov, nota, oldIdx, Attivo, codExt)
|
||||
SELECT cte.RagSoc, cte.Indirizzo, cte.cap, cte.citta, cte.prov, cte.codCliExt +' - ' + cte.RagSoc, cte.idxCli, 1,cte.codCliExt
|
||||
FROM AnagClienti anag
|
||||
RIGHT OUTER JOIN myCteClienti cte ON anag.RagSociale = cte.RagSoc
|
||||
WHERE anag.idxCliente IS NULL
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali progetti
|
||||
**************************************************/
|
||||
;WITH myCteProgetti AS
|
||||
(
|
||||
SELECT * FROM ZZZ_SPS_AnagCommesse
|
||||
)
|
||||
INSERT INTO AnagProgetti(idxCliente, nomeProj, descrProj, budgetTime, Attivo, codExt)
|
||||
SELECT cli.idxCliente, cte.codExt, cte.Descrizione + ' ['+ISNULL(cte.Codice_Disegno,' - ')+']', cte.BudgetOre, 1, cte.codExt
|
||||
FROM AnagProgetti anag
|
||||
RIGHT OUTER JOIN myCteProgetti cte ON anag.nomeProj = cte.codExt INNER JOIN
|
||||
AnagClienti Cli ON Cli.codExt = RIGHT(cte.codExt,3)
|
||||
WHERE anag.idxProgetto IS NULL
|
||||
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali fasi
|
||||
**************************************************/
|
||||
;WITH myCteFasi AS
|
||||
(
|
||||
SELECT DISTINCT codCom, Fase FROM zzz_rawData_SPS
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, '', cte.Fase, cte.Fase, 1, 0, 1
|
||||
FROM myCteFasi cte INNER JOIN AnagProgetti Pro ON cte.codCom = Pro.codExt
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.Fase
|
||||
WHERE anag.idxFase IS NULL
|
||||
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali sottofasi
|
||||
**************************************************/
|
||||
;WITH myCteSubFasi AS
|
||||
(
|
||||
SELECT DISTINCT codCom, Fase, attivita FROM zzz_rawData_SPS
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, idxFaseAncest, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, Fas.idxFase as idxFaseAncest, '', cte.attivita, cte.attivita, 1, 0, 1
|
||||
FROM myCteSubFasi cte
|
||||
INNER JOIN AnagProgetti Pro ON cte.codCom = Pro.codExt
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.Fase AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.attivita AND anag.idxFaseAncest = Fas.idxFase
|
||||
WHERE anag.idxFaseAncest IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* update cognome nome dipendenti
|
||||
**************************************************/
|
||||
UPDATE Dipendenti
|
||||
SET codDipendenteExt = Nome + ' ' + Cognome
|
||||
|
||||
UPDATE Dipendenti
|
||||
SET codDipendenteExt='Bohdan Khomonchak'
|
||||
WHERE cognome='Khomonchak'
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo records!
|
||||
**************************************************/
|
||||
-- faccio un sort x dipendente-giorno x accodare i records
|
||||
|
||||
-- faccio un sort x dipendente-giorno x accodare i records
|
||||
;WITH myCteStep1 AS
|
||||
(
|
||||
SELECT CognomeNome
|
||||
,Data
|
||||
, ROW_NUMBER() OVER(PARTITION BY CognomeNome,Data ORDER BY CognomeNome,Data) as riga
|
||||
, codCom
|
||||
, Fase
|
||||
, attivita
|
||||
, durata*60 as minuti
|
||||
, descrizione
|
||||
FROM zzz_rawData_SPS
|
||||
)
|
||||
|
||||
, myCteStep2 AS
|
||||
(
|
||||
SELECT *
|
||||
, DATEADD(MINUTE,480+120*(riga-1),Data) AS Inizio
|
||||
, DATEADD(MINUTE,480+120*(riga-1)+minuti,Data) AS Fine
|
||||
FROM myCteStep1
|
||||
)
|
||||
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione)
|
||||
SELECT Dip.idxDipendente, SFas.idxFase, cte.Inizio,cte.Fine, ISNULL(cte.Descrizione,'-')
|
||||
FROM myCteStep2 cte
|
||||
INNER JOIN Dipendenti Dip ON cte.CognomeNome = dip.codDipendenteExt
|
||||
INNER JOIN AnagProgetti Pro ON cte.codCom = Pro.codExt -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.Fase AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
INNER JOIN AnagFasi SFas ON SFas.nomeFase = cte.attivita AND SFas.idxProgetto = Pro.idxProgetto AND SFas.idxFaseAncest=fas.idxFase
|
||||
LEFT OUTER JOIN RegAttivita dati ON dati.inizio = cte.Inizio AND dati.fine = cte.Fine AND dati.descrizione = cte.Descrizione AND dati.idxDipendente = Dip.idxDipendente
|
||||
WHERE dati.idxRA IS NULL
|
||||
|
||||
|
||||
--- forzo ricalcolo attività expl!
|
||||
EXEC stp_ricalcolaRegAttivitaExpl_byPeriodoUser 0, '20120101', '20130131'
|
||||
|
||||
|
||||
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
truncate table regattivita
|
||||
|
||||
|
||||
-- faccio un sort x dipendente-giorno x accodare i records
|
||||
;WITH myCteStep1 AS
|
||||
(
|
||||
SELECT CognomeNome
|
||||
,Data
|
||||
, ROW_NUMBER() OVER(PARTITION BY CognomeNome,Data ORDER BY CognomeNome,Data) as riga
|
||||
, codCom
|
||||
, Fase
|
||||
, attivita
|
||||
, durata*60 as minuti
|
||||
, descrizione
|
||||
FROM zzz_rawData_SPS
|
||||
)
|
||||
|
||||
, myCteStep2 AS
|
||||
(
|
||||
SELECT *
|
||||
, DATEADD(MINUTE,480+120*(riga-1),Data) AS Inizio
|
||||
, DATEADD(MINUTE,480+120*(riga-1)+minuti,Data) AS Fine
|
||||
FROM myCteStep1
|
||||
)
|
||||
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione)
|
||||
SELECT Dip.idxDipendente, SFas.idxFase, cte.Inizio,cte.Fine, ISNULL(cte.Descrizione,'-')
|
||||
FROM myCteStep2 cte
|
||||
INNER JOIN Dipendenti Dip ON cte.CognomeNome = dip.codDipendenteExt
|
||||
INNER JOIN AnagProgetti Pro ON cte.codCom = Pro.codExt -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.Fase AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
INNER JOIN AnagFasi SFas ON SFas.nomeFase = cte.attivita AND SFas.idxProgetto = Pro.idxProgetto AND SFas.idxFaseAncest=fas.idxFase
|
||||
LEFT OUTER JOIN RegAttivita dati ON dati.inizio = cte.Inizio AND dati.fine = cte.Fine AND dati.descrizione = cte.Descrizione AND dati.idxDipendente = Dip.idxDipendente
|
||||
WHERE dati.idxRA IS NULL
|
||||
|
||||
|
||||
|
||||
select * from RegAttivita
|
||||
|
||||
select * from RegAttivitaExpl
|
||||
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
alter TRIGGER trg_RegAtt_upsert
|
||||
ON RegAttivita
|
||||
/*----------------------------------
|
||||
* Trigger su insert/update
|
||||
*
|
||||
* Aggiorna la tab dei RegAttivitaExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2013.01.21
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
|
||||
FOR INSERT, UPDATE
|
||||
AS
|
||||
|
||||
IF(UPDATE(idxDipendente) OR UPDATE(inizio) OR UPDATE(fine) OR UPDATE(idxFase))
|
||||
BEGIN
|
||||
-- dichiarazione variabili
|
||||
DECLARE @inizio DATETIME
|
||||
DECLARE @fine DATETIME
|
||||
DECLARE @idxDipendente INT
|
||||
|
||||
|
||||
-- recupero valori OLD
|
||||
SELECT @inizio = DATEADD(DAY,-1,CONVERT(DATE,d.inizio)), @fine = DATEADD(DAY,1,CONVERT(DATE,d.inizio)), @idxDipendente = d.idxDipendente FROM deleted d
|
||||
|
||||
--chiamo la stored di ricalcolo
|
||||
EXEC stp_ricalcolaRegAttivitaExpl_byPeriodoUser @idxDipendente, @inizio, @fine
|
||||
|
||||
-- recupero valori NEW
|
||||
SELECT @inizio = DATEADD(DAY,-1,CONVERT(DATE,i.inizio)), @fine = DATEADD(DAY,1,CONVERT(DATE,i.inizio)), @idxDipendente = i.idxDipendente FROM inserted i
|
||||
|
||||
--chiamo la stored di ricalcolo
|
||||
EXEC stp_ricalcolaRegAttivitaExpl_byPeriodoUser @idxDipendente, @inizio, @fine
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_clonaLastRA_Utente
|
||||
*
|
||||
* clona un attività utente: se c'è da ultima altrimenti da zero x una certa data
|
||||
*
|
||||
* mod: S.E.L. 2013.01.17
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RA_clonaLastRA_Utente
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME -- data x cui creare un record attività
|
||||
)
|
||||
AS
|
||||
|
||||
-- variabili
|
||||
DECLARE @idxFase INT
|
||||
DECLARE @idxRA INT
|
||||
|
||||
-- arrotondo data richiesta solo all'ora...
|
||||
SELECT @dataRif = DATEADD(HOUR, DATEPART(HOUR,@dataRif), CONVERT(DATETIME,(CONVERT(DATE,@dataRif))))
|
||||
|
||||
-- cerco se esista ultima reg attività utente...
|
||||
SELECT @idxRA=ISNULL((SELECT idxRA FROM RegAttivita WHERE idxDipendente = @idxDipendente),0)
|
||||
|
||||
-- se non ho trovato records, ovvero idxRA = 0, prendo ultima fase da elenco
|
||||
IF (@idxRA = 0)
|
||||
BEGIN
|
||||
-- calcolo ultima fase inserita...
|
||||
SELECT TOP 1 @idxFase=ISNULL(idxFase,0) FROM AnagFasi ORDER BY idxFase DESC
|
||||
-- se trovata fase inserisco!
|
||||
IF(@idxFase > 0)
|
||||
BEGIN
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (@idxDipendente, @idxFase, @dataRif, DATEADD(HOUR,1,@dataRif), '...',0)
|
||||
END
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
-- inserisco su data richeista duplicazione dell'ultima attività utente...
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
SELECT idxDipendente, idxFase, @dataRif, DATEADD(minute, DATEDIFF(MINUTE, inizio, fine), @dataRif), descrizione, importo
|
||||
FROM RegAttivita
|
||||
WHERE (idxRA = @idxRA)
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
@@ -0,0 +1,744 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_import_paymoRaw
|
||||
*
|
||||
* importa tracciato dati da paymo x utente e date indicate
|
||||
*
|
||||
* mod: S.E.L. 2012.11.20
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE import.stp_import_PaymoDataRaw
|
||||
(
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
/**************************************************
|
||||
* inizio importando eventuali clienti...
|
||||
**************************************************/
|
||||
;WITH myCteClienti AS
|
||||
(
|
||||
SELECT DISTINCT Cliente FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagClienti(RagSociale, nota, Attivo)
|
||||
SELECT cte.Cliente, cte.Cliente, 1
|
||||
FROM AnagClienti anag
|
||||
RIGHT OUTER JOIN myCteClienti cte ON anag.RagSociale = cte.Cliente
|
||||
WHERE anag.idxCliente IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali progetti
|
||||
**************************************************/
|
||||
;WITH myCteProgetti AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagProgetti(idxCliente, nomeProj, descrProj, Attivo)
|
||||
SELECT cli.idxCliente, cte.Progetto, cte.Progetto, 1
|
||||
FROM AnagProgetti anag
|
||||
RIGHT OUTER JOIN myCteProgetti cte ON anag.nomeProj = cte.Progetto INNER JOIN AnagClienti Cli ON Cli.RagSociale = cte.Cliente
|
||||
WHERE anag.idxProgetto IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali fasi
|
||||
**************************************************/
|
||||
;WITH myCteFasi AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto, TaskList FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, '', cte.TaskList, cte.TaskList, 1, 0, 1
|
||||
FROM myCteFasi cte INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.TaskList AND anag.idxProgetto=pro.idxProgetto
|
||||
WHERE anag.idxFase IS NULL
|
||||
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo eventuali sottofasi
|
||||
**************************************************/
|
||||
;WITH myCteSubFasi AS
|
||||
(
|
||||
SELECT DISTINCT Cliente, Progetto, TaskList, Task FROM zzz_RawDataPaymo
|
||||
)
|
||||
INSERT INTO AnagFasi(idxProgetto, idxFaseAncest, codFase, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo)
|
||||
SELECT Pro.idxProgetto, Fas.idxFase as idxFaseAncest, '', cte.task, cte.task, 1, 0, 1
|
||||
FROM myCteSubFasi cte
|
||||
INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale
|
||||
INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.TaskList AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
LEFT OUTER JOIN AnagFasi anag ON anag.nomeFase = cte.Task AND anag.idxFaseAncest = Fas.idxFase
|
||||
WHERE anag.idxFaseAncest IS NULL
|
||||
|
||||
|
||||
/**************************************************
|
||||
* importo records!
|
||||
**************************************************/
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione)
|
||||
SELECT Dip.idxDipendente, SFas.idxFase, cte.Inizio, cte.Fine, cte.Descrizione
|
||||
FROM zzz_RawDataPaymo cte
|
||||
INNER JOIN Dipendenti Dip ON cte.Dipendente = dip.codDipendenteExt
|
||||
INNER JOIN AnagClienti Cli ON cte.Cliente = Cli.RagSociale
|
||||
INNER JOIN AnagProgetti Pro ON cte.Progetto = Pro.nomeProj -- and pro.idxCliente=cli.idxCliente
|
||||
INNER JOIN AnagFasi Fas ON Fas.nomeFase = cte.TaskList AND Fas.idxProgetto = Pro.idxProgetto AND Fas.idxFaseAncest=0
|
||||
INNER JOIN AnagFasi SFas ON SFas.nomeFase = cte.Task AND SFas.idxProgetto = Pro.idxProgetto AND SFas.idxFaseAncest=fas.idxFase
|
||||
LEFT OUTER JOIN RegAttivita dati ON dati.inizio = cte.Inizio AND dati.fine = cte.Fine AND dati.descrizione = cte.Descrizione AND dati.idxDipendente = Dip.idxDipendente
|
||||
WHERE dati.idxRA IS NULL
|
||||
|
||||
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table AnagFasi add
|
||||
budgetTime decimal(19,4);
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'Budget del progetto (in ore)', 'SCHEMA', 'dbo', 'TABLE', 'AnagFasi', 'COLUMN', 'budgetTime';
|
||||
go
|
||||
|
||||
alter table AnagFasi add
|
||||
budgetMoney decimal(19,4);
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AF_getByIdxProj
|
||||
*
|
||||
* elenco fasi da progetto
|
||||
*
|
||||
* mod: S.E.L. 2012.10.31
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AF_getByIdxProj
|
||||
(
|
||||
@idxProgetto INT
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
/*
|
||||
SELECT idxFase, idxProgetto, codFase, idxFaseAncest, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo, codClasse, codExt
|
||||
FROM AnagFasi
|
||||
WHERE (idxProgetto = @idxProgetto)
|
||||
ORDER BY codFase
|
||||
*/
|
||||
|
||||
-- dichiaro variabili "accessorie"
|
||||
DECLARE @idxDipendente INT = 0 -- 0 = tutti
|
||||
DECLARE @dataFrom DATETIME = '19000101'
|
||||
DECLARE @dataTo DATETIME = '99991231'
|
||||
|
||||
-- controllo se date nulle importo a min/max
|
||||
DECLARE @firstDate DATETIME
|
||||
DECLARE @lastDate DATETIME
|
||||
|
||||
SELECT @firstDate = MIN(inizio), @lastDate=DATEADD(DAY,1,MAX(inizio)) FROM RegAttivita
|
||||
SELECT @dataFrom = ISNULL(@dataFrom, @firstDate), @dataTo=ISNULL(@dataTo, @lastDate)
|
||||
|
||||
|
||||
;WITH myCTE AS
|
||||
(
|
||||
SELECT af.idxFase, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagFasi AS af INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE (ra.idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND (ra.inizio >= @dataFrom AND ra.inizio <= @dataTo)
|
||||
AND (af.idxProgetto = @idxProgetto OR @idxProgetto = 0)
|
||||
GROUP BY af.idxFase
|
||||
)
|
||||
SELECT af.idxFase
|
||||
, af.idxProgetto
|
||||
, af.codFase
|
||||
, af.idxFaseAncest
|
||||
, af.nomeFase
|
||||
, af.descrizioneFase
|
||||
, af.enableTime
|
||||
, af.enableMoney
|
||||
, af.Attivo
|
||||
, ISNULL(af.budgetTime,0) AS budgetTime
|
||||
, ISNULL(af.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(af.codClasse,'') AS codClasse
|
||||
, ISNULL(af.codExt, '') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
FROM AnagFasi AS af LEFT OUTER JOIN
|
||||
myCte AS cte ON cte.idxFase = af.idxFase
|
||||
WHERE (af.idxProgetto = @idxProgetto OR @idxProgetto = 0)
|
||||
ORDER BY af.nomeFase , af.codFase
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AF_getByIdxFase
|
||||
*
|
||||
* recupera fasi da idx
|
||||
*
|
||||
* mod: S.E.L. 2012.11.12
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AF_getByIdxFase
|
||||
(
|
||||
@idxFase INT
|
||||
)
|
||||
AS
|
||||
|
||||
SET NOCOUNT ON;
|
||||
/*
|
||||
SELECT *
|
||||
FROM AnagFasi
|
||||
WHERE @idxFase = idxFase
|
||||
*/
|
||||
|
||||
-- dichiaro variabili "accessorie"
|
||||
DECLARE @idxDipendente INT = 0 -- 0 = tutti
|
||||
DECLARE @dataFrom DATETIME = '19000101'
|
||||
DECLARE @dataTo DATETIME = '99991231'
|
||||
|
||||
-- controllo se date nulle importo a min/max
|
||||
DECLARE @firstDate DATETIME
|
||||
DECLARE @lastDate DATETIME
|
||||
|
||||
SELECT @firstDate = MIN(inizio), @lastDate=DATEADD(DAY,1,MAX(inizio)) FROM RegAttivita
|
||||
SELECT @dataFrom = ISNULL(@dataFrom, @firstDate), @dataTo=ISNULL(@dataTo, @lastDate)
|
||||
|
||||
|
||||
;WITH myCTE AS
|
||||
(
|
||||
SELECT af.idxFase, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagFasi AS af INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE (ra.idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND (ra.inizio >= @dataFrom AND ra.inizio <= @dataTo)
|
||||
AND (af.idxFase = @idxFase)
|
||||
GROUP BY af.idxFase
|
||||
)
|
||||
SELECT af.idxFase
|
||||
, af.idxProgetto
|
||||
, af.codFase
|
||||
, af.idxFaseAncest
|
||||
, af.nomeFase
|
||||
, af.descrizioneFase
|
||||
, af.enableTime
|
||||
, af.enableMoney
|
||||
, af.Attivo
|
||||
, ISNULL(af.budgetTime,0) AS budgetTime
|
||||
, ISNULL(af.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(af.codClasse,'') AS codClasse
|
||||
, ISNULL(af.codExt, '') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
FROM AnagFasi AS af LEFT OUTER JOIN
|
||||
myCte AS cte ON cte.idxFase = af.idxFase
|
||||
WHERE (af.idxFase = @idxFase)
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AF_Expl_getData
|
||||
*
|
||||
* recupera elenco fasi con filtraggio ore totali per
|
||||
* - dipendente
|
||||
* - periodo
|
||||
*
|
||||
* mod: S.E.L. 2013.01.31
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_AF_Expl_getData
|
||||
(
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@dataFrom DATETIME = '19000101',
|
||||
@dataTo DATETIME = '99991231',
|
||||
@idxProgetto INT = 0
|
||||
)
|
||||
AS
|
||||
|
||||
-- controllo se date nulle importo a min/max
|
||||
DECLARE @firstDate DATETIME
|
||||
DECLARE @lastDate DATETIME
|
||||
|
||||
SELECT @firstDate = MIN(inizio), @lastDate=DATEADD(DAY,1,MAX(inizio)) FROM RegAttivita
|
||||
SELECT @dataFrom = ISNULL(@dataFrom, @firstDate), @dataTo=ISNULL(@dataTo, @lastDate)
|
||||
|
||||
|
||||
;WITH myCTE AS
|
||||
(
|
||||
SELECT af.idxFase, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagFasi AS af INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE (ra.idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND (ra.inizio >= @dataFrom AND ra.inizio <= @dataTo)
|
||||
AND (af.idxProgetto = @idxProgetto OR @idxProgetto = 0)
|
||||
GROUP BY af.idxFase
|
||||
)
|
||||
SELECT af.idxFase
|
||||
, af.idxProgetto
|
||||
, af.codFase
|
||||
, af.idxFaseAncest
|
||||
, af.nomeFase
|
||||
, af.descrizioneFase
|
||||
, af.enableTime
|
||||
, af.enableMoney
|
||||
, af.Attivo
|
||||
, ISNULL(af.budgetTime,0) AS budgetTime
|
||||
, ISNULL(af.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(af.codClasse,'') AS codClasse
|
||||
, ISNULL(af.codExt, '') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
FROM AnagFasi AS af LEFT OUTER JOIN
|
||||
myCte AS cte ON cte.idxFase = af.idxFase
|
||||
WHERE (af.idxProgetto = @idxProgetto OR @idxProgetto = 0)
|
||||
ORDER BY af.nomeFase , af.codFase
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
alter VIEW v_selProgetti
|
||||
AS
|
||||
SELECT dbo.AnagProgetti.idxProgetto AS value, dbo.AnagClienti.RagSociale + ' - ' + dbo.AnagProgetti.nomeProj AS label, dbo.AnagClienti.idxCliente AS conditio
|
||||
FROM dbo.AnagClienti INNER JOIN
|
||||
dbo.AnagProgetti ON dbo.AnagClienti.idxCliente = dbo.AnagProgetti.idxCliente
|
||||
WHERE (dbo.AnagProgetti.Attivo = 1)
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AF_getLastByIdxDipendente
|
||||
*
|
||||
* elenco ULTIME fasi dato dipendente
|
||||
*
|
||||
* mod: S.E.L. 2012.11.09
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AF_getLastByIdxDipendente
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@num2show INT
|
||||
)
|
||||
AS
|
||||
|
||||
SET NOCOUNT ON;
|
||||
|
||||
;WITH myCTE AS(
|
||||
SELECT TOP(@num2show) *
|
||||
FROM RegAttivita
|
||||
WHERE idxDipendente = @idxDipendente
|
||||
ORDER BY inizio DESC
|
||||
)
|
||||
|
||||
SELECT *, 0 AS totOre
|
||||
FROM AnagFasi
|
||||
WHERE idxFase IN (
|
||||
SELECT DISTINCT idxFase FROM myCTE
|
||||
UNION
|
||||
SELECT DISTINCT af.idxFaseAncest FROM AnagFasi af INNER JOIN myCTE ra ON af.idxFase=ra.idxFase
|
||||
)
|
||||
ORDER BY codFase
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_Expl_getData
|
||||
*
|
||||
* recupera elenco progetti con filtraggio ore totali per
|
||||
* - dipendente
|
||||
* - periodo
|
||||
*
|
||||
* mod: S.E.L. 2013.01.30
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_Expl_getData
|
||||
(
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@dataFrom DATETIME = '19000101',
|
||||
@dataTo DATETIME = '99991231',
|
||||
@idxCliente INT = 0, -- 0 = tutti
|
||||
@showPrjArch BIT = 1 -- 1 = mostra tutti
|
||||
)
|
||||
AS
|
||||
|
||||
-- controllo se date nulle importo a min/max
|
||||
DECLARE @firstDate DATETIME
|
||||
DECLARE @lastDate DATETIME
|
||||
|
||||
SELECT @firstDate = MIN(inizio), @lastDate=DATEADD(DAY,1,MAX(inizio)) FROM RegAttivita
|
||||
SELECT @dataFrom=ISNULL(@dataFrom, @firstDate) , @dataTo=ISNULL(@dataTo, @lastDate)
|
||||
|
||||
|
||||
;WITH myCTE AS
|
||||
(
|
||||
SELECT ap.idxProgetto, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagProgetti AS ap INNER JOIN
|
||||
AnagClienti AS ac ON ac.idxCliente=ap.idxCliente INNER JOIN
|
||||
AnagFasi AS af ON ap.idxProgetto = af.idxProgetto INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE (ra.idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND (ra.inizio >= @dataFrom AND ra.inizio <= @dataTo)
|
||||
AND (ac.idxCliente = @idxCliente OR @idxCliente = 0)
|
||||
AND (ap.Attivo = CASE WHEN @showPrjArch <> 0 THEN ap.Attivo ELSE 1 END)
|
||||
GROUP BY ap.idxProgetto
|
||||
)
|
||||
SELECT ac.RagSociale
|
||||
, ap.idxProgetto
|
||||
, ap.idxCliente
|
||||
, ap.nomeProj
|
||||
, ap.descrProj
|
||||
, ISNULL(ap.budgetTime,0) AS budgetTime
|
||||
, ISNULL(ap.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(ap.OldIdx,-1) AS OldIdx
|
||||
, ap.Attivo
|
||||
, ISNULL(ap.codExt,'') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
, ISNULL(ap.avvio,'19000101') AS avvio
|
||||
, ISNULL(ap.chiusura,'99991231') AS chiusura
|
||||
FROM AnagClienti AS ac INNER JOIN
|
||||
AnagProgetti AS ap ON ac.idxCliente = ap.idxCliente LEFT OUTER JOIN
|
||||
myCte AS cte ON cte.idxProgetto = ap.idxProgetto
|
||||
WHERE (ac.idxCliente = @idxCliente OR @idxCliente = 0)
|
||||
AND (ap.Attivo = CASE WHEN @showPrjArch <> 0 THEN ap.Attivo ELSE 1 END)
|
||||
ORDER BY ac.RagSociale, ap.nomeProj
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_getByIdxCli
|
||||
*
|
||||
* recupera elenco progetti da cliente
|
||||
*
|
||||
* mod: S.E.L. 2012.10.26
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_getByIdxCli
|
||||
(
|
||||
@idxCliente INT,
|
||||
@showPrjArch BIT
|
||||
)
|
||||
AS
|
||||
|
||||
/*
|
||||
SELECT *
|
||||
FROM AnagProgetti
|
||||
WHERE idxCliente = CASE WHEN @idxCliente > 0 THEN @idxCliente ELSE idxCliente END
|
||||
AND Attivo = CASE WHEN @showPrjArch <> 0 THEN Attivo ELSE 1 END
|
||||
ORDER BY nomeProj
|
||||
*/
|
||||
|
||||
;WITH myCTE AS
|
||||
(
|
||||
SELECT ap.idxProgetto, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagProgetti AS ap INNER JOIN
|
||||
AnagClienti AS ac ON ac.idxCliente=ap.idxCliente INNER JOIN
|
||||
AnagFasi AS af ON ap.idxProgetto = af.idxProgetto INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE (ac.idxCliente = @idxCliente OR @idxCliente = 0)
|
||||
AND (ap.Attivo = CASE WHEN @showPrjArch <> 0 THEN ap.Attivo ELSE 1 END)
|
||||
GROUP BY ap.idxProgetto
|
||||
)
|
||||
SELECT ac.RagSociale
|
||||
, ap.idxProgetto
|
||||
, ap.idxCliente
|
||||
, ap.nomeProj
|
||||
, ap.descrProj
|
||||
, ISNULL(ap.budgetTime,0) AS budgetTime
|
||||
, ISNULL(ap.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(ap.OldIdx,-1) AS OldIdx
|
||||
, ap.Attivo
|
||||
, ISNULL(ap.codExt,'') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
, ISNULL(ap.avvio,'19000101') AS avvio
|
||||
, ISNULL(ap.chiusura,'99991231') AS chiusura
|
||||
FROM AnagClienti AS ac INNER JOIN
|
||||
AnagProgetti AS ap ON ac.idxCliente = ap.idxCliente LEFT OUTER JOIN
|
||||
myCte AS cte ON cte.idxProgetto = ap.idxProgetto
|
||||
WHERE (ac.idxCliente = @idxCliente OR @idxCliente = 0)
|
||||
AND (ap.Attivo = CASE WHEN @showPrjArch <> 0 THEN ap.Attivo ELSE 1 END)
|
||||
ORDER BY ac.RagSociale, ap.nomeProj
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_getByIdxPrj
|
||||
*
|
||||
* recupera elenco progetti da idx
|
||||
*
|
||||
* mod: S.E.L. 2012.11.06
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_getByIdxPrj
|
||||
(
|
||||
@idxProgetto INT
|
||||
)
|
||||
AS
|
||||
/*
|
||||
SELECT *
|
||||
FROM AnagProgetti
|
||||
WHERE idxProgetto = @idxProgetto
|
||||
ORDER BY nomeProj
|
||||
*/
|
||||
|
||||
;WITH myCTE AS
|
||||
(
|
||||
SELECT ap.idxProgetto, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagProgetti AS ap INNER JOIN
|
||||
AnagClienti AS ac ON ac.idxCliente=ap.idxCliente INNER JOIN
|
||||
AnagFasi AS af ON ap.idxProgetto = af.idxProgetto INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE ap.idxProgetto = @idxProgetto
|
||||
GROUP BY ap.idxProgetto
|
||||
)
|
||||
SELECT ac.RagSociale
|
||||
, ap.idxProgetto
|
||||
, ap.idxCliente
|
||||
, ap.nomeProj
|
||||
, ap.descrProj
|
||||
, ISNULL(ap.budgetTime,0) AS budgetTime
|
||||
, ISNULL(ap.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(ap.OldIdx,-1) AS OldIdx
|
||||
, ap.Attivo
|
||||
, ISNULL(ap.codExt,'') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
, ISNULL(ap.avvio,'19000101') AS avvio
|
||||
, ISNULL(ap.chiusura,'99991231') AS chiusura
|
||||
FROM AnagClienti AS ac INNER JOIN
|
||||
AnagProgetti AS ap ON ac.idxCliente = ap.idxCliente INNER JOIN
|
||||
myCte AS cte ON cte.idxProgetto = ap.idxProgetto
|
||||
WHERE ap.idxProgetto = @idxProgetto
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_insertQuery
|
||||
*
|
||||
* inserisce un progetto in anagrafica
|
||||
*
|
||||
* mod: S.E.L. 2013.01.30
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_insertQuery
|
||||
(
|
||||
@idxCliente int,
|
||||
@nomeProj nvarchar(50),
|
||||
@descrProj nvarchar(250),
|
||||
@budgetTime decimal(19, 4),
|
||||
@budgetMoney decimal(19, 4),
|
||||
@avvio DATETIME = '19000101',
|
||||
@chiusura DATETIME = '99991231'
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
INSERT INTO AnagProgetti
|
||||
(idxCliente, nomeProj, descrProj, budgetTime, budgetMoney, Attivo, avvio, chiusura)
|
||||
VALUES (@idxCliente,@nomeProj,@descrProj,@budgetTime,@budgetMoney, 1, @avvio, @chiusura);
|
||||
|
||||
|
||||
--SELECT idxProgetto, idxCliente, nomeProj, descrProj, budgetTime, budgetMoney, OldIdx, Attivo FROM AnagProgetti WHERE (idxProgetto = SCOPE_IDENTITY())
|
||||
DECLARE @idxPrj INT
|
||||
SELECT @idxPrj = SCOPE_IDENTITY()
|
||||
EXEC stp_AP_getByIdxPrj @idxPrj
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_update
|
||||
*
|
||||
* elimina un progetto da anagrafica
|
||||
*
|
||||
* mod: S.E.L. 2013.01.30
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_update
|
||||
(
|
||||
@idxCliente INT,
|
||||
@nomeProj NVARCHAR(50),
|
||||
@descrProj NVARCHAR(250),
|
||||
@budgetTime DECIMAL(19, 4),
|
||||
@budgetMoney DECIMAL(19, 4),
|
||||
@avvio DATETIME = '19000101',
|
||||
@chiusura DATETIME = '99991231',
|
||||
@Original_idxProgetto INT
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
UPDATE dbo.AnagProgetti
|
||||
SET idxCliente = @idxCliente,
|
||||
nomeProj = @nomeProj,
|
||||
descrProj = @descrProj,
|
||||
budgetTime = @budgetTime,
|
||||
budgetMoney = @budgetMoney,
|
||||
avvio = @avvio,
|
||||
chiusura = @chiusura
|
||||
WHERE idxProgetto = @Original_idxProgetto;
|
||||
|
||||
/*
|
||||
SELECT idxProgetto, idxCliente, nomeProj, descrProj, budgetTime, budgetMoney, Attivo
|
||||
FROM AnagProgetti
|
||||
WHERE (idxProgetto =@Original_idxProgetto)
|
||||
*/
|
||||
EXEC stp_AP_getByIdxPrj @Original_idxProgetto
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AF_updateFaseAncest
|
||||
*
|
||||
* cambia la fase ancestor per una fase e le relative sottofasi dell'albero
|
||||
*
|
||||
* mod: S.E.L. 2013.01.31
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_AF_updateFaseAncest
|
||||
(
|
||||
@idxFaseAncest INT,
|
||||
@Original_idxFase INT
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
UPDATE AnagFasi
|
||||
SET idxFaseAncest = @idxFaseAncest
|
||||
WHERE idxFase = @Original_idxFase;
|
||||
|
||||
SELECT * FROM AnagFasi WHERE idxFase = @Original_idxFase
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AF_updateProegtto
|
||||
*
|
||||
* cambia il progetto per una fase e le relative sottofasi dell'albero
|
||||
*
|
||||
* mod: S.E.L. 2013.01.31
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_AF_updateProgetto
|
||||
(
|
||||
@idxProgetto INT,
|
||||
@Original_idxFase INT
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
UPDATE AnagFasi
|
||||
SET idxProgetto = @idxProgetto
|
||||
WHERE idxFase = @Original_idxFase;
|
||||
|
||||
SELECT * FROM AnagFasi WHERE idxFase = @Original_idxFase
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_clonaLastRA_Utente
|
||||
*
|
||||
* clona un attività utente: se c'è da ultima altrimenti da zero x una certa data
|
||||
*
|
||||
* mod: S.E.L. 2013.01.17
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RA_clonaLastRA_Utente
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME -- data x cui creare un record attività
|
||||
)
|
||||
AS
|
||||
|
||||
-- variabili
|
||||
DECLARE @idxFase INT
|
||||
DECLARE @idxRA INT
|
||||
|
||||
-- arrotondo data richiesta solo all'ora...
|
||||
SELECT @dataRif = DATEADD(HOUR, DATEPART(HOUR,@dataRif), CONVERT(DATETIME,(CONVERT(DATE,@dataRif))))
|
||||
|
||||
-- cerco se esista ultima reg attività utente...
|
||||
SELECT @idxRA=ISNULL((SELECT TOP 1 idxRA FROM RegAttivita WHERE idxDipendente = @idxDipendente),0)
|
||||
|
||||
-- se non ho trovato records, ovvero idxRA = 0, prendo ultima fase da elenco
|
||||
IF (@idxRA = 0)
|
||||
BEGIN
|
||||
-- calcolo ultima fase inserita...
|
||||
SELECT TOP 1 @idxFase=ISNULL(idxFase,0) FROM AnagFasi ORDER BY idxFase DESC
|
||||
-- se trovata fase inserisco!
|
||||
IF(@idxFase > 0)
|
||||
BEGIN
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (@idxDipendente, @idxFase, @dataRif, DATEADD(HOUR,1,@dataRif), '...',0)
|
||||
END
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
-- inserisco su data richeista duplicazione dell'ultima attività utente...
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
SELECT idxDipendente, idxFase, @dataRif, DATEADD(minute, DATEDIFF(MINUTE, inizio, fine), @dataRif), descrizione, importo
|
||||
FROM RegAttivita
|
||||
WHERE (idxRA = @idxRA)
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(270, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,714 @@
|
||||
alter table AnagKeyValue add
|
||||
descrizione nvarchar(250);
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* Trigger su insert/update/delete
|
||||
*
|
||||
* Aggiorna giustificativi nella tab TimbratureExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2012.12.04
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
alter TRIGGER trg_giustUpdateTimbr
|
||||
ON Giustificativi
|
||||
FOR INSERT, UPDATE
|
||||
AS
|
||||
|
||||
-- controllo se rescord esista altrimenti lo creo!!!
|
||||
DECLARE @trovate INT = 0
|
||||
DECLARE @idxDipendente INT
|
||||
DECLARE @dataRif DATETIME
|
||||
SET @trovate = ISNULL( ( SELECT COUNT(*) FROM TimbratureExpl te INNER JOIN inserted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav) ,0)
|
||||
IF(@trovate = 0)
|
||||
BEGIN
|
||||
SELECT @idxDipendente = idxDipendente, @dataRif=dataLav FROM inserted
|
||||
EXEC stp_ricalcolaTimbratureExpl @idxDipendente, @dataRif
|
||||
END
|
||||
|
||||
|
||||
-- CONTROLLO SE IL RECORD NON SIA BLOCCATO!!!
|
||||
DECLARE @block BIT
|
||||
SET @block = ( SELECT te.block FROM TimbratureExpl te INNER JOIN deleted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav )
|
||||
IF(@block = 0)
|
||||
BEGIN
|
||||
-- prendo tutte le "vecchie" righe (deleted) e x le giornate relative TOLGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust='MAL' THEN 0 ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN 0 ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN 0 ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN 0 ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN deleted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
|
||||
END
|
||||
|
||||
SET @block = ( SELECT te.block FROM TimbratureExpl te INNER JOIN inserted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav )
|
||||
IF(@block = 0)
|
||||
BEGIN
|
||||
-- prendo le "nuove" righe (inserted) e x le giornate relative AGGIUNGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust='MAL' THEN g.minuti ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN g.minuti ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN g.minuti ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN g.minuti ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN inserted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* Trigger su insert/update/delete
|
||||
*
|
||||
* Aggiorna giustificativi nella tab TimbratureExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2012.12.04
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
create TRIGGER trg_giustDelUpdTimbr
|
||||
ON Giustificativi
|
||||
FOR DELETE
|
||||
AS
|
||||
|
||||
-- controllo se rescord esista altrimenti lo creo!!!
|
||||
DECLARE @trovate INT = 0
|
||||
DECLARE @idxDipendente INT
|
||||
DECLARE @dataRif DATETIME
|
||||
|
||||
-- CONTROLLO SE IL RECORD NON SIA BLOCCATO!!!
|
||||
DECLARE @block BIT
|
||||
SET @block = ( SELECT te.block FROM TimbratureExpl te INNER JOIN deleted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav )
|
||||
IF(@block = 0)
|
||||
BEGIN
|
||||
-- prendo tutte le "vecchie" righe (deleted) e x le giornate relative TOLGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust='MAL' THEN 0 ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN 0 ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN 0 ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN 0 ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN deleted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
alter VIEW v_selFasi
|
||||
AS
|
||||
SELECT idxFase AS value, nomeFase AS label, idxProgetto AS conditio, enableTime, codFase, idxFase * enableTime AS valueGroup
|
||||
FROM dbo.AnagFasi
|
||||
go
|
||||
|
||||
exec sp_updateextendedproperty 'MS_DiagramPane1', '[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
|
||||
Begin DesignProperties =
|
||||
Begin PaneConfigurations =
|
||||
Begin PaneConfiguration = 0
|
||||
NumPanes = 4
|
||||
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
|
||||
End
|
||||
Begin PaneConfiguration = 1
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 4 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 2
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 2 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 3
|
||||
NumPanes = 3
|
||||
Configuration = "(H (4 [30] 2 [40] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 4
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [56] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 5
|
||||
NumPanes = 2
|
||||
Configuration = "(H (2 [66] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 6
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [50] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 7
|
||||
NumPanes = 1
|
||||
Configuration = "(V (3))"
|
||||
End
|
||||
Begin PaneConfiguration = 8
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1[56] 4[18] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 9
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [75] 4))"
|
||||
End
|
||||
Begin PaneConfiguration = 10
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1[66] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 11
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [60] 2))"
|
||||
End
|
||||
Begin PaneConfiguration = 12
|
||||
NumPanes = 1
|
||||
Configuration = "(H (1) )"
|
||||
End
|
||||
Begin PaneConfiguration = 13
|
||||
NumPanes = 1
|
||||
Configuration = "(V (4))"
|
||||
End
|
||||
Begin PaneConfiguration = 14
|
||||
NumPanes = 1
|
||||
Configuration = "(V (2))"
|
||||
End
|
||||
ActivePaneConfig = 0
|
||||
End
|
||||
Begin DiagramPane =
|
||||
Begin Origin =
|
||||
Top = 0
|
||||
Left = 0
|
||||
End
|
||||
Begin Tables =
|
||||
Begin Table = "AnagFasi"
|
||||
Begin Extent =
|
||||
Top = 6
|
||||
Left = 38
|
||||
Bottom = 284
|
||||
Right = 209
|
||||
End
|
||||
DisplayFlags = 280
|
||||
TopColumn = 0
|
||||
End
|
||||
End
|
||||
End
|
||||
Begin SQLPane =
|
||||
End
|
||||
Begin DataPane =
|
||||
Begin ParameterDefaults = ""
|
||||
End
|
||||
Begin ColumnWidths = 9
|
||||
Width = 284
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 11985
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
End
|
||||
End
|
||||
Begin CriteriaPane =
|
||||
Begin ColumnWidths = 11
|
||||
Column = 1440
|
||||
Alias = 900
|
||||
Table = 1170
|
||||
Output = 720
|
||||
Append = 1400
|
||||
NewValue = 1170
|
||||
SortType = 1350
|
||||
SortOrder = 1410
|
||||
GroupBy = 1350
|
||||
Filter = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
End
|
||||
End
|
||||
End
|
||||
', 'SCHEMA', 'dbo', 'VIEW', 'v_selFasi';
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
alter VIEW v_selProgetti
|
||||
AS
|
||||
SELECT dbo.AnagProgetti.idxProgetto AS value, dbo.AnagClienti.RagSociale + ' - ' + dbo.AnagProgetti.nomeProj AS label, dbo.AnagClienti.idxCliente AS conditio,
|
||||
dbo.AnagProgetti.Attivo
|
||||
FROM dbo.AnagClienti INNER JOIN
|
||||
dbo.AnagProgetti ON dbo.AnagClienti.idxCliente = dbo.AnagProgetti.idxCliente
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AF_getByIdxProj
|
||||
*
|
||||
* elenco fasi da progetto
|
||||
*
|
||||
* mod: S.E.L. 2012.10.31
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AF_getByIdxProj
|
||||
(
|
||||
@idxProgetto INT
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
/*
|
||||
SELECT idxFase, idxProgetto, codFase, idxFaseAncest, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo, codClasse, codExt
|
||||
FROM AnagFasi
|
||||
WHERE (idxProgetto = @idxProgetto)
|
||||
ORDER BY codFase
|
||||
*/
|
||||
|
||||
-- dichiaro variabili "accessorie"
|
||||
DECLARE @idxDipendente INT = 0 -- 0 = tutti
|
||||
DECLARE @dataFrom DATETIME = '19000101'
|
||||
DECLARE @dataTo DATETIME = '99991231'
|
||||
|
||||
-- controllo se date nulle importo a min/max
|
||||
DECLARE @firstDate DATETIME
|
||||
DECLARE @lastDate DATETIME
|
||||
|
||||
SELECT @firstDate = MIN(inizio), @lastDate=DATEADD(DAY,1,MAX(inizio)) FROM RegAttivita
|
||||
SELECT @dataFrom = ISNULL(@dataFrom, @firstDate), @dataTo=ISNULL(@dataTo, @lastDate)
|
||||
|
||||
|
||||
;WITH myCTE AS
|
||||
(
|
||||
SELECT af.idxFase, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagFasi AS af INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE (ra.idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND (ra.inizio >= @dataFrom AND ra.inizio <= @dataTo)
|
||||
AND (af.idxProgetto = @idxProgetto OR @idxProgetto = 0)
|
||||
GROUP BY af.idxFase
|
||||
)
|
||||
SELECT af.idxFase
|
||||
, af.idxProgetto
|
||||
, af.codFase
|
||||
, af.idxFaseAncest
|
||||
, af.nomeFase
|
||||
, af.descrizioneFase
|
||||
, af.enableTime
|
||||
, af.enableMoney
|
||||
, af.Attivo
|
||||
, ISNULL(af.budgetTime,0) AS budgetTime
|
||||
, ISNULL(af.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(af.codClasse,'') AS codClasse
|
||||
, ISNULL(af.codExt, '') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
FROM AnagFasi AS af LEFT OUTER JOIN
|
||||
myCte AS cte ON cte.idxFase = af.idxFase
|
||||
WHERE (af.idxProgetto = @idxProgetto OR @idxProgetto = 0)
|
||||
ORDER BY af.codFase, af.nomeFase
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AF_InsertQuery
|
||||
*
|
||||
* elenco fasi da progetto
|
||||
*
|
||||
* mod: S.E.L. 2012.11.02
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AF_InsertQuery
|
||||
(
|
||||
@idxProgetto INT,
|
||||
@idxFaseAncest INT,
|
||||
@nomeFase NVARCHAR(50),
|
||||
@descrizioneFase NVARCHAR(250),
|
||||
@enableTime BIT,
|
||||
@enableMoney BIT,
|
||||
@budgetTime decimal(19, 4),
|
||||
@budgetMoney decimal(19, 4),
|
||||
@Attivo BIT
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
INSERT INTO AnagFasi ( codFase, idxProgetto, idxFaseAncest, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo, budgetTime, budgetMoney)
|
||||
VALUES ('', @idxProgetto, @idxFaseAncest, @nomeFase, @descrizioneFase, @enableTime, @enableMoney, @Attivo, @budgetTime, @budgetMoney);
|
||||
|
||||
SELECT idxFase, idxProgetto, codFase, idxFaseAncest, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo FROM AnagFasi WHERE (idxFase = SCOPE_IDENTITY())
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AF_getByIdxProj
|
||||
*
|
||||
* elenco fasi da progetto
|
||||
*
|
||||
* mod: S.E.L. 2012.11.02
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AF_updateQuery
|
||||
(
|
||||
@nomeFase nvarchar(50),
|
||||
@descrizioneFase nvarchar(250),
|
||||
@enableTime bit,
|
||||
@enableMoney bit,
|
||||
@Attivo int,
|
||||
@budgetTime DECIMAL(19, 4),
|
||||
@budgetMoney DECIMAL(19, 4),
|
||||
@Original_idxFase int
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
UPDATE AnagFasi
|
||||
SET nomeFase = @nomeFase,
|
||||
descrizioneFase = @descrizioneFase,
|
||||
enableTime = @enableTime,
|
||||
enableMoney = @enableMoney,
|
||||
budgetTime = @budgetTime,
|
||||
budgetMoney = @budgetMoney,
|
||||
Attivo = @Attivo
|
||||
WHERE idxFase = @Original_idxFase;
|
||||
|
||||
SELECT * FROM AnagFasi WHERE idxFase = @Original_idxFase
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* STORED PROCEDURE stp_giust_insByDate
|
||||
*
|
||||
* Aggiunge un giustificativo per coprire la durata necessaria a chiudere la giornata indicata
|
||||
* mod: S.E.L. - 2012.12.10
|
||||
*----------------------------------*/
|
||||
alter PROCEDURE stp_giust_insByDate
|
||||
(
|
||||
@idxDipendente INT = 0,
|
||||
@dataRif DATETIME,
|
||||
@codGiust NVARCHAR(5) = 'PERM'
|
||||
)
|
||||
AS
|
||||
|
||||
BEGIN TRAN
|
||||
--min necessari x chiudere giornata
|
||||
DECLARE @minPerm INT = 0
|
||||
|
||||
-- variabili
|
||||
DECLARE @minArr INT
|
||||
--SELECT @minArr=dbo.f_minArrotDip(@idxDipendente)
|
||||
SELECT @minArr = ISNULL(valInt,1) FROM AnagKeyValue WHERE nomeVar = 'minutiRoundDay'
|
||||
|
||||
-- calcolo minuti
|
||||
SELECT @minPerm = (CEILING(CONVERT(FLOAT,minOrd-minLav)/@minArr)*@minArr)
|
||||
FROM TimbratureExpl
|
||||
WHERE isOkLav = 0
|
||||
AND idxDipendente = @idxDipendente
|
||||
AND dataLav = @dataRif
|
||||
|
||||
-- INSERT giustificativo!
|
||||
INSERT INTO Giustificativi
|
||||
VALUES (@dataRif,@idxDipendente,@codGiust,@minPerm,1)
|
||||
|
||||
COMMIT TRAN
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RAD_Expl_getByIdxDipData
|
||||
*
|
||||
* recupera elenco attività (con Expl dei dati da anagrafica) da idxDipendente + dataRif
|
||||
*
|
||||
* mod: S.E.L. 2013.01.23
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RAD_Expl_getByIdxDipData
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT d.Cognome + ' ' + d.Nome AS CognomeNome, ra.idxDipendente, ra.inizio, ra.fine
|
||||
, CASE WHEN ISNULL(descrizione, '') = '' THEN '-' ELSE ISNULL(descrizione, '') END AS descrizione
|
||||
, ra.oreTot, ra.oreTot * 60 AS minTot, ra.importo, ac.RagSociale, ap.nomeProj, af.nomeFase, ra.idxRA
|
||||
FROM RegAttivita ra INNER JOIN
|
||||
AnagFasi af ON ra.idxFase = af.idxFase INNER JOIN
|
||||
AnagProgetti ap ON af.idxProgetto = ap.idxProgetto INNER JOIN
|
||||
AnagClienti ac ON ap.idxCliente = ac.idxCliente INNER JOIN
|
||||
Dipendenti d ON ra.idxDipendente = d.idxDipendente
|
||||
WHERE (ra.idxDipendente = @idxDipendente OR @idxDipendente = 0) AND (CAST(ra.inizio AS DATE) = CAST(@dataRif AS DATE) OR
|
||||
CAST(ra.fine AS DATE) = CAST(@dataRif AS DATE))
|
||||
ORDER BY ra.inizio
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_ReportOreDip
|
||||
*
|
||||
* elenco ore dipendenti
|
||||
*
|
||||
* mod: S.E.L. 2013.02.04
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE export.stp_ReportOreDip
|
||||
(
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@dataFrom DATETIME,
|
||||
@dataTo DATETIME
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
DECLARE @minArr INT
|
||||
|
||||
SELECT @minArr = ISNULL(valInt,1) FROM AnagKeyValue WHERE nomeVar = 'minutiRoundDay'
|
||||
|
||||
-- elenco mensile...
|
||||
SELECT dataLav, CognomeNome,
|
||||
entrata_1, uscita_1, entrata_2, uscita_2,
|
||||
entrata_3, uscita_3, entrata_4, uscita_4,
|
||||
FLOOR(CAST(h_lav AS DECIMAL(9,3))*60/@minArr)/(60/@minArr) AS h_lavorate,
|
||||
FLOOR(CAST(minStra AS DECIMAL(9,3))/@minArr)/(60/@minArr) AS h_straordinarie,
|
||||
CEILING(CAST(minPerm AS DECIMAL(9,3))/@minArr)/(60/@minArr) AS h_permessi,
|
||||
CEILING(CAST(minFer AS DECIMAL(9,3))/@minArr)/(60/@minArr) AS h_ferie,
|
||||
CEILING(CAST(minMal AS DECIMAL(9,3))/@minArr)/(60/@minArr) AS h_malattia,
|
||||
CEILING(CAST(minFest AS DECIMAL(9,3))/@minArr)/(60/@minArr) AS h_festivita
|
||||
FROM TimbratureExpl
|
||||
WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND dataLav >= CAST(@dataFrom AS DATE)
|
||||
AND dataLav <= CAST(@dataTo AS DATE)
|
||||
ORDER BY CognomeNome, dataLav
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RAD_Expl_getByIdxDipPeriodo
|
||||
*
|
||||
* recupera elenco attività (con Expl dei dati da anagrafica) da idxDipendente + periodo + opzionali cliente e progetto
|
||||
*
|
||||
* mod: S.E.L. 2013.02.01
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_RAD_Expl_getByIdxDipPeriodo
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataFrom DATETIME,
|
||||
@dataTo DATETIME,
|
||||
@idxCliente INT = 0, -- 0 = tutti
|
||||
@idxProgetto INT = 0, -- 0 = tutti
|
||||
@soloAncest BIT = 0 -- 0 = tutti
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT d.Cognome + ' ' + d.Nome AS CognomeNome, ra.idxDipendente, ra.inizio, ra.fine
|
||||
, CASE WHEN ISNULL(descrizione, '') = '' THEN '-' ELSE ISNULL(descrizione, '') END AS descrizione
|
||||
, ra.oreTot, ra.oreTot * 60 AS minTot, ra.importo, ac.RagSociale, ap.nomeProj,
|
||||
af.nomeFase, ra.idxRA
|
||||
FROM RegAttivita ra INNER JOIN
|
||||
AnagFasi af ON ra.idxFase = af.idxFase INNER JOIN
|
||||
AnagProgetti ap ON af.idxProgetto = ap.idxProgetto INNER JOIN
|
||||
AnagClienti ac ON ap.idxCliente = ac.idxCliente INNER JOIN
|
||||
Dipendenti d ON ra.idxDipendente = d.idxDipendente
|
||||
WHERE (ra.idxDipendente = @idxDipendente OR @idxDipendente=0)
|
||||
AND (ra.inizio >= CAST(@dataFrom AS DATE) AND ra.inizio <= CAST(@dataTo AS DATE))
|
||||
AND (ac.idxCliente = @idxCliente OR @idxCliente <= 0)
|
||||
AND (ap.idxProgetto = @idxProgetto OR @idxProgetto <= 0)
|
||||
AND (af.idxFaseAncest = CASE WHEN @soloAncest <> 0 THEN 0 ELSE af.idxFaseAncest END )
|
||||
ORDER BY ra.inizio
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_updateFase
|
||||
*
|
||||
* update fase x record selezionato
|
||||
*
|
||||
* mod: S.E.L. 2013.02.01
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_RA_updateFase
|
||||
(
|
||||
@idxFase int,
|
||||
@Original_idxRA int
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
UPDATE RegAttivita
|
||||
SET idxFase = @idxFase
|
||||
WHERE (idxRA = @Original_idxRA);
|
||||
go
|
||||
|
||||
/*************************************
|
||||
* STORED PROCEDURE stp_VSFasiOpt_ByPrj
|
||||
*
|
||||
* elenco fasi dato progetto con calmpo valore a zero se fase "ancestor"
|
||||
*
|
||||
* mod : 2013.02.01
|
||||
* aut : S.E. Locatelli
|
||||
**************************************/
|
||||
create PROCEDURE stp_VSFasiOpt_ByPrj
|
||||
(
|
||||
@conditio INT = 0
|
||||
,@soloAttivi BIT = 0 -- 0 = tutti, 1 = solo attivi x time tracking
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT value as valueGroup, label, conditio, valueGroup as value
|
||||
FROM v_selFasi
|
||||
WHERE conditio = @conditio
|
||||
AND (enableTime = @soloAttivi OR @soloAttivi = 0)
|
||||
ORDER BY codFase, label
|
||||
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*************************************
|
||||
* STORED PROCEDURE stp_VSFasi_ByPrj
|
||||
*
|
||||
* elenco fasi dato progetto
|
||||
*
|
||||
* mod : 26/09/2012
|
||||
* aut : S.E. Locatelli
|
||||
**************************************/
|
||||
alter PROCEDURE stp_VSFasi_ByPrj
|
||||
(
|
||||
@conditio INT = 0
|
||||
,@soloAttivi BIT = 0 -- 0 = tutti, 1 = solo attivi x time tracking
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT value, label, conditio
|
||||
FROM v_selFasi
|
||||
WHERE conditio = @conditio
|
||||
AND (enableTime = @soloAttivi OR @soloAttivi = 0)
|
||||
ORDER BY codFase, label
|
||||
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
/*************************************
|
||||
* STORED PROCEDURE stp_VSPrj
|
||||
*
|
||||
* elenco progetti "formattato" by cliente
|
||||
*
|
||||
* mod : 26/09/2012
|
||||
* aut : S.E. Locatelli
|
||||
**************************************/
|
||||
alter PROCEDURE stp_VSPrj
|
||||
(
|
||||
@soloAttivi BIT = 0 -- 0 = tutti, 1 = solo attivi
|
||||
)
|
||||
AS
|
||||
/*
|
||||
WITH myCTE AS
|
||||
(
|
||||
SELECT MIN(value) as value, conditio AS label, conditio
|
||||
FROM v_selProgetti
|
||||
GROUP BY conditio
|
||||
|
||||
UNION
|
||||
|
||||
SELECT *
|
||||
FROM v_selProgetti
|
||||
)
|
||||
|
||||
SELECT *
|
||||
FROM myCTE
|
||||
ORDER BY conditio, label
|
||||
*/
|
||||
|
||||
SELECT *
|
||||
FROM v_selProgetti
|
||||
WHERE (Attivo = @soloAttivi OR @soloAttivi = 0)
|
||||
ORDER BY label
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
/*************************************
|
||||
* STORED PROCEDURE stp_VSPrj
|
||||
*
|
||||
* elenco progetti "formattato" by cliente
|
||||
*
|
||||
* mod : 26/09/2012
|
||||
* aut : S.E. Locatelli
|
||||
**************************************/
|
||||
alter PROCEDURE stp_VSPrj_byConditio
|
||||
(
|
||||
@conditio NVARCHAR(50)
|
||||
,@soloAttivi BIT = 0 -- 0 = tutti, 1 = solo attivi
|
||||
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
SELECT value, label, conditio, Attivo
|
||||
FROM v_selProgetti
|
||||
WHERE (conditio = @conditio OR @conditio=0)
|
||||
AND (Attivo = @soloAttivi OR @soloAttivi = 0)
|
||||
ORDER BY label
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(290, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,181 @@
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
set identity_insert dbo.AnagFasi on
|
||||
go
|
||||
|
||||
INSERT INTO dbo.AnagFasi
|
||||
(idxFase, idxProgetto, codFase, idxFaseAncest, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo, codClasse, codExt, budgetTime, budgetMoney)
|
||||
VALUES (74, 5, N'F.5.74.', 5, N'prodotto3D', N'prodotto3D', 1, 0, 1, NULL, NULL, NULL, NULL)
|
||||
INSERT INTO dbo.AnagFasi
|
||||
(idxFase, idxProgetto, codFase, idxFaseAncest, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo, codClasse, codExt, budgetTime, budgetMoney)
|
||||
VALUES (75, 6, N'F.8.75.', 8, N'attrezzature2D', N'attrezzature2D', 1, 0, 1, NULL, NULL, NULL, NULL)
|
||||
INSERT INTO dbo.AnagFasi
|
||||
(idxFase, idxProgetto, codFase, idxFaseAncest, nomeFase, descrizioneFase, enableTime, enableMoney, Attivo, codClasse, codExt, budgetTime, budgetMoney)
|
||||
VALUES (76, 8, N'F.15.76.', 15, N'attrezzature3D', N'attrezzature3D', 1, 0, 1, NULL, NULL, NULL, NULL)
|
||||
go
|
||||
|
||||
set identity_insert dbo.AnagFasi off
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
set identity_insert dbo.RegAttivita on
|
||||
go
|
||||
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (319, 11, 56, '2013-01-04 08:00:00.000', '2013-01-04 12:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (320, 2, 57, '2013-01-08 08:00:00.000', '2013-01-08 09:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (321, 2, 57, '2013-01-09 08:00:00.000', '2013-01-09 16:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (322, 2, 57, '2013-01-10 08:00:00.000', '2013-01-10 16:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (323, 2, 57, '2013-01-11 08:00:00.000', '2013-01-11 16:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (324, 2, 57, '2013-01-14 08:00:00.000', '2013-01-14 16:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (325, 2, 57, '2013-01-15 08:00:00.000', '2013-01-15 16:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (326, 2, 57, '2013-01-16 08:00:00.000', '2013-01-16 14:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (327, 2, 57, '2013-01-21 08:00:00.000', '2013-01-21 11:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (328, 2, 57, '2013-01-25 08:00:00.000', '2013-01-25 12:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (329, 2, 57, '2013-01-28 08:00:00.000', '2013-01-28 16:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (330, 2, 57, '2013-01-29 08:00:00.000', '2013-01-29 16:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (331, 2, 57, '2013-01-30 08:00:00.000', '2013-01-30 16:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (332, 2, 57, '2013-01-31 08:00:00.000', '2013-01-31 16:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (333, 3, 63, '2013-01-11 10:00:00.000', '2013-01-11 11:00:00.000', N'sistemazione br222 sx deckel', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (334, 7, 64, '2013-02-01 08:00:00.000', '2013-02-01 11:00:00.000', N'br222 sx 2d', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (335, 3, 65, '2013-01-11 08:00:00.000', '2013-01-11 09:00:00.000', N'sistemazione coltello ford cd4 sx', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (336, 3, 65, '2013-01-30 08:00:00.000', '2013-01-30 10:00:00.000', N'modifica br 222 sx sede', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (337, 7, 65, '2013-01-07 08:00:00.000', '2013-01-07 12:00:00.000', N'modifiche gm epsilon', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (338, 7, 65, '2013-01-11 08:00:00.000', '2013-01-11 13:00:00.000', N'modifica br222', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (339, 7, 65, '2013-01-30 08:00:00.000', '2013-01-30 13:00:00.000', N'modifiche 3d + 2d', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (340, 7, 65, '2013-01-31 08:00:00.000', '2013-01-31 12:00:00.000', N'br222 sx modifiche', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (341, 3, 66, '2013-01-17 08:00:00.000', '2013-01-17 10:00:00.000', N'controllo modifica br222 sx 2 impr.', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (342, 6, 68, '2013-01-31 08:00:00.000', '2013-01-31 17:00:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (343, 6, 68, '2013-02-01 08:00:00.000', '2013-02-01 16:30:00.000', N'', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (344, 3, 76, '2013-01-28 08:00:00.000', '2013-01-28 17:00:00.000', N'SISTEMAZIONE MOV. N°13 HONDA DESTRA', 0.0000)
|
||||
INSERT INTO dbo.RegAttivita
|
||||
(idxRA, idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (345, 3, 76, '2013-01-29 08:00:00.000', '2013-01-29 15:00:00.000', N' MODIFICA HONDA DESTRA', 0.0000)
|
||||
go
|
||||
|
||||
set identity_insert dbo.RegAttivita off
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
UPDATE dbo.Permessi SET
|
||||
NUMERO=4
|
||||
WHERE COD_PERMESSO='ADMIN_dipendenti'
|
||||
UPDATE dbo.Permessi SET
|
||||
NUMERO=5
|
||||
WHERE COD_PERMESSO='ADMIN_orario'
|
||||
INSERT INTO dbo.Permessi
|
||||
VALUES ('ADMIN_spostaFasi', 'spostaFasi.aspx', 1, 3, 'SpostaFasi', 'SpostaFasiExpl')
|
||||
INSERT INTO dbo.Permessi
|
||||
VALUES ('MANAGE_Report', 'reportProgetti.aspx', 2, 4, 'ReportPrj', 'ReportPrjExpl')
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('ADMIN', N'GPW_prjAdm', 'S')
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('ADMIN_clienti', N'GPW_prjAdm', 'S')
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('ADMIN_fasi', N'GPW_prjAdm', 'S')
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('ADMIN_progetti', N'GPW_prjAdm', 'S')
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('ADMIN_spostaFasi', N'GPW_admin', NULL)
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('ADMIN_spostaFasi', N'GPW_prjAdm', NULL)
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('MANAGE', N'GPW_prjAdm', 'S')
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('MANAGE_Report', N'GPW_admin', NULL)
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('MANAGE_Report', N'GPW_prjAdm', NULL)
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
--- forzo ricalcolo attività expl!
|
||||
EXEC stp_ricalcolaRegAttivitaExpl_byPeriodoUser 0, '20120101', '20130204'
|
||||
@@ -0,0 +1,668 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
-- =============================================
|
||||
-- Author: S.E. Locatelli
|
||||
-- Create date: 2013.02.13
|
||||
-- Description: Gestione trigger update attivo x sottofasi
|
||||
-- =============================================
|
||||
create TRIGGER trg_AF_updateAttivoSubFasi
|
||||
ON AnagFasi
|
||||
AFTER UPDATE
|
||||
AS
|
||||
BEGIN
|
||||
IF (@@ROWCOUNT = 0) -- SE NESSUNA RIGA AGGIORNATA O INSERITA ESCO
|
||||
RETURN
|
||||
|
||||
-- SET NOCOUNT ON added to prevent extra result sets from
|
||||
-- interfering with SELECT statements.
|
||||
SET NOCOUNT ON;
|
||||
|
||||
-- CONTROLLO se è stato aggiornato "attivo)
|
||||
IF(UPDATE(Attivo))
|
||||
BEGIN
|
||||
-- lo farò solo sulle sottofasi e x i casi di modifica di fasi "master"...
|
||||
UPDATE AF
|
||||
SET AF.Attivo = i.Attivo
|
||||
FROM AnagFasi AF
|
||||
INNER JOIN inserted i ON AF.idxFaseAncest = i.idxFase
|
||||
INNER JOIN deleted d ON i.idxFase = d.idxFase
|
||||
WHERE i.Attivo <> d.Attivo
|
||||
END
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
alter table AnagProgetti drop
|
||||
column budgetTime,
|
||||
column budgetMoney;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
alter VIEW v_selFasi
|
||||
AS
|
||||
SELECT idxFase AS value, nomeFase AS label, idxProgetto AS conditio, enableTime, codFase, idxFase * enableTime AS valueGroup, Attivo
|
||||
FROM dbo.AnagFasi
|
||||
go
|
||||
|
||||
exec sp_updateextendedproperty 'MS_DiagramPane1', '[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
|
||||
Begin DesignProperties =
|
||||
Begin PaneConfigurations =
|
||||
Begin PaneConfiguration = 0
|
||||
NumPanes = 4
|
||||
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
|
||||
End
|
||||
Begin PaneConfiguration = 1
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 4 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 2
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 2 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 3
|
||||
NumPanes = 3
|
||||
Configuration = "(H (4 [30] 2 [40] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 4
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [56] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 5
|
||||
NumPanes = 2
|
||||
Configuration = "(H (2 [66] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 6
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [50] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 7
|
||||
NumPanes = 1
|
||||
Configuration = "(V (3))"
|
||||
End
|
||||
Begin PaneConfiguration = 8
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1[56] 4[18] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 9
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [75] 4))"
|
||||
End
|
||||
Begin PaneConfiguration = 10
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1[66] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 11
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [60] 2))"
|
||||
End
|
||||
Begin PaneConfiguration = 12
|
||||
NumPanes = 1
|
||||
Configuration = "(H (1) )"
|
||||
End
|
||||
Begin PaneConfiguration = 13
|
||||
NumPanes = 1
|
||||
Configuration = "(V (4))"
|
||||
End
|
||||
Begin PaneConfiguration = 14
|
||||
NumPanes = 1
|
||||
Configuration = "(V (2))"
|
||||
End
|
||||
ActivePaneConfig = 0
|
||||
End
|
||||
Begin DiagramPane =
|
||||
Begin Origin =
|
||||
Top = 0
|
||||
Left = 0
|
||||
End
|
||||
Begin Tables =
|
||||
Begin Table = "AnagFasi"
|
||||
Begin Extent =
|
||||
Top = 6
|
||||
Left = 38
|
||||
Bottom = 284
|
||||
Right = 209
|
||||
End
|
||||
DisplayFlags = 280
|
||||
TopColumn = 1
|
||||
End
|
||||
End
|
||||
End
|
||||
Begin SQLPane =
|
||||
End
|
||||
Begin DataPane =
|
||||
Begin ParameterDefaults = ""
|
||||
End
|
||||
Begin ColumnWidths = 9
|
||||
Width = 284
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 11985
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
End
|
||||
End
|
||||
Begin CriteriaPane =
|
||||
Begin ColumnWidths = 11
|
||||
Column = 1440
|
||||
Alias = 900
|
||||
Table = 1170
|
||||
Output = 720
|
||||
Append = 1400
|
||||
NewValue = 1170
|
||||
SortType = 1350
|
||||
SortOrder = 1410
|
||||
GroupBy = 1350
|
||||
Filter = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
End
|
||||
End
|
||||
End
|
||||
', 'SCHEMA', 'dbo', 'VIEW', 'v_selFasi';
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_Expl_getData
|
||||
*
|
||||
* recupera elenco progetti con filtraggio ore totali per
|
||||
* - dipendente
|
||||
* - periodo
|
||||
*
|
||||
* mod: S.E.L. 2013.01.30
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_Expl_getData
|
||||
(
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@dataFrom DATETIME = '19000101',
|
||||
@dataTo DATETIME = '99991231',
|
||||
@idxCliente INT = 0, -- 0 = tutti
|
||||
@showPrjArch BIT = 1 -- 1 = mostra tutti
|
||||
)
|
||||
AS
|
||||
|
||||
-- controllo se date nulle importo a min/max
|
||||
DECLARE @firstDate DATETIME
|
||||
DECLARE @lastDate DATETIME
|
||||
|
||||
SELECT @firstDate = MIN(inizio), @lastDate=DATEADD(DAY,1,MAX(inizio)) FROM RegAttivita
|
||||
SELECT @dataFrom=ISNULL(@dataFrom, @firstDate) , @dataTo=ISNULL(@dataTo, @lastDate)
|
||||
|
||||
|
||||
;WITH cteOreReal AS
|
||||
(
|
||||
SELECT ap.idxProgetto, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagProgetti AS ap INNER JOIN
|
||||
AnagClienti AS ac ON ac.idxCliente=ap.idxCliente INNER JOIN
|
||||
AnagFasi AS af ON ap.idxProgetto = af.idxProgetto INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE (ra.idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND (ra.inizio >= @dataFrom AND ra.inizio <= @dataTo)
|
||||
AND (ac.idxCliente = @idxCliente OR @idxCliente = 0)
|
||||
AND (ap.Attivo = CASE WHEN @showPrjArch <> 0 THEN ap.Attivo ELSE 1 END)
|
||||
GROUP BY ap.idxProgetto
|
||||
)
|
||||
,cteOreBudget as
|
||||
(
|
||||
SELECT
|
||||
idxProgetto
|
||||
,SUM(ISNULL(budgetTime,0)) as budgetTime
|
||||
,SUM(ISNULL(budgetMoney,0)) as budgetMoney
|
||||
FROM AnagFasi
|
||||
GROUP BY idxProgetto
|
||||
)
|
||||
|
||||
SELECT ac.RagSociale
|
||||
, ap.idxProgetto
|
||||
, ap.idxCliente
|
||||
, ap.nomeProj
|
||||
, ap.descrProj
|
||||
, ISNULL(bdgt.budgetTime,0) AS budgetTime
|
||||
, ISNULL(bdgt.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(ap.OldIdx,-1) AS OldIdx
|
||||
, ap.Attivo
|
||||
, ISNULL(ap.codExt,'') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
, ISNULL(ap.avvio,'19000101') AS avvio
|
||||
, ISNULL(ap.chiusura,'99991231') AS chiusura
|
||||
FROM AnagClienti AS ac INNER JOIN
|
||||
AnagProgetti AS ap ON ac.idxCliente = ap.idxCliente LEFT OUTER JOIN
|
||||
cteOreBudget AS bdgt ON ap.idxProgetto = bdgt.idxProgetto LEFT OUTER JOIN
|
||||
cteOreReal AS cte ON cte.idxProgetto = ap.idxProgetto
|
||||
WHERE (ac.idxCliente = @idxCliente OR @idxCliente = 0)
|
||||
AND (ap.Attivo = CASE WHEN @showPrjArch <> 0 THEN ap.Attivo ELSE 1 END)
|
||||
ORDER BY ac.RagSociale, ap.nomeProj
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_getByIdxCli
|
||||
*
|
||||
* recupera elenco progetti da cliente
|
||||
*
|
||||
* mod: S.E.L. 2012.10.26
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_getByIdxCli
|
||||
(
|
||||
@idxCliente INT,
|
||||
@showPrjArch BIT
|
||||
)
|
||||
AS
|
||||
|
||||
;WITH cteOreReal AS
|
||||
(
|
||||
SELECT ap.idxProgetto, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagProgetti AS ap INNER JOIN
|
||||
AnagClienti AS ac ON ac.idxCliente=ap.idxCliente INNER JOIN
|
||||
AnagFasi AS af ON ap.idxProgetto = af.idxProgetto INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE (ac.idxCliente = @idxCliente OR @idxCliente = 0)
|
||||
AND (ap.Attivo = CASE WHEN @showPrjArch <> 0 THEN ap.Attivo ELSE 1 END)
|
||||
GROUP BY ap.idxProgetto
|
||||
)
|
||||
,cteOreBudget as
|
||||
(
|
||||
select
|
||||
idxProgetto
|
||||
,SUM(ISNULL(budgetTime,0)) as budgetTime
|
||||
,SUM(ISNULL(budgetMoney,0)) as budgetMoney
|
||||
from AnagFasi
|
||||
GROUP BY idxProgetto
|
||||
)
|
||||
|
||||
SELECT ac.RagSociale
|
||||
, ap.idxProgetto
|
||||
, ap.idxCliente
|
||||
, ap.nomeProj
|
||||
, ap.descrProj
|
||||
, ISNULL(bdgt.budgetTime,0) AS budgetTime
|
||||
, ISNULL(bdgt.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(ap.OldIdx,-1) AS OldIdx
|
||||
, ap.Attivo
|
||||
, ISNULL(ap.codExt,'') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
, ISNULL(ap.avvio,'19000101') AS avvio
|
||||
, ISNULL(ap.chiusura,'99991231') AS chiusura
|
||||
FROM AnagClienti AS ac INNER JOIN
|
||||
AnagProgetti AS ap ON ac.idxCliente = ap.idxCliente LEFT OUTER JOIN
|
||||
cteOreBudget AS bdgt ON ap.idxProgetto = bdgt.idxProgetto LEFT OUTER JOIN
|
||||
cteOreReal AS cte ON cte.idxProgetto = ap.idxProgetto
|
||||
WHERE (ac.idxCliente = @idxCliente OR @idxCliente = 0)
|
||||
AND (ap.Attivo = CASE WHEN @showPrjArch <> 0 THEN ap.Attivo ELSE 1 END)
|
||||
ORDER BY ac.RagSociale, ap.nomeProj
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_getByIdxPrj
|
||||
*
|
||||
* recupera elenco progetti da idx
|
||||
*
|
||||
* mod: S.E.L. 2012.11.06
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_getByIdxPrj
|
||||
(
|
||||
@idxProgetto INT
|
||||
)
|
||||
AS
|
||||
/*
|
||||
SELECT *
|
||||
FROM AnagProgetti
|
||||
WHERE idxProgetto = @idxProgetto
|
||||
ORDER BY nomeProj
|
||||
*/
|
||||
|
||||
;WITH cteOreReal AS
|
||||
(
|
||||
SELECT ap.idxProgetto, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagProgetti AS ap INNER JOIN
|
||||
AnagClienti AS ac ON ac.idxCliente=ap.idxCliente INNER JOIN
|
||||
AnagFasi AS af ON ap.idxProgetto = af.idxProgetto INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE ap.idxProgetto = @idxProgetto
|
||||
GROUP BY ap.idxProgetto
|
||||
)
|
||||
,cteOreBudget as
|
||||
(
|
||||
select
|
||||
idxProgetto
|
||||
,SUM(ISNULL(budgetTime,0)) as budgetTime
|
||||
,SUM(ISNULL(budgetMoney,0)) as budgetMoney
|
||||
from AnagFasi
|
||||
GROUP BY idxProgetto
|
||||
)
|
||||
|
||||
SELECT ac.RagSociale
|
||||
, ap.idxProgetto
|
||||
, ap.idxCliente
|
||||
, ap.nomeProj
|
||||
, ap.descrProj
|
||||
, ISNULL(bdgt.budgetTime,0) AS budgetTime
|
||||
, ISNULL(bdgt.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(ap.OldIdx,-1) AS OldIdx
|
||||
, ap.Attivo
|
||||
, ISNULL(ap.codExt,'') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
, ISNULL(ap.avvio,'19000101') AS avvio
|
||||
, ISNULL(ap.chiusura,'99991231') AS chiusura
|
||||
FROM AnagClienti AS ac INNER JOIN
|
||||
AnagProgetti AS ap ON ac.idxCliente = ap.idxCliente LEFT OUTER JOIN
|
||||
cteOreBudget AS bdgt ON ap.idxProgetto = bdgt.idxProgetto LEFT OUTER JOIN
|
||||
cteOreReal AS cte ON cte.idxProgetto = ap.idxProgetto
|
||||
WHERE ap.idxProgetto = @idxProgetto
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_insertQuery
|
||||
*
|
||||
* inserisce un progetto in anagrafica
|
||||
*
|
||||
* mod: S.E.L. 2013.01.30
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_insertQuery
|
||||
(
|
||||
@idxCliente int,
|
||||
@nomeProj nvarchar(50),
|
||||
@descrProj nvarchar(250)
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
DECLARE @avvio DATETIME = '19000101'
|
||||
DECLARE @chiusura DATETIME = '99991231'
|
||||
INSERT INTO AnagProgetti
|
||||
(idxCliente, nomeProj, descrProj, Attivo, avvio, chiusura)
|
||||
VALUES (@idxCliente,@nomeProj,@descrProj, 1, @avvio, @chiusura);
|
||||
/*
|
||||
DECLARE @idxPrj INT
|
||||
SELECT @idxPrj = SCOPE_IDENTITY()
|
||||
EXEC stp_AP_getByIdxPrj @idxPrj
|
||||
*/
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_update
|
||||
*
|
||||
* elimina un progetto da anagrafica
|
||||
*
|
||||
* mod: S.E.L. 2013.01.30
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_update
|
||||
(
|
||||
@idxCliente INT,
|
||||
@nomeProj NVARCHAR(50),
|
||||
@descrProj NVARCHAR(250),
|
||||
--@avvio DATETIME = '19000101',
|
||||
--@chiusura DATETIME = '99991231',
|
||||
@Original_idxProgetto INT
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
UPDATE dbo.AnagProgetti
|
||||
SET idxCliente = @idxCliente
|
||||
,nomeProj = @nomeProj
|
||||
,descrProj = @descrProj
|
||||
--,avvio = @avvio,
|
||||
--,chiusura = @chiusura
|
||||
WHERE idxProgetto = @Original_idxProgetto;
|
||||
|
||||
/*
|
||||
EXEC stp_AP_getByIdxPrj @Original_idxProgetto
|
||||
*/
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_updateAttivo
|
||||
*
|
||||
* elimina un progetto da anagrafica
|
||||
*
|
||||
* mod: S.E.L. 2012.11.06
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_updateAttivo
|
||||
(
|
||||
@Attivo BIT,
|
||||
@Original_idxProgetto INT
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
UPDATE dbo.AnagProgetti
|
||||
SET Attivo = @Attivo
|
||||
WHERE idxProgetto = @Original_idxProgetto;
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RAD_Expl_getByIdxDipPeriodo
|
||||
*
|
||||
* recupera elenco attività (con Expl dei dati da anagrafica) da idxDipendente + periodo + opzionali cliente e progetto
|
||||
*
|
||||
* mod: S.E.L. 2013.02.01
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RAD_Expl_getByIdxDipPeriodo
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataFrom DATETIME,
|
||||
@dataTo DATETIME,
|
||||
@idxCliente INT = 0, -- 0 = tutti
|
||||
@idxProgetto INT = 0, -- 0 = tutti
|
||||
@idxFase INT = 0, -- 0 = tutti
|
||||
@soloAncest BIT = 0 -- 0 = tutti
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT d.Cognome + ' ' + d.Nome AS CognomeNome, ra.idxDipendente, ra.inizio, ra.fine
|
||||
, CASE WHEN ISNULL(descrizione, '') = '' THEN '-' ELSE ISNULL(descrizione, '') END AS descrizione
|
||||
, ra.oreTot, ra.oreTot * 60 AS minTot, ra.importo, ac.RagSociale, ap.nomeProj,
|
||||
af.nomeFase, ra.idxRA
|
||||
FROM RegAttivita ra INNER JOIN
|
||||
AnagFasi af ON ra.idxFase = af.idxFase INNER JOIN
|
||||
AnagProgetti ap ON af.idxProgetto = ap.idxProgetto INNER JOIN
|
||||
AnagClienti ac ON ap.idxCliente = ac.idxCliente INNER JOIN
|
||||
Dipendenti d ON ra.idxDipendente = d.idxDipendente
|
||||
WHERE (ra.idxDipendente = @idxDipendente OR @idxDipendente=0)
|
||||
AND (ra.inizio >= CAST(@dataFrom AS DATE) AND ra.inizio <= CAST(@dataTo AS DATE))
|
||||
AND (ac.idxCliente = @idxCliente OR @idxCliente <= 0)
|
||||
AND (ap.idxProgetto = @idxProgetto OR @idxProgetto <= 0)
|
||||
AND (af.idxFase = @idxFase OR @idxFase <= 0)
|
||||
AND (af.idxFaseAncest = CASE WHEN @soloAncest <> 0 THEN 0 ELSE af.idxFaseAncest END )
|
||||
ORDER BY ra.inizio
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_clonaLastRA_Utente
|
||||
*
|
||||
* clona un attività utente: se c'è da ultima altrimenti da zero x una certa data
|
||||
*
|
||||
* mod: S.E.L. 2013.01.17
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RA_clonaLastRA_Utente
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME -- data x cui creare un record attività
|
||||
)
|
||||
AS
|
||||
|
||||
-- variabili
|
||||
DECLARE @idxFase INT
|
||||
DECLARE @idxRA INT
|
||||
|
||||
-- arrotondo data richiesta solo all'ora...
|
||||
SELECT @dataRif = DATEADD(HOUR, DATEPART(HOUR,@dataRif), CONVERT(DATETIME,(CONVERT(DATE,@dataRif))))
|
||||
|
||||
-- cerco se esista ultima reg attività utente...
|
||||
SELECT @idxRA=ISNULL((SELECT TOP 1 idxRA FROM RegAttivita WHERE idxDipendente = @idxDipendente ORDER BY inizio DESC),0)
|
||||
|
||||
-- se non ho trovato records, ovvero idxRA = 0, prendo ultima fase da elenco
|
||||
IF (@idxRA = 0)
|
||||
BEGIN
|
||||
-- calcolo ultima fase inserita...
|
||||
SELECT TOP 1 @idxFase=ISNULL(idxFase,0) FROM AnagFasi ORDER BY idxFase DESC
|
||||
-- se trovata fase inserisco!
|
||||
IF(@idxFase > 0)
|
||||
BEGIN
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (@idxDipendente, @idxFase, @dataRif, DATEADD(HOUR,1,@dataRif), '...',0)
|
||||
END
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
-- inserisco su data richeista duplicazione dell'ultima attività utente...
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
SELECT idxDipendente, idxFase, @dataRif, DATEADD(minute, DATEDIFF(MINUTE, inizio, fine), @dataRif), descrizione, importo
|
||||
FROM RegAttivita
|
||||
WHERE (idxRA = @idxRA)
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_statsProj
|
||||
*
|
||||
* calcolo statistiche progetto
|
||||
*
|
||||
* mod: S.E.L. 2012.10.31
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_statsProj
|
||||
(
|
||||
@idxProgetto int
|
||||
)
|
||||
AS
|
||||
|
||||
DECLARE @oreBudget DECIMAL(19,4), @oreMese DECIMAL(19,4), @oreMesePrec DECIMAL(19,4), @oreTot DECIMAL(19,4);
|
||||
DECLARE @adesso DATETIME, @inizio DATETIME, @fine DATETIME;
|
||||
|
||||
SET @adesso = ( SELECT GETDATE() )
|
||||
|
||||
SET @oreBudget = (
|
||||
SELECT SUM(ISNULL(budgetTime, 0))
|
||||
FROM AnagFasi
|
||||
WHERE idxProgetto = @idxProgetto
|
||||
GROUP BY idxProgetto
|
||||
)
|
||||
SET @oreTot = (
|
||||
SELECT ISNULL(SUM(ISNULL(ra.oreTot,0)),0) AS erogate
|
||||
FROM AnagFasi af INNER JOIN RegAttivita ra ON af.idxFase = ra.idxFase
|
||||
WHERE af.idxProgetto = @idxProgetto
|
||||
GROUP BY af.idxProgetto
|
||||
)
|
||||
|
||||
SET @inizio = ( SELECT dbo.Date(YEAR(@adesso), MONTH(@adesso), 1) )
|
||||
SET @fine = ( SELECT dbo.Date(YEAR(@adesso), MONTH(@adesso)+1, 1) )
|
||||
|
||||
SET @oreMese = (
|
||||
SELECT ISNULL(SUM(ISNULL(ra.oreTot,0)),0) AS erogate
|
||||
FROM AnagFasi af INNER JOIN RegAttivita ra ON af.idxFase = ra.idxFase
|
||||
WHERE af.idxProgetto = @idxProgetto
|
||||
AND ra.inizio BETWEEN @inizio AND @fine
|
||||
)
|
||||
|
||||
SET @inizio = ( SELECT dbo.Date(YEAR(@adesso), MONTH(@adesso)-1, 1) )
|
||||
SET @fine = ( SELECT dbo.Date(YEAR(@adesso), MONTH(@adesso), 1) )
|
||||
|
||||
SET @oreMesePrec = (
|
||||
SELECT ISNULL(SUM(ISNULL(ra.oreTot,0)),0) AS erogate
|
||||
FROM AnagFasi af INNER JOIN RegAttivita ra ON af.idxFase = ra.idxFase
|
||||
WHERE af.idxProgetto = @idxProgetto
|
||||
AND ra.inizio BETWEEN @inizio AND @fine
|
||||
)
|
||||
SELECT @oreBudget AS oreBudget, @oreTot AS oreTot, @oreMese AS oreMese, @oreMesePrec AS oreMesePrec, Attivo
|
||||
FROM AnagProgetti
|
||||
WHERE idxProgetto = @idxProgetto
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
/*************************************
|
||||
* STORED PROCEDURE stp_VSFasiOpt_ByPrj
|
||||
*
|
||||
* elenco fasi dato progetto con calmpo valore a zero se fase "ancestor"
|
||||
*
|
||||
* mod : 2013.02.01
|
||||
* aut : S.E. Locatelli
|
||||
**************************************/
|
||||
alter PROCEDURE stp_VSFasiOpt_ByPrj
|
||||
(
|
||||
@conditio INT = 0
|
||||
,@soloAttivi BIT = 0 -- 0 = tutti, 1 = solo attivi x time tracking
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT value as valueGroup, label, conditio, valueGroup as value
|
||||
FROM v_selFasi
|
||||
WHERE conditio = @conditio
|
||||
AND (enableTime = @soloAttivi OR @soloAttivi = 0)
|
||||
AND Attivo = 1
|
||||
ORDER BY codFase, label
|
||||
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(303, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,311 @@
|
||||
alter table AnagClienti add
|
||||
constraint DF_AnagClienti_codExt default ('n.d.') for codExt,
|
||||
constraint DF_AnagClienti_Attivo default ((1)) for Attivo,
|
||||
constraint DF_AnagClienti_OldIdx default ((-1)) for OldIdx;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
alter VIEW v_logCommUt
|
||||
AS
|
||||
SELECT dataLav AS Data, idxDipendente, CognomeNome, h_lav, 0.00 AS h_com, isOk AS okTimbr, isOk AS okLavCom, '---' AS progetto, minOrd, minStra, minPerm,
|
||||
minFer, minMal, minFest
|
||||
FROM dbo.TimbratureExpl
|
||||
go
|
||||
|
||||
exec sp_updateextendedproperty 'MS_DiagramPane1', '[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
|
||||
Begin DesignProperties =
|
||||
Begin PaneConfigurations =
|
||||
Begin PaneConfiguration = 0
|
||||
NumPanes = 4
|
||||
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
|
||||
End
|
||||
Begin PaneConfiguration = 1
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 4 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 2
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 2 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 3
|
||||
NumPanes = 3
|
||||
Configuration = "(H (4 [30] 2 [40] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 4
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [56] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 5
|
||||
NumPanes = 2
|
||||
Configuration = "(H (2 [66] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 6
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [50] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 7
|
||||
NumPanes = 1
|
||||
Configuration = "(V (3))"
|
||||
End
|
||||
Begin PaneConfiguration = 8
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1[56] 4[18] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 9
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [75] 4))"
|
||||
End
|
||||
Begin PaneConfiguration = 10
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1[66] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 11
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [60] 2))"
|
||||
End
|
||||
Begin PaneConfiguration = 12
|
||||
NumPanes = 1
|
||||
Configuration = "(H (1) )"
|
||||
End
|
||||
Begin PaneConfiguration = 13
|
||||
NumPanes = 1
|
||||
Configuration = "(V (4))"
|
||||
End
|
||||
Begin PaneConfiguration = 14
|
||||
NumPanes = 1
|
||||
Configuration = "(V (2))"
|
||||
End
|
||||
ActivePaneConfig = 0
|
||||
End
|
||||
Begin DiagramPane =
|
||||
Begin Origin =
|
||||
Top = 0
|
||||
Left = 0
|
||||
End
|
||||
Begin Tables =
|
||||
Begin Table = "TimbratureExpl"
|
||||
Begin Extent =
|
||||
Top = 6
|
||||
Left = 38
|
||||
Bottom = 357
|
||||
Right = 213
|
||||
End
|
||||
DisplayFlags = 280
|
||||
TopColumn = 9
|
||||
End
|
||||
End
|
||||
End
|
||||
Begin SQLPane =
|
||||
End
|
||||
Begin DataPane =
|
||||
Begin ParameterDefaults = ""
|
||||
End
|
||||
Begin ColumnWidths = 13
|
||||
Width = 284
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
End
|
||||
End
|
||||
Begin CriteriaPane =
|
||||
Begin ColumnWidths = 11
|
||||
Column = 1440
|
||||
Alias = 900
|
||||
Table = 1170
|
||||
Output = 720
|
||||
Append = 1400
|
||||
NewValue = 1170
|
||||
SortType = 1350
|
||||
SortOrder = 1410
|
||||
GroupBy = 1350
|
||||
Filter = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
End
|
||||
End
|
||||
End
|
||||
', 'SCHEMA', 'dbo', 'VIEW', 'v_logCommUt';
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AC_insert
|
||||
*
|
||||
* crea un cliente in anagrafica
|
||||
*
|
||||
* mod: S.E.L. 2013.02.26
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_AC_insert
|
||||
(
|
||||
@RagSociale NVARCHAR(50),
|
||||
@indirizzo NVARCHAR(50),
|
||||
@CAP NVARCHAR(5),
|
||||
@citta NVARCHAR(50),
|
||||
@prov NVARCHAR(50),
|
||||
@tel NVARCHAR(50),
|
||||
@email NVARCHAR(50),
|
||||
@pIva NVARCHAR(20),
|
||||
@CF NVARCHAR(20),
|
||||
@nota NVARCHAR(500)
|
||||
)
|
||||
AS
|
||||
|
||||
SET NOCOUNT OFF;
|
||||
INSERT INTO AnagClienti(RagSociale, indirizzo, CAP, citta, prov, tel, email, pIva, CF, nota)
|
||||
VALUES (@RagSociale, @indirizzo, @CAP, @citta, @prov, @tel, @email, @pIva, @CF, @nota)
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_freqProjByDipPeriodo
|
||||
*
|
||||
* elenco dei progetti/fasi per dipendente/periodo
|
||||
*
|
||||
* mod: S.E.L. 2013.02.20
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_freqProjByDipPeriodo
|
||||
(
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME,
|
||||
@maxRes INT = 999 -- num max risultati desiderati
|
||||
)
|
||||
AS
|
||||
|
||||
-- calcolo il totale dei risultati per prima cosa...
|
||||
DECLARE @totNum AS INT = 1
|
||||
|
||||
DECLARE @tabFreq AS TABLE
|
||||
(
|
||||
nomeProj NVARCHAR(250)
|
||||
,nomeFase NVARCHAR(250)
|
||||
,qty DECIMAL(9,3)
|
||||
,idxFase INT
|
||||
)
|
||||
|
||||
INSERT @tabFreq
|
||||
SELECT TOP (@maxRes) nomeProj, nomeFase ,SUM(ra.oreTot) as qty, ra.idxFase
|
||||
FROM RegAttivita ra INNER JOIN AnagFasi af ON ra.idxFase=af.idxFase
|
||||
INNER JOIN AnagProgetti ap ON af.idxProgetto=ap.idxProgetto
|
||||
WHERE ra.inizio BETWEEN @inizio AND @fine
|
||||
AND (ra.idxDipendente = @idxDipendente OR @idxDipendente = 0 )
|
||||
GROUP BY nomeProj, nomeFase, ra.idxFase
|
||||
ORDER BY qty DESC
|
||||
|
||||
-- calcolo il totale
|
||||
SELECT @totNum = ISNULL(SUM(qty),1) FROM @tabFreq
|
||||
|
||||
-- restituisco tab con calcolo freq reale
|
||||
SELECT idxFase, nomeProj, nomeFase, qty/@totNum as freq, qty, @totNum AS tot
|
||||
FROM @tabFreq
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_clonaLastRA_byFaseUtente
|
||||
*
|
||||
* clona un attività utente: ultima di un dato tipo di fase
|
||||
*
|
||||
* mod: S.E.L. 2013.02.20
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_RA_clonaLastRA_byFaseUtente
|
||||
(
|
||||
@idxDipendente INT
|
||||
,@dataRif DATETIME -- data x cui creare un record attività
|
||||
,@idxFase INT
|
||||
)
|
||||
AS
|
||||
|
||||
-- variabili
|
||||
DECLARE @idxRA INT
|
||||
|
||||
DECLARE @round AS INT
|
||||
SET @round = ( SELECT valInt FROM AnagKeyValue WHERE nomeVar = 'minutiRoundDay' )
|
||||
|
||||
-- arrotondo data richiesta...
|
||||
SELECT @dataRif = DATEADD(n, (ROUND(dbo.TimeSpanUnits('m', dbo.TimeOnly(DATEADD(n,-1,@dataRif))) / @round, 2) + 1) * @round , CAST(CAST(@dataRif AS DATE) AS DATETIME))
|
||||
|
||||
-- controlla che x la data richiesta non ci siano già altre attività, in quel caso "accoda"...
|
||||
DECLARE @trovate INT = 0
|
||||
SELECT @trovate = COUNT(idxRA) FROM RegAttivita WHERE idxDipendente = @idxDipendente AND CAST(@dataRif AS DATE) = CAST(inizio AS DATE)
|
||||
|
||||
IF @trovate > 0
|
||||
BEGIN
|
||||
-- imposto @dataRif per iniziare alla fine dell'ultimo record
|
||||
SELECT TOP 1 @dataRif=fine FROM RegAttivita WHERE idxDipendente = @idxDipendente AND CAST(@dataRif AS DATE) = CAST(inizio AS DATE) ORDER BY fine DESC
|
||||
END
|
||||
|
||||
-- cerco ultima reg attività utente x fase indicata...
|
||||
SELECT @idxRA=ISNULL((SELECT TOP 1 idxRA FROM RegAttivita WHERE idxDipendente = @idxDipendente AND idxFase = @idxFase ORDER BY inizio DESC),0)
|
||||
|
||||
-- inserisco su data richeista duplicazione dell'ultima attività utente...
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
SELECT idxDipendente, idxFase, @dataRif, DATEADD(minute, DATEDIFF(MINUTE, inizio, fine), @dataRif), descrizione, importo
|
||||
FROM RegAttivita
|
||||
WHERE (idxRA = @idxRA)
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(304, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,291 @@
|
||||
create table ElencoReport(
|
||||
IdxRep int not null identity constraint PK_ElencoReport primary key,
|
||||
ReportName nvarchar(50),
|
||||
ReportUrl nvarchar(500),
|
||||
imgUrl nvarchar(50)
|
||||
);
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
set identity_insert dbo.ElencoReport on
|
||||
go
|
||||
|
||||
INSERT INTO dbo.ElencoReport
|
||||
(IdxRep, ReportName, ReportUrl, imgUrl)
|
||||
VALUES (1, N'Report Ore: Cliente - Progetto - Utente', N'GPW+-+Report+Presenze%2fGPW+-+Ore+per+Cliente-Progetto-Utente', NULL)
|
||||
INSERT INTO dbo.ElencoReport
|
||||
(IdxRep, ReportName, ReportUrl, imgUrl)
|
||||
VALUES (2, N'Report Completo: Elenco Ore Attivita Progetti', N'GPW+-+Report+Presenze%2fGPW+-+Elenco+Ore+Attivita+Progetti', NULL)
|
||||
go
|
||||
|
||||
set identity_insert dbo.ElencoReport off
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_ReportOreDip
|
||||
*
|
||||
* elenco ore dipendenti
|
||||
*
|
||||
* mod: S.E.L. 2013.02.04
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE export.stp_ReportOreDip
|
||||
(
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@dataFrom DATETIME,
|
||||
@dataTo DATETIME
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
DECLARE @minArr INT
|
||||
|
||||
SELECT @minArr = ISNULL(valInt,1) FROM AnagKeyValue WHERE nomeVar = 'minutiRoundDay'
|
||||
|
||||
-- elenco mensile...
|
||||
SELECT dataLav, CognomeNome,
|
||||
entrata_1, uscita_1, entrata_2, uscita_2,
|
||||
entrata_3, uscita_3, entrata_4, uscita_4,
|
||||
FLOOR(CAST(h_lav AS DECIMAL(9,3))*60/@minArr)/(60/@minArr) AS h_lavorate,
|
||||
FLOOR(CAST(minStra AS DECIMAL(9,3))/@minArr)/(60/@minArr) AS h_straordinarie,
|
||||
CEILING(CAST(minPerm AS DECIMAL(9,3))/@minArr)/(60/@minArr) AS h_permessi,
|
||||
CEILING(CAST(minFer AS DECIMAL(9,3))/@minArr)/(60/@minArr) AS h_ferie,
|
||||
CEILING(CAST(minMal AS DECIMAL(9,3))/@minArr)/(60/@minArr) AS h_malattia,
|
||||
CEILING(CAST(minFest AS DECIMAL(9,3))/@minArr)/(60/@minArr) AS h_festivita
|
||||
FROM TimbratureExpl
|
||||
WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND dataLav >= CAST(@dataFrom AS DATE)
|
||||
AND dataLav <= CAST(@dataTo AS DATE)
|
||||
--AND NOT (entrata_1 IS NULL)
|
||||
ORDER BY CognomeNome, dataLav
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AP_Expl_getData
|
||||
*
|
||||
* recupera elenco progetti con filtraggio ore totali per
|
||||
* - dipendente
|
||||
* - periodo
|
||||
*
|
||||
* mod: S.E.L. 2013.01.30
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AP_Expl_getData
|
||||
(
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@dataFrom DATETIME = '19000101',
|
||||
@dataTo DATETIME = '99991231',
|
||||
@idxCliente INT = 0, -- 0 = tutti
|
||||
@showPrjArch BIT = 1, -- 1 = mostra tutti, 0 = nasconde archiviati
|
||||
@showPrjZeroH BIT = 1 -- 1 = mostra tutti, 0 = nasconde se zero ore caricate
|
||||
)
|
||||
AS
|
||||
|
||||
-- controllo se date nulle importo a min/max
|
||||
DECLARE @firstDate DATETIME
|
||||
DECLARE @lastDate DATETIME
|
||||
|
||||
SELECT @firstDate = MIN(inizio), @lastDate=DATEADD(DAY,1,MAX(inizio)) FROM RegAttivita
|
||||
SELECT @dataFrom=ISNULL(@dataFrom, @firstDate) , @dataTo=ISNULL(@dataTo, @lastDate)
|
||||
|
||||
|
||||
;WITH cteOreReal AS
|
||||
(
|
||||
SELECT ap.idxProgetto, SUM(ISNULL(ra.oreTot, 0)) AS totOre
|
||||
FROM AnagProgetti AS ap INNER JOIN
|
||||
AnagClienti AS ac ON ac.idxCliente=ap.idxCliente INNER JOIN
|
||||
AnagFasi AS af ON ap.idxProgetto = af.idxProgetto INNER JOIN
|
||||
RegAttivita AS ra ON af.idxFase = ra.idxFase
|
||||
WHERE (ra.idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND (ra.inizio >= @dataFrom AND ra.inizio <= @dataTo)
|
||||
AND (ac.idxCliente = @idxCliente OR @idxCliente = 0)
|
||||
AND (ap.Attivo = CASE WHEN @showPrjArch <> 0 THEN ap.Attivo ELSE 1 END)
|
||||
GROUP BY ap.idxProgetto
|
||||
)
|
||||
,cteOreBudget as
|
||||
(
|
||||
SELECT
|
||||
idxProgetto
|
||||
,SUM(ISNULL(budgetTime,0)) as budgetTime
|
||||
,SUM(ISNULL(budgetMoney,0)) as budgetMoney
|
||||
FROM AnagFasi
|
||||
GROUP BY idxProgetto
|
||||
)
|
||||
|
||||
SELECT ac.RagSociale
|
||||
, ap.idxProgetto
|
||||
, ap.idxCliente
|
||||
, ap.nomeProj
|
||||
, ap.descrProj
|
||||
, ISNULL(bdgt.budgetTime,0) AS budgetTime
|
||||
, ISNULL(bdgt.budgetMoney,0) AS budgetMoney
|
||||
, ISNULL(ap.OldIdx,-1) AS OldIdx
|
||||
, ap.Attivo
|
||||
, ISNULL(ap.codExt,'') AS codExt
|
||||
, ISNULL(cte.totOre, 0) AS totOre
|
||||
, ISNULL(ap.avvio,'19000101') AS avvio
|
||||
, ISNULL(ap.chiusura,'99991231') AS chiusura
|
||||
FROM AnagClienti AS ac INNER JOIN
|
||||
AnagProgetti AS ap ON ac.idxCliente = ap.idxCliente LEFT OUTER JOIN
|
||||
cteOreBudget AS bdgt ON ap.idxProgetto = bdgt.idxProgetto LEFT OUTER JOIN
|
||||
cteOreReal AS cte ON cte.idxProgetto = ap.idxProgetto
|
||||
WHERE (ac.idxCliente = @idxCliente OR @idxCliente = 0)
|
||||
AND (ap.Attivo = CASE WHEN @showPrjArch <> 0 THEN ap.Attivo ELSE 1 END)
|
||||
AND (totOre > 0 OR @showPrjZeroH = 1)
|
||||
ORDER BY ac.RagSociale, ap.nomeProj
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_clonaLastRA_byFaseUtente
|
||||
*
|
||||
* clona un attività utente: ultima di un dato tipo di fase
|
||||
*
|
||||
* mod: S.E.L. 2013.02.20
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RA_clonaLastRA_byFaseUtente
|
||||
(
|
||||
@idxDipendente INT
|
||||
,@dataRif DATETIME -- data x cui creare un record attività
|
||||
,@idxFase INT
|
||||
,@minuti INT = 0 -- se 0 fa last value
|
||||
)
|
||||
AS
|
||||
|
||||
-- variabili
|
||||
DECLARE @idxRA INT
|
||||
DECLARE @inizio DATETIME
|
||||
|
||||
-- calcolo fine ultima attività del giorno x l'utente (se c'è...)
|
||||
SELECT TOP 1 @inizio = ISNULL(fine, @dataRif)
|
||||
FROM RegAttivita
|
||||
WHERE idxDipendente = @idxDipendente
|
||||
AND CONVERT(DATE,fine) = @dataRif
|
||||
ORDER BY fine DESC
|
||||
|
||||
|
||||
DECLARE @round AS INT
|
||||
SET @round = ( SELECT valInt FROM AnagKeyValue WHERE nomeVar = 'minutiRoundDay' )
|
||||
|
||||
-- arrotondo data richiesta...
|
||||
SELECT @dataRif = DATEADD(n, (ROUND(dbo.TimeSpanUnits('m', dbo.TimeOnly(DATEADD(n,-1,@dataRif))) / @round, 2) + 1) * @round , CAST(CAST(@dataRif AS DATE) AS DATETIME))
|
||||
|
||||
-- controlla che x la data richiesta non ci siano già altre attività, in quel caso "accoda"...
|
||||
DECLARE @trovate INT = 0
|
||||
SELECT @trovate = COUNT(idxRA) FROM RegAttivita WHERE idxDipendente = @idxDipendente AND CAST(@dataRif AS DATE) = CAST(inizio AS DATE)
|
||||
|
||||
IF @trovate > 0
|
||||
BEGIN
|
||||
-- imposto @dataRif per iniziare alla fine dell'ultimo record
|
||||
SELECT TOP 1 @dataRif=fine FROM RegAttivita WHERE idxDipendente = @idxDipendente AND CAST(@dataRif AS DATE) = CAST(inizio AS DATE) ORDER BY fine DESC
|
||||
END
|
||||
|
||||
-- cerco ultima reg attività utente x fase indicata...
|
||||
SELECT @idxRA=ISNULL((SELECT TOP 1 idxRA FROM RegAttivita WHERE idxDipendente = @idxDipendente AND idxFase = @idxFase ORDER BY inizio DESC),0)
|
||||
|
||||
-- inserisco su data richeista duplicazione dell'ultima attività utente...
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
SELECT idxDipendente, idxFase, @dataRif, DATEADD(minute, CASE WHEN @minuti = 0 THEN DATEDIFF(MINUTE, inizio, fine) ELSE @minuti END, @dataRif), descrizione, importo
|
||||
FROM RegAttivita
|
||||
WHERE (idxRA = @idxRA)
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* FUNCTION f_dataOraITA
|
||||
*
|
||||
* formatta data ora in modo che sia compatibilit con excel ITA
|
||||
*
|
||||
**********************************************************/
|
||||
create FUNCTION f_dataOraITA
|
||||
(
|
||||
@valore DATETIME
|
||||
)
|
||||
RETURNS NVARCHAR(50)
|
||||
AS
|
||||
BEGIN
|
||||
RETURN CONVERT(NVARCHAR(50), @valore, 120)
|
||||
END
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* FUNCTION f_floatITA
|
||||
*
|
||||
* formatta data ora in modo che sia compatibilita con excel ITA
|
||||
*
|
||||
**********************************************************/
|
||||
create FUNCTION f_floatITA
|
||||
(
|
||||
@valore FLOAT
|
||||
)
|
||||
RETURNS NVARCHAR(50)
|
||||
AS
|
||||
BEGIN
|
||||
RETURN REPLACE(CONVERT(NVARCHAR(50), @valore),'.',',')
|
||||
END
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(306, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,118 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
exec sp_rename 'PK_ElencoReport', 'tmp__PK_ElencoReport', 'OBJECT';
|
||||
go
|
||||
|
||||
exec sp_rename 'ElencoReport', 'tmp__ElencoReport_0', 'OBJECT';
|
||||
go
|
||||
|
||||
create table ElencoReport(
|
||||
IdxRep int not null identity constraint PK_ElencoReport primary key,
|
||||
nome nvarchar(50),
|
||||
descrizione nvarchar(250),
|
||||
cssClass nvarchar(250),
|
||||
ReportUrl nvarchar(500)
|
||||
);
|
||||
go
|
||||
|
||||
set identity_insert ElencoReport on;
|
||||
go
|
||||
|
||||
insert into ElencoReport(IdxRep,ReportUrl) select IdxRep,ReportUrl from tmp__ElencoReport_0;
|
||||
go
|
||||
|
||||
set identity_insert ElencoReport off;
|
||||
go
|
||||
|
||||
drop table tmp__ElencoReport_0;
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
UPDATE dbo.ElencoReport SET
|
||||
nome=N'Report Ore', descrizione=N'Report ore raggruppato per Cliente > Progetto > Utente', cssClass=N'reportOre'
|
||||
WHERE IdxRep=1
|
||||
UPDATE dbo.ElencoReport SET
|
||||
nome=N'Report Completo', descrizione=N' Elenco Ore Attivita Progetti (eg: valido per pivot excel)', cssClass=N'reportPivot'
|
||||
WHERE IdxRep=2
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
UPDATE dbo.Permessi SET
|
||||
NUMERO=5
|
||||
WHERE COD_PERMESSO='MANAGE_Report'
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('ADMIN', N'GPW_user', 'N')
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('ADMIN_fasi', N'GPW_user', 'N')
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('ADMIN_progetti', N'GPW_user', 'N')
|
||||
UPDATE dbo.Permessi2Funzione SET
|
||||
READWRITE='S'
|
||||
WHERE COD_PERMESSO='ADMIN_spostaFasi' and COD_FUNZIONE=N'GPW_admin'
|
||||
UPDATE dbo.Permessi2Funzione SET
|
||||
READWRITE='S'
|
||||
WHERE COD_PERMESSO='ADMIN_spostaFasi' and COD_FUNZIONE=N'GPW_prjAdm'
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('MANAGE', N'GPW_user', 'N')
|
||||
UPDATE dbo.Permessi2Funzione SET
|
||||
READWRITE='S'
|
||||
WHERE COD_PERMESSO='MANAGE_Report' and COD_FUNZIONE=N'GPW_admin'
|
||||
UPDATE dbo.Permessi2Funzione SET
|
||||
READWRITE='S'
|
||||
WHERE COD_PERMESSO='MANAGE_Report' and COD_FUNZIONE=N'GPW_prjAdm'
|
||||
INSERT INTO dbo.Permessi2Funzione
|
||||
VALUES ('MANAGE_Report', N'GPW_user', 'N')
|
||||
UPDATE dbo.Permessi2Funzione SET
|
||||
READWRITE='S'
|
||||
WHERE COD_PERMESSO='MANAGE_SpostOre' and COD_FUNZIONE=N'GPW_admin'
|
||||
UPDATE dbo.Permessi2Funzione SET
|
||||
READWRITE='S'
|
||||
WHERE COD_PERMESSO='MANAGE_SpostOre' and COD_FUNZIONE=N'GPW_prjAdm'
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(308, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,93 @@
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
create FUNCTION f_expDataGGMMAAAA( @Data AS DATE )
|
||||
-- ritorna la DATA per file di export x paghe formato carattere
|
||||
RETURNS CHAR(8)
|
||||
AS
|
||||
BEGIN
|
||||
RETURN REPLACE( CONVERT(NVARCHAR(50), @Data , 105), '-','')
|
||||
END
|
||||
go
|
||||
|
||||
create FUNCTION f_expTimeHHMM( @Time AS DECIMAL(10,5) , @Format CHAR(1), @Arrot AS INT)
|
||||
-- ritorna ore per file di export x paghe formato carattere es . 8 0re 30 minuti -> 0850
|
||||
-- Time valore da convertire
|
||||
-- Format Formato del valore passato ( M-minuti O-Ore )
|
||||
RETURNS CHAR(4)
|
||||
AS
|
||||
BEGIN
|
||||
|
||||
DECLARE @Ore AS INT;
|
||||
DECLARE @Min AS INT;
|
||||
DECLARE @OreMin AS DECIMAL(10,5);
|
||||
|
||||
IF @Format = 'M' -- Minuti
|
||||
BEGIN
|
||||
-- SET @Ore = CONVERT( INTEGER , ( @Time / 60.00 ) );
|
||||
-- SET @Min = @Time - ( @Ore * 60 );
|
||||
|
||||
SET @OreMin = CONVERT(INT, (@Time / @Arrot) )
|
||||
SET @OreMin = ( ( @OreMin * @Arrot ) / 60 ) * 100
|
||||
END
|
||||
|
||||
RETURN dbo.f_padLeft( CONVERT( VARCHAR(4) , CONVERT(INT, @OreMin )) , 4, '0')
|
||||
END
|
||||
go
|
||||
|
||||
/***************************************
|
||||
* FUNCTION f_padLeft
|
||||
*
|
||||
* fornisce una stringa della lunghezza desiderata aggiungendo a sx il carattere richiesto alla @string originale
|
||||
*
|
||||
* Steamware, S.E.L.
|
||||
* mod: 2010.03.19
|
||||
*
|
||||
****************************************/
|
||||
create FUNCTION f_padLeft (@string VARCHAR(255), @desired_length INTEGER, @pad_character CHAR(1))
|
||||
RETURNS VARCHAR(255) AS
|
||||
BEGIN
|
||||
|
||||
-- Prefix the required number of spaces to bulk up the string and then replace the spaces with the desired character
|
||||
RETURN CASE
|
||||
WHEN LEN(@string) < @desired_length
|
||||
THEN REPLACE(SPACE(@desired_length - LEN(@string)), ' ', @pad_character) + @string
|
||||
ELSE @string
|
||||
END
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
/***************************************
|
||||
* FUNCTION f_padLeft
|
||||
*
|
||||
* fornisce una stringa della lunghezza desiderata aggiungendo a sx il carattere richiesto alla @string originale
|
||||
*
|
||||
* Steamware, S.E.L.
|
||||
* mod: 2010.03.19
|
||||
*
|
||||
****************************************/
|
||||
create FUNCTION f_padRight (@string VARCHAR(255), @desired_length INTEGER, @pad_character CHAR(1))
|
||||
RETURNS VARCHAR(255) AS
|
||||
BEGIN
|
||||
|
||||
-- Prefix the required number of spaces to bulk up the string and then replace the spaces with the desired character
|
||||
RETURN CASE
|
||||
WHEN LEN(@string) < @desired_length
|
||||
THEN @string + REPLACE(SPACE(@desired_length - LEN(@string)), ' ', @pad_character)
|
||||
ELSE @string
|
||||
END
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(312, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,26 @@
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
UPDATE dbo.AnagKeyValue SET
|
||||
descrizione=N'arrotondamento standard valori'
|
||||
WHERE nomeVar=N'minutiRound'
|
||||
INSERT INTO dbo.AnagKeyValue
|
||||
VALUES (N'minutiRoundDay', 15, NULL, NULL, N'arrotondamento giornaliero')
|
||||
INSERT INTO dbo.AnagKeyValue
|
||||
VALUES (N'minutiRoundExtraFascia', 15, NULL, NULL, N'arrotondamento periodi fuori fascia ingresso/uscita')
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(314, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,127 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table AnagKeyValue alter column
|
||||
valString nvarchar(250);
|
||||
go
|
||||
|
||||
alter table AnagKeyValue add
|
||||
constraint DF_AnagKeyValue_valInt default ((0)) for valInt,
|
||||
constraint DF_AnagKeyValue_descrizione default ('-') for descrizione,
|
||||
constraint DF_AnagKeyValue_valFloat default ((0)) for valFloat,
|
||||
constraint DF_AnagKeyValue_valString default ('') for valString;
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table Dipendenti add
|
||||
dataAssunzione date constraint DF_Dipendenti_dataAssunzione default ('1900-01-01'),
|
||||
dataCessazione date constraint DF_Dipendenti_dataCessazione default ('9999-12-31'),
|
||||
attivo bit constraint DF_Dipendenti_attivo default ((1));
|
||||
go
|
||||
|
||||
update Dipendenti set dataAssunzione=('1900-01-01'),dataCessazione=('9999-12-31'),attivo=((1));
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
-- =============================================
|
||||
-- Author: S.E. Locatelli
|
||||
-- Create date: 2013-03-25
|
||||
-- Description: Recupero elenco dip attivi
|
||||
-- =============================================
|
||||
create PROCEDURE stp_Dip_getAttivi
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
SELECT *
|
||||
FROM Dipendenti
|
||||
WHERE (attivo = 1)
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AKV_getByKey
|
||||
*
|
||||
* elenco valori da chiave x tab anagrafica key/val
|
||||
*
|
||||
* mod: S.E.L. 2013.03.25
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_AKV_getByKey
|
||||
(
|
||||
@nomeVar NVARCHAR(50)
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
|
||||
SELECT nomeVar
|
||||
,ISNULL(valInt,0) AS valInt
|
||||
,ISNULL(valFloat,0) AS valFloat
|
||||
,ISNULL(valString,'') AS valString
|
||||
,ISNULL(descrizione,'') AS descrizione
|
||||
FROM AnagKeyValue
|
||||
WHERE nomeVar = @nomeVar
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
UPDATE dbo.AnagKeyValue SET
|
||||
valFloat=0, valString=N''
|
||||
WHERE nomeVar=N'minutiRound'
|
||||
UPDATE dbo.AnagKeyValue SET
|
||||
valFloat=0, valString=N''
|
||||
WHERE nomeVar=N'minutiRoundDay'
|
||||
UPDATE dbo.AnagKeyValue SET
|
||||
valFloat=0, valString=N''
|
||||
WHERE nomeVar=N'minutiRoundExtraFascia'
|
||||
INSERT INTO dbo.AnagKeyValue
|
||||
VALUES (N'appMode', 0, 0, N'runtime', N'modalità applicazione (runtime)')
|
||||
INSERT INTO dbo.AnagKeyValue
|
||||
VALUES (N'installazione', 0, 0, N'ETS', N'nome installazione')
|
||||
INSERT INTO dbo.AnagKeyValue
|
||||
VALUES (N'ETS', 10, 0, N'+FBqyG1V4kqbqYe/IO7KywpmR9YzujB0', N'licenze e codice auth applicativo')
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(320, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,865 @@
|
||||
create table AnagTipoCheck(
|
||||
chkFun nvarchar(50) not null constraint PK_AnagTipoCheck primary key,
|
||||
descrFun nvarchar(50)
|
||||
);
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
INSERT INTO dbo.AnagTipoCheck
|
||||
VALUES (N'PP30m', N'Pausa pranzo 30 min')
|
||||
INSERT INTO dbo.AnagTipoCheck
|
||||
VALUES (N'PP60m', N'Pausa pranzo 60 min')
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table AnagOrari add
|
||||
chkFun nvarchar(50) constraint DF_AnagOrari_checkFun default ('');
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'parametro (opzionale) da passare alla funzione di check "finale" per verifica giornate lavorate in tab TimbratureExpl', 'SCHEMA', 'dbo', 'TABLE', 'AnagOrari', 'COLUMN', 'chkFun';
|
||||
go
|
||||
|
||||
update AnagOrari set chkFun=('');
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
/******************************************************************************
|
||||
* FUNCTION f_chkFunDip
|
||||
*
|
||||
* restituisce il nome della funzione di check da applicare dato profilo orario
|
||||
*
|
||||
* mod: S.E.L. 2013.03.28
|
||||
*
|
||||
*******************************************************************************/
|
||||
create FUNCTION f_chkFunDip
|
||||
(
|
||||
@idxDipendente INT
|
||||
)
|
||||
RETURNS NVARCHAR(50)
|
||||
AS
|
||||
|
||||
BEGIN
|
||||
|
||||
DECLARE @chkFun NVARCHAR(50) = ''
|
||||
|
||||
|
||||
SELECT @chkFun = ISNULL(chkFun,'')
|
||||
FROM AnagOrari ao INNER JOIN Dipendenti d ON ao.codOrario=d.codOrario
|
||||
WHERE d.idxDipendente = @idxDipendente
|
||||
|
||||
RETURN @chkFun
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table TimbratureExpl drop
|
||||
constraint DF_TimbratureExpl_minOrd ,
|
||||
constraint DF_TimbratureExpl_minLav ,
|
||||
constraint DF_TimbratureExpl_minStra ,
|
||||
constraint DF_TimbratureExpl_minNonLav ,
|
||||
constraint DF_TimbratureExpl_minFest ,
|
||||
constraint DF_TimbratureExpl_minPerm ,
|
||||
constraint DF_TimbratureExpl_minFer ,
|
||||
constraint DF_TimbratureExpl_minFest1 ,
|
||||
constraint DF_TimbratureExpl_block ,
|
||||
constraint DF_TimbratureExpl_isOkTim ,
|
||||
constraint DF_TimbratureExpl_isOk ;
|
||||
go
|
||||
|
||||
exec sp_rename 'PK_TimbratureExpl_1', 'tmp__PK_TimbratureExpl_1', 'OBJECT';
|
||||
go
|
||||
|
||||
exec sp_rename 'TimbratureExpl', 'tmp__TimbratureExpl_2', 'OBJECT';
|
||||
go
|
||||
|
||||
create table TimbratureExpl(
|
||||
dataLav date not null,
|
||||
idxDipendente int not null,
|
||||
CognomeNome nvarchar(100),
|
||||
entrata_1 datetime,
|
||||
uscita_1 datetime,
|
||||
entrata_2 datetime,
|
||||
uscita_2 datetime,
|
||||
entrata_3 datetime,
|
||||
uscita_3 datetime,
|
||||
entrata_4 datetime,
|
||||
uscita_4 datetime,
|
||||
h_lav float,
|
||||
h_giust as ((((CONVERT([float],[minPerm],(0))+[minFer])+[minMal])+[minFest])/(60)),
|
||||
minLav int constraint DF_TimbratureExpl_minLav default ((0)),
|
||||
minOrd int constraint DF_TimbratureExpl_minOrd default ((0)),
|
||||
minNonLav int constraint DF_TimbratureExpl_minNonLav default ((0)),
|
||||
minStra int constraint DF_TimbratureExpl_minStra default ((0)),
|
||||
minPerm int constraint DF_TimbratureExpl_minPerm default ((0)),
|
||||
minFer int constraint DF_TimbratureExpl_minFer default ((0)),
|
||||
minMal int constraint DF_TimbratureExpl_minFest1 default ((0)),
|
||||
minFest int constraint DF_TimbratureExpl_minFest default ((0)),
|
||||
minArcoPres as (datediff(minute,isnull([entrata_1],getdate()),isnull(isnull([uscita_4],isnull([uscita_3],isnull([uscita_2],isnull([uscita_1],[entrata_1])))),getdate()))),
|
||||
isOkTim bit constraint DF_TimbratureExpl_isOkTim default ((0)),
|
||||
isOkApp bit constraint DF_TimbratureExpl_isOk default ((1)),
|
||||
isOkLav as (case when [minOrd]<=(((([minLav]+[minPerm])+[minFer])+[minMal])+[minFest]) then (1) else (0) end),
|
||||
isOk as (([isOkTim]&[isOkApp])&case when [minOrd]<=(((([minLav]+[minPerm])+[minFer])+[minMal])+[minFest]) then (1) else (0) end),
|
||||
block bit constraint DF_TimbratureExpl_block default ((0)),
|
||||
chkFunCod nvarchar(50) constraint DF_TimbratureExpl_chkFunRes default (''),
|
||||
chkFunRes nvarchar(50) constraint DF_TimbratureExpl_chkFunRes1 default (''),
|
||||
|
||||
constraint PK_TimbratureExpl_1 primary key(dataLav,idxDipendente)
|
||||
);
|
||||
go
|
||||
|
||||
create index ix_idxDip on TimbratureExpl(idxDipendente)
|
||||
include(dataLav,CognomeNome,h_lav,minOrd,minStra,minPerm,minFer,block,isOkApp,isOkTim);
|
||||
go
|
||||
|
||||
create index ix_TimbrExpl_CognomeNome_DataLav on TimbratureExpl(CognomeNome,dataLav);
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'totale ore giustificate', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'h_giust';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'minuti non lavorati (ovvero se fatti meno di ordinari e senza giustificativi)', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'minNonLav';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'DATEDIFF(n, ISNULL(entrata_1,GETDATE()), ISNULL(ISNULL(uscita_4,ISNULL(uscita_3,ISNULL(uscita_2,ISNULL(uscita_1,entrata_1)))),GETDATE()))', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'minArcoPres';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'dato sintetico x indicare se TUTTE le timbrature componenti siano approvate', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'isOkApp';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'determina se la giornata sia ok (oreLav + giustificativi >= oreOrd)', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'isOkLav';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'determina se il record sia "bloccato" (archiviazione e blocco mesi precedenti...)', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'block';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'eventuale diagnostica da check function sulla riga indicata (codice)', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'chkFunCod';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'eventuale diagnostica da check function sulla riga indicata (spiegazione)', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'chkFunRes';
|
||||
go
|
||||
|
||||
insert into TimbratureExpl(dataLav,idxDipendente,CognomeNome,entrata_1,uscita_1,entrata_2,uscita_2,entrata_3,uscita_3,entrata_4,uscita_4,h_lav,minLav,minOrd,minNonLav,minStra,minPerm,minFer,minMal,minFest,isOkTim,isOkApp,block) select dataLav,idxDipendente,CognomeNome,entrata_1,uscita_1,entrata_2,uscita_2,entrata_3,uscita_3,entrata_4,uscita_4,h_lav,minLav,minOrd,minNonLav,minStra,minPerm,minFer,minMal,minFest,isOkTim,isOkApp,block from tmp__TimbratureExpl_2;
|
||||
go
|
||||
|
||||
drop table tmp__TimbratureExpl_2;
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
create VIEW v_selCodOrario
|
||||
AS
|
||||
SELECT codOrario AS value, codOrario AS label
|
||||
FROM dbo.AnagOrari
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_DiagramPane1', '[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
|
||||
Begin DesignProperties =
|
||||
Begin PaneConfigurations =
|
||||
Begin PaneConfiguration = 0
|
||||
NumPanes = 4
|
||||
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
|
||||
End
|
||||
Begin PaneConfiguration = 1
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 4 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 2
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 2 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 3
|
||||
NumPanes = 3
|
||||
Configuration = "(H (4 [30] 2 [40] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 4
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [56] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 5
|
||||
NumPanes = 2
|
||||
Configuration = "(H (2 [66] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 6
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [50] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 7
|
||||
NumPanes = 1
|
||||
Configuration = "(V (3))"
|
||||
End
|
||||
Begin PaneConfiguration = 8
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1[56] 4[18] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 9
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [75] 4))"
|
||||
End
|
||||
Begin PaneConfiguration = 10
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1[66] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 11
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [60] 2))"
|
||||
End
|
||||
Begin PaneConfiguration = 12
|
||||
NumPanes = 1
|
||||
Configuration = "(H (1) )"
|
||||
End
|
||||
Begin PaneConfiguration = 13
|
||||
NumPanes = 1
|
||||
Configuration = "(V (4))"
|
||||
End
|
||||
Begin PaneConfiguration = 14
|
||||
NumPanes = 1
|
||||
Configuration = "(V (2))"
|
||||
End
|
||||
ActivePaneConfig = 0
|
||||
End
|
||||
Begin DiagramPane =
|
||||
Begin Origin =
|
||||
Top = 0
|
||||
Left = 0
|
||||
End
|
||||
Begin Tables =
|
||||
Begin Table = "AnagOrari"
|
||||
Begin Extent =
|
||||
Top = 6
|
||||
Left = 38
|
||||
Bottom = 200
|
||||
Right = 223
|
||||
End
|
||||
DisplayFlags = 280
|
||||
TopColumn = 0
|
||||
End
|
||||
End
|
||||
End
|
||||
Begin SQLPane =
|
||||
End
|
||||
Begin DataPane =
|
||||
Begin ParameterDefaults = ""
|
||||
End
|
||||
Begin ColumnWidths = 9
|
||||
Width = 284
|
||||
Width = 1500
|
||||
Width = 3810
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
End
|
||||
End
|
||||
Begin CriteriaPane =
|
||||
Begin ColumnWidths = 11
|
||||
Column = 1440
|
||||
Alias = 900
|
||||
Table = 1170
|
||||
Output = 720
|
||||
Append = 1400
|
||||
NewValue = 1170
|
||||
SortType = 1350
|
||||
SortOrder = 1410
|
||||
GroupBy = 1350
|
||||
Filter = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
End
|
||||
End
|
||||
End
|
||||
', 'SCHEMA', 'dbo', 'VIEW', 'v_selCodOrario';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_DiagramPaneCount', 1, 'SCHEMA', 'dbo', 'VIEW', 'v_selCodOrario';
|
||||
go
|
||||
|
||||
create VIEW v_selTipoChk
|
||||
AS
|
||||
SELECT chkFun AS value, descrFun AS label
|
||||
FROM dbo.AnagTipoCheck
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_DiagramPane1', '[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
|
||||
Begin DesignProperties =
|
||||
Begin PaneConfigurations =
|
||||
Begin PaneConfiguration = 0
|
||||
NumPanes = 4
|
||||
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
|
||||
End
|
||||
Begin PaneConfiguration = 1
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 4 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 2
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 2 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 3
|
||||
NumPanes = 3
|
||||
Configuration = "(H (4 [30] 2 [40] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 4
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [56] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 5
|
||||
NumPanes = 2
|
||||
Configuration = "(H (2 [66] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 6
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [50] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 7
|
||||
NumPanes = 1
|
||||
Configuration = "(V (3))"
|
||||
End
|
||||
Begin PaneConfiguration = 8
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1[56] 4[18] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 9
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [75] 4))"
|
||||
End
|
||||
Begin PaneConfiguration = 10
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1[66] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 11
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [60] 2))"
|
||||
End
|
||||
Begin PaneConfiguration = 12
|
||||
NumPanes = 1
|
||||
Configuration = "(H (1) )"
|
||||
End
|
||||
Begin PaneConfiguration = 13
|
||||
NumPanes = 1
|
||||
Configuration = "(V (4))"
|
||||
End
|
||||
Begin PaneConfiguration = 14
|
||||
NumPanes = 1
|
||||
Configuration = "(V (2))"
|
||||
End
|
||||
ActivePaneConfig = 0
|
||||
End
|
||||
Begin DiagramPane =
|
||||
Begin Origin =
|
||||
Top = 0
|
||||
Left = 0
|
||||
End
|
||||
Begin Tables =
|
||||
Begin Table = "AnagTipoCheck"
|
||||
Begin Extent =
|
||||
Top = 6
|
||||
Left = 38
|
||||
Bottom = 102
|
||||
Right = 208
|
||||
End
|
||||
DisplayFlags = 280
|
||||
TopColumn = 0
|
||||
End
|
||||
End
|
||||
End
|
||||
Begin SQLPane =
|
||||
End
|
||||
Begin DataPane =
|
||||
Begin ParameterDefaults = ""
|
||||
End
|
||||
Begin ColumnWidths = 9
|
||||
Width = 284
|
||||
Width = 1500
|
||||
Width = 1755
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
End
|
||||
End
|
||||
Begin CriteriaPane =
|
||||
Begin ColumnWidths = 11
|
||||
Column = 1440
|
||||
Alias = 900
|
||||
Table = 1170
|
||||
Output = 720
|
||||
Append = 1400
|
||||
NewValue = 1170
|
||||
SortType = 1350
|
||||
SortOrder = 1410
|
||||
GroupBy = 1350
|
||||
Filter = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
End
|
||||
End
|
||||
End
|
||||
', 'SCHEMA', 'dbo', 'VIEW', 'v_selTipoChk';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_DiagramPaneCount', 1, 'SCHEMA', 'dbo', 'VIEW', 'v_selTipoChk';
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AD_insertQuery
|
||||
*
|
||||
* aggiunge un dipendente in anagrafica
|
||||
*
|
||||
* mod: S.E.L. 2012.10.29
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AD_insertQuery
|
||||
(
|
||||
@matricola NVARCHAR(50),
|
||||
@CF NVARCHAR(16),
|
||||
@Cognome NVARCHAR(50),
|
||||
@Nome NVARCHAR(50),
|
||||
@dataNascita DATETIME,
|
||||
@luogoNascita NVARCHAR(50),
|
||||
@provNascita NVARCHAR(50),
|
||||
@nazNascita NVARCHAR(50),
|
||||
@email NVARCHAR(250),
|
||||
@dominio NVARCHAR(50),
|
||||
@utente NVARCHAR(50),
|
||||
@codOrario NVARCHAR(50),
|
||||
@attivo BIT
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
INSERT INTO Dipendenti
|
||||
(matricola, CF, Cognome, Nome, dataNascita, luogoNascita, provNascita, nazNascita, email, dominio, utente,codOrario,attivo)
|
||||
VALUES (@matricola,@CF,@Cognome,@Nome,@dataNascita,@luogoNascita,UPPER(@provNascita),UPPER(@nazNascita),@email,@dominio,@utente,@codOrario,@attivo);
|
||||
|
||||
SELECT * FROM Dipendenti WHERE (idxDipendente = SCOPE_IDENTITY())
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_AD_updateQuery
|
||||
*
|
||||
* aggiorna un dipendente da anagrafica
|
||||
*
|
||||
* mod: S.E.L. 2012.10.29
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_AD_updateQuery
|
||||
(
|
||||
@matricola NVARCHAR(50),
|
||||
@CF NVARCHAR(16),
|
||||
@Cognome NVARCHAR(50),
|
||||
@Nome NVARCHAR(50),
|
||||
@dataNascita datetime,
|
||||
@luogoNascita NVARCHAR(50),
|
||||
@provNascita NVARCHAR(50),
|
||||
@nazNascita NVARCHAR(50),
|
||||
@email NVARCHAR(250),
|
||||
@dominio NVARCHAR(50),
|
||||
@utente NVARCHAR(50),
|
||||
@codOrario NVARCHAR(50),
|
||||
@attivo BIT,
|
||||
@Original_idxDipendente int
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT OFF;
|
||||
UPDATE Dipendenti
|
||||
SET matricola = @matricola, CF = @CF, Cognome = @Cognome, Nome = @Nome, dataNascita = @dataNascita, luogoNascita = @luogoNascita,
|
||||
provNascita = UPPER(@provNascita), nazNascita = UPPER(@nazNascita), email = @email, dominio = @dominio, utente = @utente
|
||||
,codOrario = @codOrario, attivo = @attivo
|
||||
WHERE (idxDipendente = @Original_idxDipendente);
|
||||
|
||||
SELECT * FROM Dipendenti WHERE (idxDipendente = @Original_idxDipendente)
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*******************************************************************************
|
||||
* STORED PROCEDURE stp_TE_doChkFun
|
||||
*
|
||||
* effettua check finali sulla riga di timbrature esplore indicata, contiene varie logiche
|
||||
* anche da + installazioni clienti
|
||||
*
|
||||
* mod: S.E.L. 2013.03.28
|
||||
*
|
||||
*******************************************************************************/
|
||||
create PROCEDURE stp_TE_doChkFun
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
|
||||
|
||||
-- recupero tipo di fuction da usare
|
||||
DECLARE @chkFun NVARCHAR(50) = ''
|
||||
DECLARE @minPP INT = 0
|
||||
|
||||
SELECT @chkFun = dbo.f_chkFunDip(@idxDipendente)
|
||||
-- controllo tipo di funzione... e imposto risultato!
|
||||
IF(@chkFun = 'PP60m')
|
||||
BEGIN
|
||||
SET @minPP = 60
|
||||
|
||||
UPDATE TimbratureExpl
|
||||
SET chkFunCod = 'P',
|
||||
chkFunRes = 'Mancata pausa pranzo 60m'
|
||||
WHERE idxDipendente = @idxDipendente AND dataLav = @dataRif
|
||||
AND (minArcoPres - minLav) < @minPP -- controllo pause > PP imposta
|
||||
AND (minOrd > 0 AND minLav > 0) -- controllo DEBBA lavorare e ABBIA lavorato
|
||||
END
|
||||
ELSE IF(@chkFun = 'PP30m')
|
||||
BEGIN
|
||||
SET @minPP = 30
|
||||
|
||||
UPDATE TimbratureExpl
|
||||
SET chkFunCod = 'P',
|
||||
chkFunRes = 'Mancata pausa pranzo 30m'
|
||||
WHERE idxDipendente = @idxDipendente AND dataLav = @dataRif
|
||||
AND (minArcoPres - minLav) < @minPP -- controllo pause > PP imposta
|
||||
AND (minOrd > 0 AND minLav > 0) -- controllo DEBBA lavorare e ABBIA lavorato
|
||||
END
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*******************************************************************************
|
||||
* stp_ricalcolaTimbratureExpl
|
||||
*
|
||||
* Aggiorna la tab timbrature expl ricalcolando la giornata del record interessato
|
||||
* mod: S.E.L. - 2012.02.06
|
||||
********************************************************************************/
|
||||
alter PROCEDURE stp_ricalcolaTimbratureExpl
|
||||
(
|
||||
@idxDipendente AS INT,
|
||||
@dataRif AS DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
-- variabili
|
||||
DECLARE @minArr INT
|
||||
SELECT @minArr=dbo.f_minArrotDip(@idxDipendente)
|
||||
|
||||
-- CONTROLLO SE IL RECORD NON SIA BLOCCATO!!!
|
||||
DECLARE @block BIT
|
||||
SET @block = ( SELECT ISNULL(( SELECT block FROM TimbratureExpl WHERE (idxDipendente = @idxDipendente) AND CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif) ),0) )
|
||||
IF(@block = 0)
|
||||
BEGIN
|
||||
-- elimino i periodi della data indicata...
|
||||
DELETE FROM TimbratureExpl
|
||||
WHERE (idxDipendente = @idxDipendente) AND CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)
|
||||
|
||||
-- inserisco i dati minimi per la data indicata
|
||||
INSERT INTO TimbratureExpl(idxDipendente, dataLav)
|
||||
VALUES(@idxDipendente, CONVERT(DATE,@dataRif))
|
||||
|
||||
-- aggiorno cognome nome
|
||||
BEGIN TRY
|
||||
UPDATE te
|
||||
SET CognomeNome = ISNULL(vcn.CognomeNome,'')
|
||||
FROM TimbratureExpl te INNER JOIN v_cognomeNome vcn ON te.idxDipendente = vcn.idxDipendente
|
||||
WHERE CONVERT(DATE,te.dataLav) = CONVERT(DATE,@dataRif) AND te.idxDipendente = @idxDipendente
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
-- non faccio nulla
|
||||
END CATCH
|
||||
|
||||
-- aggiorno 1° timbratura
|
||||
UPDATE te
|
||||
SET te.entrata_1 = pl.entrata,
|
||||
te.uscita_1 = pl.uscita
|
||||
FROM TimbratureExpl te INNER JOIN PeriodiLav pl ON
|
||||
te.idxDipendente = pl.idxDipendente AND
|
||||
(CONVERT(DATE,te.dataLav) = CONVERT(DATE,pl.entrata))
|
||||
WHERE pl.rowNum = 1 AND te.idxDipendente = @idxDipendente AND CONVERT(DATE,pl.entrata) = CONVERT(DATE,@dataRif)
|
||||
|
||||
-- aggiorno 2° timbratura
|
||||
UPDATE te
|
||||
SET te.entrata_2 = pl.entrata,
|
||||
te.uscita_2 = pl.uscita
|
||||
FROM TimbratureExpl te INNER JOIN PeriodiLav pl ON te.idxDipendente = pl.idxDipendente
|
||||
AND (CONVERT(DATE,te.dataLav) = CONVERT(DATE,pl.entrata))
|
||||
WHERE pl.rowNum = 2 AND te.idxDipendente = @idxDipendente AND CONVERT(DATE,pl.entrata) = CONVERT(DATE,@dataRif)
|
||||
|
||||
-- aggiorno 3° timbratura
|
||||
UPDATE te
|
||||
SET te.entrata_3 = pl.entrata,
|
||||
te.uscita_3 = pl.uscita
|
||||
FROM TimbratureExpl te INNER JOIN PeriodiLav pl ON te.idxDipendente = pl.idxDipendente
|
||||
AND (CONVERT(DATE,te.dataLav) =CONVERT(DATE,pl.entrata))
|
||||
WHERE pl.rowNum = 3 AND te.idxDipendente = @idxDipendente AND CONVERT(DATE,pl.entrata) = CONVERT(DATE,@dataRif)
|
||||
|
||||
-- aggiorno 4° timbratura
|
||||
UPDATE te
|
||||
SET te.entrata_4 = pl.entrata,
|
||||
te.uscita_4 = pl.uscita
|
||||
FROM TimbratureExpl te INNER JOIN PeriodiLav pl ON te.idxDipendente = pl.idxDipendente
|
||||
AND (CONVERT(DATE,te.dataLav) =CONVERT(DATE,pl.entrata))
|
||||
WHERE pl.rowNum = 4 AND te.idxDipendente = @idxDipendente AND CONVERT(DATE,pl.entrata) = CONVERT(DATE,@dataRif)
|
||||
|
||||
-- calcolo ore totali...
|
||||
UPDATE TimbratureExpl
|
||||
SET h_lav = CAST(FLOOR((ISNULL(DATEDIFF(n,entrata_1,uscita_1),0) + ISNULL(DATEDIFF(n,entrata_2,uscita_2),0) + ISNULL(DATEDIFF(n,entrata_3,uscita_3),0) + ISNULL(DATEDIFF(n,entrata_4,uscita_4),0))/@minArr) AS FLOAT)*@minArr/60
|
||||
FROM TimbratureExpl
|
||||
WHERE (CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)) AND idxDipendente = @idxDipendente
|
||||
|
||||
-- verifico: se c'è anche solo 1 timbratura non approvata metto flag isOkApp a falso
|
||||
UPDATE TimbratureExpl
|
||||
SET isOkApp = ISNULL((
|
||||
SELECT MIN(CASE WHEN Approv=0 THEN 0 ELSE 1 END) AS isOk
|
||||
FROM Timbrature
|
||||
WHERE idxDipendente = @idxDipendente
|
||||
AND (CONVERT(DATE,dataOra) = CONVERT(DATE,@dataRif))
|
||||
GROUP BY CONVERT(DATE,dataOra)
|
||||
),1)
|
||||
FROM TimbratureExpl
|
||||
WHERE (CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)) AND idxDipendente = @idxDipendente
|
||||
|
||||
-- verifico: se entrate <> uscite flag isOkTim a falso
|
||||
UPDATE TimbratureExpl
|
||||
SET isOkTim = (
|
||||
SELECT CASE WHEN
|
||||
ISNULL(
|
||||
(SELECT COUNT(*) as timb
|
||||
FROM Timbrature AS t
|
||||
WHERE t.idxDipendente = @idxDipendente
|
||||
AND (CONVERT(DATE,dataOra) = CONVERT(DATE,@dataRif))
|
||||
GROUP BY t.idxDipendente , CONVERT(DATE,t.dataOra)
|
||||
HAVING COUNT ( CASE Entrata WHEN 1 THEN dataOra END ) <> COUNT ( CASE Entrata WHEN 0 THEN dataOra END )
|
||||
),0) > 0 THEN 0 ELSE 1 END
|
||||
)
|
||||
FROM TimbratureExpl
|
||||
WHERE (CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)) AND idxDipendente = @idxDipendente
|
||||
|
||||
-- calcolo resoconto MINUTI giornaliero, imposto LUN x inizio settimana
|
||||
SET DATEFIRST 1
|
||||
|
||||
-- MIN lavorati, ordinari (con arrotondamento...)
|
||||
UPDATE TimbratureExpl
|
||||
SET minLav = CAST((ISNULL(DATEDIFF(n,entrata_1,uscita_1),0) + ISNULL(DATEDIFF(n,entrata_2,uscita_2),0) + ISNULL(DATEDIFF(n,entrata_3,uscita_3),0) + ISNULL(DATEDIFF(n,entrata_4,uscita_4),0)) AS FLOAT)
|
||||
,minOrd = dbo.f_oreOrdDip(idxDipendente,dataLav) * 60 -- da schema orario dip attivo
|
||||
FROM TimbratureExpl
|
||||
WHERE (CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)) AND idxDipendente = @idxDipendente
|
||||
|
||||
-- MIN non lavorati, straordinari (con arrotondamento...)
|
||||
UPDATE TimbratureExpl
|
||||
SET minNonLav = (CEILING(CONVERT(FLOAT,CASE WHEN minOrd <= minLav THEN (0) ELSE minOrd-minLav END)/@minArr)*@minArr)
|
||||
,minStra = (FLOOR(CONVERT(FLOAT,CASE WHEN minOrd < minLav AND minLav > (0) THEN minLav-minOrd ELSE (0) END)/@minArr)*@minArr)
|
||||
FROM TimbratureExpl
|
||||
WHERE (CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)) AND idxDipendente = @idxDipendente
|
||||
|
||||
|
||||
-- MIN da tab giustificativi (feste, ferie, malattia, permessi)
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust='MAL' THEN g.minuti ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN g.minuti ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN g.minuti ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN g.minuti ELSE minPerm END,
|
||||
chkFunCod = '',
|
||||
chkFunRes = ''
|
||||
FROM TimbratureExpl te INNER JOIN Giustificativi g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
WHERE (CONVERT(DATE,te.dataLav) = CONVERT(DATE,@dataRif)) AND te.idxDipendente = @idxDipendente
|
||||
|
||||
-- verifico SE codice orario richieda una chkFun eseguo calcolo...
|
||||
IF(dbo.f_chkFunDip(@idxDipendente)<>'')
|
||||
BEGIN
|
||||
EXEC stp_TE_doChkFun @idxDipendente, @dataRif
|
||||
END
|
||||
|
||||
END
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_lcuByDipDate
|
||||
*
|
||||
* elenco dati COMPLETI di timbratura e commessa per utente/periodo
|
||||
*
|
||||
* mod: S.E.L. 2012.11.02
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_TE_RA_ByUserDate
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataFrom DATETIME,
|
||||
@dataTo DATETIME,
|
||||
@showWE BIT = 1, -- imposto visualizzazione week-end a true di default
|
||||
@maxErrMin INT = 0, -- minuti massimi di scostamento consentiti per DIFETTO, default 0
|
||||
@maxErrPlus INT = 0 -- minuti massimi di scostamento consentiti per ECCESSO, default 0
|
||||
)
|
||||
with recompile
|
||||
AS
|
||||
|
||||
BEGIN
|
||||
|
||||
-- imposto LUN x inizio settimana
|
||||
SET DATEFIRST 1
|
||||
|
||||
-- faccio una tab temporanea con tallyTable x calcolo periodo intero...
|
||||
DECLARE @numD INT
|
||||
SET @numD = ( SELECT DATEDIFF(dd, @dataFrom, @dataTo ) )
|
||||
|
||||
-- tab dei record RegAttività progetti
|
||||
;WITH myCteRA AS
|
||||
(
|
||||
SELECT idxDipendente, dataLav, minRegAtt, descrProj
|
||||
FROM dbo.RegAttivitaExpl
|
||||
WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0) AND (dataLav >= DATEADD(DAY,-1,@dataFrom) AND dataLav <= @dataTo)
|
||||
)
|
||||
|
||||
SELECT mc.Data as dataLav
|
||||
,mc.idxDipendente
|
||||
,ISNULL(dip.Cognome + ' ' + dip.Nome,'') AS CognomeNome
|
||||
-- ore base + progetti
|
||||
,ISNULL(te.h_lav,0) AS h_lav
|
||||
,ISNULL(te.h_giust,0) AS h_giust
|
||||
,CAST(ISNULL(vra.minRegAtt,0) AS DECIMAL(9,3))/60 AS h_com
|
||||
,ISNULL(vra.descrProj,'') as progetti
|
||||
-- check coerenza
|
||||
,CASE WHEN ISNULL(vra.minRegAtt,0)-ISNULL(te.h_lav,0)*60 >= @maxErrMin AND ISNULL(vra.minRegAtt,0)-ISNULL(te.h_lav,0)*60 <= @maxErrPlus THEN 1 ELSE 0 END AS okLavCom
|
||||
,ISNULL(te.isOkTim,0) AS isOkTim
|
||||
,ISNULL(te.isOkApp,0) AS isOkApp
|
||||
,ISNULL(te.isOkLav,0) AS isOkLav
|
||||
,ISNULL(te.isOk,0) AS isOk
|
||||
-- check blocco
|
||||
,ISNULL(te.block,0) AS block
|
||||
-- dettaglio minuti
|
||||
,ISNULL(te.minOrd,0) AS minOrd
|
||||
,ISNULL(te.minNonLav,0) AS minNonLav
|
||||
,ISNULL(te.minStra,0) AS minStra
|
||||
,ISNULL(te.minPerm,0) AS minPerm
|
||||
,ISNULL(te.minFer,0) AS minFer
|
||||
,ISNULL(te.minMal,0) AS minMal
|
||||
,ISNULL(te.minFest,0) AS minFest
|
||||
,ISNULL(te.minArcoPres,0) AS minArcoPres
|
||||
,ISNULL(vra.minRegAtt,0) AS minRegAtt
|
||||
-- dettaglio entrate
|
||||
, te.entrata_1, te.uscita_1
|
||||
, te.entrata_2, te.uscita_2
|
||||
, te.entrata_3, te.uscita_3
|
||||
, te.entrata_4, te.uscita_4
|
||||
-- dati check
|
||||
, te.chkFunCod, te.chkFunRes
|
||||
|
||||
FROM (SELECT CONVERT(DATE,DATEADD(dd, -N, @dataTo)) as Data, idxDipendente
|
||||
FROM Tally, Dipendenti
|
||||
WHERE N <= @numD
|
||||
AND (idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
) AS mc
|
||||
LEFT OUTER JOIN myCteRA vra ON mc.Data = vra.dataLav AND mc.idxDipendente=vra.idxDipendente
|
||||
LEFT OUTER JOIN TimbratureExpl te ON mc.Data=te.dataLav AND te.idxDipendente=mc.idxDipendente
|
||||
LEFT OUTER JOIN Dipendenti dip ON dip.idxDipendente=mc.idxDipendente
|
||||
WHERE (te.idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND DATEPART(dw, mc.Data) <= CASE WHEN @showWE=0 THEN 5 ELSE 7 END --solo lun-ven, 1-5
|
||||
ORDER BY mc.Data DESC, dip.Cognome, dip.Nome
|
||||
|
||||
END
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(324, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,273 @@
|
||||
create table ListValues(
|
||||
TableName nvarchar(50) not null,
|
||||
FieldName nvarchar(50) not null,
|
||||
value nvarchar(10) not null,
|
||||
label nvarchar(50),
|
||||
ordinal int constraint DF_ListValues_ordinal default ((0)),
|
||||
|
||||
constraint PK_ListValues_1 primary key(TableName,FieldName,value)
|
||||
);
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
INSERT INTO dbo.ListValues
|
||||
VALUES (N'*', N'PageSize', N'10', N'10', 1)
|
||||
INSERT INTO dbo.ListValues
|
||||
VALUES (N'*', N'PageSize', N'15', N'15', 2)
|
||||
INSERT INTO dbo.ListValues
|
||||
VALUES (N'*', N'PageSize', N'20', N'20', 3)
|
||||
INSERT INTO dbo.ListValues
|
||||
VALUES (N'*', N'PageSize', N'35', N'35', 4)
|
||||
INSERT INTO dbo.ListValues
|
||||
VALUES (N'*', N'PageSize', N'50', N'50', 5)
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* Trigger su insert/update
|
||||
*
|
||||
* Aggiorna giustificativi nella tab TimbratureExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2012.12.04
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
alter TRIGGER trg_giustUpdateTimbr
|
||||
ON Giustificativi
|
||||
FOR INSERT, UPDATE
|
||||
AS
|
||||
|
||||
-- controllo se rescord esista altrimenti lo creo!!!
|
||||
DECLARE @trovate INT = 0
|
||||
DECLARE @idxDipendente INT
|
||||
DECLARE @dataRif DATETIME
|
||||
SET @trovate = ISNULL( ( SELECT COUNT(*) FROM TimbratureExpl te INNER JOIN inserted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav) ,0)
|
||||
IF(@trovate = 0)
|
||||
BEGIN
|
||||
SELECT @idxDipendente = idxDipendente, @dataRif=dataLav FROM inserted
|
||||
EXEC stp_ricalcolaTimbratureExpl @idxDipendente, @dataRif
|
||||
END
|
||||
|
||||
-- CONTROLLO SE IL RECORD NON SIA BLOCCATO con where nell'update
|
||||
-- prendo tutte le "vecchie" righe (deleted) e x le giornate relative TOLGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust='MAL' THEN 0 ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN 0 ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN 0 ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN 0 ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN deleted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
WHERE te.block = 0
|
||||
|
||||
-- prendo le "nuove" righe (inserted) e x le giornate relative AGGIUNGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust='MAL' THEN g.minuti ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN g.minuti ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN g.minuti ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN g.minuti ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN inserted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
WHERE te.block = 0
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* Trigger su delete
|
||||
*
|
||||
* Aggiorna giustificativi nella tab TimbratureExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2012.12.04
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
alter TRIGGER trg_giustDelUpdTimbr
|
||||
ON Giustificativi
|
||||
FOR DELETE
|
||||
AS
|
||||
|
||||
-- controllo se rescord esista altrimenti lo creo!!!
|
||||
DECLARE @trovate INT = 0
|
||||
DECLARE @idxDipendente INT
|
||||
DECLARE @dataRif DATETIME
|
||||
|
||||
-- CONTROLLO SE IL RECORD NON SIA BLOCCATO in update con where
|
||||
-- prendo tutte le "vecchie" righe (deleted) e x le giornate relative TOLGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust='MAL' THEN 0 ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN 0 ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN 0 ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN 0 ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN deleted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
WHERE te.block = 0
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
create VIEW v_selPageSize
|
||||
AS
|
||||
SELECT TOP (100) PERCENT value, label, ordinal
|
||||
FROM dbo.ListValues
|
||||
WHERE (TableName = N'*') AND (FieldName = N'PageSize')
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_DiagramPane1', '[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
|
||||
Begin DesignProperties =
|
||||
Begin PaneConfigurations =
|
||||
Begin PaneConfiguration = 0
|
||||
NumPanes = 4
|
||||
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
|
||||
End
|
||||
Begin PaneConfiguration = 1
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 4 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 2
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1 [50] 2 [25] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 3
|
||||
NumPanes = 3
|
||||
Configuration = "(H (4 [30] 2 [40] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 4
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [56] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 5
|
||||
NumPanes = 2
|
||||
Configuration = "(H (2 [66] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 6
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [50] 3))"
|
||||
End
|
||||
Begin PaneConfiguration = 7
|
||||
NumPanes = 1
|
||||
Configuration = "(V (3))"
|
||||
End
|
||||
Begin PaneConfiguration = 8
|
||||
NumPanes = 3
|
||||
Configuration = "(H (1[56] 4[18] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 9
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1 [75] 4))"
|
||||
End
|
||||
Begin PaneConfiguration = 10
|
||||
NumPanes = 2
|
||||
Configuration = "(H (1[66] 2) )"
|
||||
End
|
||||
Begin PaneConfiguration = 11
|
||||
NumPanes = 2
|
||||
Configuration = "(H (4 [60] 2))"
|
||||
End
|
||||
Begin PaneConfiguration = 12
|
||||
NumPanes = 1
|
||||
Configuration = "(H (1) )"
|
||||
End
|
||||
Begin PaneConfiguration = 13
|
||||
NumPanes = 1
|
||||
Configuration = "(V (4))"
|
||||
End
|
||||
Begin PaneConfiguration = 14
|
||||
NumPanes = 1
|
||||
Configuration = "(V (2))"
|
||||
End
|
||||
ActivePaneConfig = 0
|
||||
End
|
||||
Begin DiagramPane =
|
||||
Begin Origin =
|
||||
Top = 0
|
||||
Left = 0
|
||||
End
|
||||
Begin Tables =
|
||||
Begin Table = "ListValues"
|
||||
Begin Extent =
|
||||
Top = 6
|
||||
Left = 38
|
||||
Bottom = 187
|
||||
Right = 208
|
||||
End
|
||||
DisplayFlags = 280
|
||||
TopColumn = 0
|
||||
End
|
||||
End
|
||||
End
|
||||
Begin SQLPane =
|
||||
End
|
||||
Begin DataPane =
|
||||
Begin ParameterDefaults = ""
|
||||
End
|
||||
Begin ColumnWidths = 9
|
||||
Width = 284
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
Width = 1500
|
||||
End
|
||||
End
|
||||
Begin CriteriaPane =
|
||||
Begin ColumnWidths = 11
|
||||
Column = 1440
|
||||
Alias = 900
|
||||
Table = 1170
|
||||
Output = 720
|
||||
Append = 1400
|
||||
NewValue = 1170
|
||||
SortType = 1350
|
||||
SortOrder = 1410
|
||||
GroupBy = 1350
|
||||
Filter = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
Or = 1350
|
||||
End
|
||||
End
|
||||
End
|
||||
', 'SCHEMA', 'dbo', 'VIEW', 'v_selPageSize';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_DiagramPaneCount', 1, 'SCHEMA', 'dbo', 'VIEW', 'v_selPageSize';
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(325, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,289 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* Trigger su insert/update
|
||||
*
|
||||
* Aggiorna giustificativi nella tab TimbratureExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2012.12.04
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
alter TRIGGER trg_giustUpdateTimbr
|
||||
ON Giustificativi
|
||||
FOR INSERT, UPDATE
|
||||
AS
|
||||
|
||||
-- controllo se rescord esista altrimenti lo creo!!!
|
||||
DECLARE @trovate INT = 0
|
||||
DECLARE @idxDipendente INT
|
||||
DECLARE @dataRif DATETIME
|
||||
-- carico dati
|
||||
SET @trovate = ISNULL( ( SELECT COUNT(*) FROM TimbratureExpl te INNER JOIN inserted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav) ,0)
|
||||
SELECT @idxDipendente = idxDipendente, @dataRif=dataLav FROM inserted
|
||||
IF(@trovate = 0)
|
||||
BEGIN
|
||||
EXEC stp_ricalcolaTimbratureExpl @idxDipendente, @dataRif
|
||||
END
|
||||
|
||||
-- CONTROLLO SE IL RECORD NON SIA BLOCCATO con where nell'update
|
||||
-- prendo tutte le "vecchie" righe (deleted) e x le giornate relative TOLGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust='MAL' THEN 0 ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN 0 ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN 0 ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN 0 ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN deleted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
WHERE te.block = 0
|
||||
|
||||
-- prendo le "nuove" righe (inserted) e x le giornate relative AGGIUNGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust='MAL' THEN g.minuti ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN g.minuti ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN g.minuti ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN g.minuti ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN inserted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
WHERE te.block = 0
|
||||
|
||||
-- verifico SE codice orario richieda una chkFun eseguo calcolo...
|
||||
IF(dbo.f_chkFunDip(@idxDipendente)<>'')
|
||||
BEGIN
|
||||
EXEC stp_TE_doChkFun @idxDipendente, @dataRif
|
||||
END
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* Trigger su delete
|
||||
*
|
||||
* Aggiorna giustificativi nella tab TimbratureExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2012.12.04
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
alter TRIGGER trg_giustDelUpdTimbr
|
||||
ON Giustificativi
|
||||
FOR DELETE
|
||||
AS
|
||||
|
||||
-- controllo se rescord esista altrimenti lo creo!!!
|
||||
DECLARE @trovate INT = 0
|
||||
DECLARE @idxDipendente INT
|
||||
DECLARE @dataRif DATETIME
|
||||
-- carico dati
|
||||
SELECT @idxDipendente = idxDipendente, @dataRif=dataLav FROM deleted
|
||||
|
||||
-- CONTROLLO SE IL RECORD NON SIA BLOCCATO in update con where
|
||||
-- prendo tutte le "vecchie" righe (deleted) e x le giornate relative TOLGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust='MAL' THEN 0 ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN 0 ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN 0 ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN 0 ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN deleted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
WHERE te.block = 0
|
||||
|
||||
-- verifico SE codice orario richieda una chkFun eseguo calcolo...
|
||||
IF(dbo.f_chkFunDip(@idxDipendente)<>'')
|
||||
BEGIN
|
||||
EXEC stp_TE_doChkFun @idxDipendente, @dataRif
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*************************************************
|
||||
* STORED PROCEDURE stp_giust_insertQuery
|
||||
*
|
||||
* Aggiunge un giustificativo NUOVO
|
||||
* mod: S.E.L. - 2013.04.03
|
||||
**************************************************/
|
||||
create PROCEDURE stp_giust_insertQuery
|
||||
(
|
||||
@dataLav date,
|
||||
@idxDipendente int,
|
||||
@codGiust nvarchar(5),
|
||||
@minuti int
|
||||
)
|
||||
AS
|
||||
|
||||
INSERT INTO Giustificativi (dataLav, idxDipendente, codGiust, minuti)
|
||||
VALUES (@dataLav, @idxDipendente, @codGiust, @minuti)
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*************************************************
|
||||
* STORED PROCEDURE stp_giust_insByDate
|
||||
*
|
||||
* Aggiunge un giustificativo per coprire la durata necessaria a chiudere la giornata indicata
|
||||
* mod: S.E.L. - 2012.12.10
|
||||
**************************************************/
|
||||
alter PROCEDURE stp_giust_insByDate
|
||||
(
|
||||
@idxDipendente INT = 0,
|
||||
@dataRif DATETIME,
|
||||
@codGiust NVARCHAR(5) = 'PERM'
|
||||
)
|
||||
AS
|
||||
|
||||
BEGIN TRAN
|
||||
|
||||
DECLARE @minPerm INT = 0 -- min necessari x chiudere giornata
|
||||
DECLARE @isPP BIT = 0
|
||||
|
||||
SELECT @isPP = CASE WHEN ISNULL(chkFunCod,'')='P' THEN 1 ELSE 0 END FROM TimbratureExpl WHERE idxDipendente=@idxDipendente AND dataLav=@dataRif
|
||||
|
||||
IF(@isPP=1)
|
||||
BEGIN
|
||||
-- recupero tipo di fuction da usare
|
||||
DECLARE @chkFun NVARCHAR(50) = ''
|
||||
DECLARE @minPP INT = 0
|
||||
|
||||
-- imposto variabili
|
||||
SELECT @chkFun = dbo.f_chkFunDip(@idxDipendente), @codGiust = 'PERM'
|
||||
|
||||
-- controllo tipo di funzione... e imposto risultato!
|
||||
IF(@chkFun = 'PP60m')
|
||||
BEGIN
|
||||
SET @minPP = 60
|
||||
END
|
||||
ELSE IF(@chkFun = 'PP30m')
|
||||
BEGIN
|
||||
SET @minPP = 30
|
||||
END
|
||||
-- calcolo quota permesso
|
||||
SELECT @minPerm = @minPP - (minArcoPres - minLav)
|
||||
FROM TimbratureExpl
|
||||
WHERE idxDipendente = @idxDipendente AND dataLav = @dataRif
|
||||
|
||||
-- INSERT giustificativo!
|
||||
INSERT INTO Giustificativi
|
||||
VALUES (@dataRif,@idxDipendente,@codGiust,@minPerm,1)
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
-- variabili
|
||||
DECLARE @minArr INT
|
||||
--SELECT @minArr=dbo.f_minArrotDip(@idxDipendente)
|
||||
SELECT @minArr = ISNULL(valInt,1) FROM AnagKeyValue WHERE nomeVar = 'minutiRoundDay'
|
||||
|
||||
-- calcolo minuti
|
||||
SELECT @minPerm = (CEILING(CONVERT(FLOAT,minOrd-minLav)/@minArr)*@minArr)
|
||||
FROM TimbratureExpl
|
||||
WHERE isOkLav = 0
|
||||
AND idxDipendente = @idxDipendente
|
||||
AND dataLav = @dataRif
|
||||
|
||||
-- INSERT giustificativo!
|
||||
INSERT INTO Giustificativi
|
||||
VALUES (@dataRif,@idxDipendente,@codGiust,@minPerm,1)
|
||||
END
|
||||
COMMIT TRAN
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*******************************************************************************
|
||||
* STORED PROCEDURE stp_TE_doChkFun
|
||||
*
|
||||
* effettua check finali sulla riga di timbrature esplore indicata, contiene varie logiche
|
||||
* anche da + installazioni clienti
|
||||
*
|
||||
* mod: S.E.L. 2013.03.28
|
||||
*
|
||||
*******************************************************************************/
|
||||
alter PROCEDURE stp_TE_doChkFun
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
|
||||
|
||||
-- recupero tipo di fuction da usare
|
||||
DECLARE @chkFun NVARCHAR(50) = ''
|
||||
DECLARE @chkFunCod NVARCHAR(50) = ''
|
||||
DECLARE @chkFunRes NVARCHAR(50) = ''
|
||||
DECLARE @minPP INT = 0
|
||||
|
||||
SELECT @chkFun = dbo.f_chkFunDip(@idxDipendente)
|
||||
-- controllo tipo di funzione... e imposto risultato!
|
||||
IF(@chkFun = 'PP60m')
|
||||
BEGIN
|
||||
SELECT @minPP = 60, @chkFunCod = 'P', @chkFunRes = 'Mancata pausa pranzo 60m'
|
||||
END
|
||||
ELSE IF(@chkFun = 'PP30m')
|
||||
BEGIN
|
||||
SELECT @minPP = 30, @chkFunCod = 'P', @chkFunRes = 'Mancata pausa pranzo 30m'
|
||||
END
|
||||
|
||||
-- se c'è check da fare faccio COMUNQUE update!
|
||||
IF(@chkFun <>'')
|
||||
BEGIN
|
||||
UPDATE TimbratureExpl
|
||||
SET chkFunCod = CASE WHEN (minArcoPres - minLav) < @minPP - minPerm THEN @chkFunCod ELSE '' END, -- chk pause > PP imposta (- minuti permesso caricati)
|
||||
chkFunRes = CASE WHEN (minArcoPres - minLav) < @minPP - minPerm THEN @chkFunRes ELSE '' END -- chk pause > PP imposta (- minuti permesso caricati)
|
||||
WHERE idxDipendente = @idxDipendente AND dataLav = @dataRif
|
||||
AND (minOrd > 0 AND minLav > 0) -- controllo DEBBA lavorare e ABBIA lavorato
|
||||
AND block = 0 -- controllo NON sia bloccato
|
||||
END
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(327, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,417 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* Trigger su insert/update
|
||||
*
|
||||
* Aggiorna giustificativi nella tab TimbratureExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2012.12.04
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
alter TRIGGER trg_giustUpdateTimbr
|
||||
ON Giustificativi
|
||||
FOR INSERT, UPDATE
|
||||
AS
|
||||
|
||||
-- controllo se rescord esista altrimenti lo creo!!!
|
||||
DECLARE @trovate INT = 0
|
||||
DECLARE @idxDipendente INT
|
||||
DECLARE @dataRif DATETIME
|
||||
-- carico dati
|
||||
SET @trovate = ISNULL( ( SELECT COUNT(*) FROM TimbratureExpl te INNER JOIN inserted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav) ,0)
|
||||
SELECT @idxDipendente = idxDipendente, @dataRif=dataLav FROM inserted
|
||||
IF(@trovate = 0)
|
||||
BEGIN
|
||||
EXEC stp_ricalcolaTimbratureExpl @idxDipendente, @dataRif
|
||||
END
|
||||
|
||||
-- CONTROLLO SE IL RECORD NON SIA BLOCCATO con where nell'update
|
||||
-- prendo tutte le "vecchie" righe (deleted) e x le giornate relative TOLGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust IN('MAL','MAT','INF') THEN 0 ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN 0 ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN 0 ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN 0 ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN deleted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
WHERE te.block = 0
|
||||
|
||||
-- prendo le "nuove" righe (inserted) e x le giornate relative AGGIUNGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust IN('MAL','MAT','INF') THEN g.minuti ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN g.minuti ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN g.minuti ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN g.minuti ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN inserted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
WHERE te.block = 0
|
||||
|
||||
-- verifico SE codice orario richieda una chkFun eseguo calcolo...
|
||||
IF(dbo.f_chkFunDip(@idxDipendente)<>'')
|
||||
BEGIN
|
||||
EXEC stp_TE_doChkFun @idxDipendente, @dataRif
|
||||
END
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* Trigger su delete
|
||||
*
|
||||
* Aggiorna giustificativi nella tab TimbratureExpl
|
||||
*
|
||||
* creato da: S.E. Locatelli - 2012.12.04
|
||||
* ultima modifica:
|
||||
*----------------------------------*/
|
||||
alter TRIGGER trg_giustDelUpdTimbr
|
||||
ON Giustificativi
|
||||
FOR DELETE
|
||||
AS
|
||||
|
||||
-- controllo se rescord esista altrimenti lo creo!!!
|
||||
DECLARE @trovate INT = 0
|
||||
DECLARE @idxDipendente INT
|
||||
DECLARE @dataRif DATETIME
|
||||
-- carico dati
|
||||
SELECT @idxDipendente = idxDipendente, @dataRif=dataLav FROM deleted
|
||||
|
||||
-- CONTROLLO SE IL RECORD NON SIA BLOCCATO in update con where
|
||||
-- prendo tutte le "vecchie" righe (deleted) e x le giornate relative TOLGO i minuti dei giustificativi
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust IN('MAL','MAT','INF') THEN 0 ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN 0 ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN 0 ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN 0 ELSE minPerm END
|
||||
FROM TimbratureExpl te INNER JOIN deleted g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
WHERE te.block = 0
|
||||
|
||||
-- verifico SE codice orario richieda una chkFun eseguo calcolo...
|
||||
IF(dbo.f_chkFunDip(@idxDipendente)<>'')
|
||||
BEGIN
|
||||
EXEC stp_TE_doChkFun @idxDipendente, @dataRif
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*******************************************************************************
|
||||
* stp_ricalcolaTimbratureExpl
|
||||
*
|
||||
* Aggiorna la tab timbrature expl ricalcolando la giornata del record interessato
|
||||
* mod: S.E.L. - 2012.02.06
|
||||
********************************************************************************/
|
||||
alter PROCEDURE stp_ricalcolaTimbratureExpl
|
||||
(
|
||||
@idxDipendente AS INT,
|
||||
@dataRif AS DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
-- variabili
|
||||
DECLARE @minArr INT
|
||||
SELECT @minArr=dbo.f_minArrotDip(@idxDipendente)
|
||||
|
||||
-- CONTROLLO SE IL RECORD NON SIA BLOCCATO!!!
|
||||
DECLARE @block BIT
|
||||
SET @block = ( SELECT ISNULL(( SELECT block FROM TimbratureExpl WHERE (idxDipendente = @idxDipendente) AND CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif) ),0) )
|
||||
IF(@block = 0)
|
||||
BEGIN
|
||||
-- elimino i periodi della data indicata...
|
||||
DELETE FROM TimbratureExpl
|
||||
WHERE (idxDipendente = @idxDipendente) AND CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)
|
||||
|
||||
-- inserisco i dati minimi per la data indicata
|
||||
INSERT INTO TimbratureExpl(idxDipendente, dataLav)
|
||||
VALUES(@idxDipendente, CONVERT(DATE,@dataRif))
|
||||
|
||||
-- aggiorno cognome nome
|
||||
BEGIN TRY
|
||||
UPDATE te
|
||||
SET CognomeNome = ISNULL(vcn.CognomeNome,'')
|
||||
FROM TimbratureExpl te INNER JOIN v_cognomeNome vcn ON te.idxDipendente = vcn.idxDipendente
|
||||
WHERE CONVERT(DATE,te.dataLav) = CONVERT(DATE,@dataRif) AND te.idxDipendente = @idxDipendente
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
-- non faccio nulla
|
||||
END CATCH
|
||||
|
||||
-- aggiorno 1° timbratura
|
||||
UPDATE te
|
||||
SET te.entrata_1 = pl.entrata,
|
||||
te.uscita_1 = pl.uscita
|
||||
FROM TimbratureExpl te INNER JOIN PeriodiLav pl ON
|
||||
te.idxDipendente = pl.idxDipendente AND
|
||||
(CONVERT(DATE,te.dataLav) = CONVERT(DATE,pl.entrata))
|
||||
WHERE pl.rowNum = 1 AND te.idxDipendente = @idxDipendente AND CONVERT(DATE,pl.entrata) = CONVERT(DATE,@dataRif)
|
||||
|
||||
-- aggiorno 2° timbratura
|
||||
UPDATE te
|
||||
SET te.entrata_2 = pl.entrata,
|
||||
te.uscita_2 = pl.uscita
|
||||
FROM TimbratureExpl te INNER JOIN PeriodiLav pl ON te.idxDipendente = pl.idxDipendente
|
||||
AND (CONVERT(DATE,te.dataLav) = CONVERT(DATE,pl.entrata))
|
||||
WHERE pl.rowNum = 2 AND te.idxDipendente = @idxDipendente AND CONVERT(DATE,pl.entrata) = CONVERT(DATE,@dataRif)
|
||||
|
||||
-- aggiorno 3° timbratura
|
||||
UPDATE te
|
||||
SET te.entrata_3 = pl.entrata,
|
||||
te.uscita_3 = pl.uscita
|
||||
FROM TimbratureExpl te INNER JOIN PeriodiLav pl ON te.idxDipendente = pl.idxDipendente
|
||||
AND (CONVERT(DATE,te.dataLav) =CONVERT(DATE,pl.entrata))
|
||||
WHERE pl.rowNum = 3 AND te.idxDipendente = @idxDipendente AND CONVERT(DATE,pl.entrata) = CONVERT(DATE,@dataRif)
|
||||
|
||||
-- aggiorno 4° timbratura
|
||||
UPDATE te
|
||||
SET te.entrata_4 = pl.entrata,
|
||||
te.uscita_4 = pl.uscita
|
||||
FROM TimbratureExpl te INNER JOIN PeriodiLav pl ON te.idxDipendente = pl.idxDipendente
|
||||
AND (CONVERT(DATE,te.dataLav) =CONVERT(DATE,pl.entrata))
|
||||
WHERE pl.rowNum = 4 AND te.idxDipendente = @idxDipendente AND CONVERT(DATE,pl.entrata) = CONVERT(DATE,@dataRif)
|
||||
|
||||
-- calcolo ore totali...
|
||||
UPDATE TimbratureExpl
|
||||
SET h_lav = CAST(FLOOR((ISNULL(DATEDIFF(n,entrata_1,uscita_1),0) + ISNULL(DATEDIFF(n,entrata_2,uscita_2),0) + ISNULL(DATEDIFF(n,entrata_3,uscita_3),0) + ISNULL(DATEDIFF(n,entrata_4,uscita_4),0))/@minArr) AS FLOAT)*@minArr/60
|
||||
FROM TimbratureExpl
|
||||
WHERE (CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)) AND idxDipendente = @idxDipendente
|
||||
|
||||
-- verifico: se c'è anche solo 1 timbratura non approvata metto flag isOkApp a falso
|
||||
UPDATE TimbratureExpl
|
||||
SET isOkApp = ISNULL((
|
||||
SELECT MIN(CASE WHEN Approv=0 THEN 0 ELSE 1 END) AS isOk
|
||||
FROM Timbrature
|
||||
WHERE idxDipendente = @idxDipendente
|
||||
AND (CONVERT(DATE,dataOra) = CONVERT(DATE,@dataRif))
|
||||
GROUP BY CONVERT(DATE,dataOra)
|
||||
),1)
|
||||
FROM TimbratureExpl
|
||||
WHERE (CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)) AND idxDipendente = @idxDipendente
|
||||
|
||||
-- verifico: se entrate <> uscite flag isOkTim a falso
|
||||
UPDATE TimbratureExpl
|
||||
SET isOkTim = (
|
||||
SELECT CASE WHEN
|
||||
ISNULL(
|
||||
(SELECT COUNT(*) as timb
|
||||
FROM Timbrature AS t
|
||||
WHERE t.idxDipendente = @idxDipendente
|
||||
AND (CONVERT(DATE,dataOra) = CONVERT(DATE,@dataRif))
|
||||
GROUP BY t.idxDipendente , CONVERT(DATE,t.dataOra)
|
||||
HAVING COUNT ( CASE Entrata WHEN 1 THEN dataOra END ) <> COUNT ( CASE Entrata WHEN 0 THEN dataOra END )
|
||||
),0) > 0 THEN 0 ELSE 1 END
|
||||
)
|
||||
FROM TimbratureExpl
|
||||
WHERE (CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)) AND idxDipendente = @idxDipendente
|
||||
|
||||
-- calcolo resoconto MINUTI giornaliero, imposto LUN x inizio settimana
|
||||
SET DATEFIRST 1
|
||||
|
||||
-- MIN lavorati, ordinari (con arrotondamento...)
|
||||
UPDATE TimbratureExpl
|
||||
SET minLav = CAST((ISNULL(DATEDIFF(n,entrata_1,uscita_1),0) + ISNULL(DATEDIFF(n,entrata_2,uscita_2),0) + ISNULL(DATEDIFF(n,entrata_3,uscita_3),0) + ISNULL(DATEDIFF(n,entrata_4,uscita_4),0)) AS FLOAT)
|
||||
,minOrd = dbo.f_oreOrdDip(idxDipendente,dataLav) * 60 -- da schema orario dip attivo
|
||||
FROM TimbratureExpl
|
||||
WHERE (CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)) AND idxDipendente = @idxDipendente
|
||||
|
||||
-- MIN non lavorati, straordinari (con arrotondamento...)
|
||||
UPDATE TimbratureExpl
|
||||
SET minNonLav = (CEILING(CONVERT(FLOAT,CASE WHEN minOrd <= minLav THEN (0) ELSE minOrd-minLav END)/@minArr)*@minArr)
|
||||
,minStra = (FLOOR(CONVERT(FLOAT,CASE WHEN minOrd < minLav AND minLav > (0) THEN minLav-minOrd ELSE (0) END)/@minArr)*@minArr)
|
||||
FROM TimbratureExpl
|
||||
WHERE (CONVERT(DATE,dataLav) = CONVERT(DATE,@dataRif)) AND idxDipendente = @idxDipendente
|
||||
|
||||
|
||||
-- MIN da tab giustificativi (feste, ferie, malattia, permessi)
|
||||
UPDATE TimbratureExpl
|
||||
SET minMal = CASE WHEN g.codGiust IN('MAL','MAT','INF') THEN g.minuti ELSE minMal END,
|
||||
minFer = CASE WHEN g.codGiust='FER' THEN g.minuti ELSE minFer END,
|
||||
minFest = CASE WHEN g.codGiust='FEST' THEN g.minuti ELSE minFest END,
|
||||
minPerm = CASE WHEN g.codGiust='PERM' THEN g.minuti ELSE minPerm END,
|
||||
chkFunCod = '',
|
||||
chkFunRes = ''
|
||||
FROM TimbratureExpl te INNER JOIN Giustificativi g ON te.idxDipendente = g.idxDipendente AND te.dataLav = g.dataLav
|
||||
WHERE (CONVERT(DATE,te.dataLav) = CONVERT(DATE,@dataRif)) AND te.idxDipendente = @idxDipendente
|
||||
|
||||
-- verifico SE codice orario richieda una chkFun eseguo calcolo...
|
||||
IF(dbo.f_chkFunDip(@idxDipendente)<>'')
|
||||
BEGIN
|
||||
EXEC stp_TE_doChkFun @idxDipendente, @dataRif
|
||||
END
|
||||
|
||||
END
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*************************************************
|
||||
* STORED PROCEDURE stp_giust_insByDate
|
||||
*
|
||||
* Aggiunge un giustificativo per coprire la durata necessaria a chiudere la giornata indicata
|
||||
* mod: S.E.L. - 2012.12.10
|
||||
**************************************************/
|
||||
alter PROCEDURE stp_giust_insByDate
|
||||
(
|
||||
@idxDipendente INT = 0,
|
||||
@dataRif DATETIME,
|
||||
@codGiust NVARCHAR(5) = 'PERM'
|
||||
)
|
||||
AS
|
||||
|
||||
BEGIN TRAN
|
||||
|
||||
DECLARE @minPerm INT = 0 -- min necessari x chiudere giornata
|
||||
DECLARE @isPP BIT = 0
|
||||
|
||||
SELECT @isPP = CASE WHEN ISNULL(chkFunCod,'')='P' THEN 1 ELSE 0 END FROM TimbratureExpl WHERE idxDipendente=@idxDipendente AND dataLav=@dataRif
|
||||
|
||||
IF(@isPP=1)
|
||||
BEGIN
|
||||
-- recupero tipo di fuction da usare
|
||||
DECLARE @chkFun NVARCHAR(50) = ''
|
||||
DECLARE @minPP INT = 0
|
||||
|
||||
-- imposto variabili
|
||||
SELECT @chkFun = dbo.f_chkFunDip(@idxDipendente), @codGiust = 'PERM'
|
||||
|
||||
-- controllo tipo di funzione... e imposto risultato!
|
||||
/*
|
||||
IF(@chkFun = 'PP60m')
|
||||
BEGIN
|
||||
SET @minPP = 60
|
||||
END
|
||||
ELSE IF(@chkFun = 'PP30m')
|
||||
BEGIN
|
||||
SET @minPP = 30
|
||||
END
|
||||
*/
|
||||
IF(@chkFun LIKE 'PP%m')
|
||||
BEGIN
|
||||
SELECT @minPP=REPLACE(REPLACE(@chkFun,'PP',''),'m','')
|
||||
END
|
||||
-- calcolo quota permesso
|
||||
SELECT @minPerm = @minPP - (minArcoPres - minLav)
|
||||
FROM TimbratureExpl
|
||||
WHERE idxDipendente = @idxDipendente AND dataLav = @dataRif
|
||||
|
||||
-- INSERT giustificativo!
|
||||
INSERT INTO Giustificativi
|
||||
VALUES (@dataRif,@idxDipendente,@codGiust,@minPerm,1)
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
-- variabili
|
||||
DECLARE @minArr INT
|
||||
--SELECT @minArr=dbo.f_minArrotDip(@idxDipendente)
|
||||
SELECT @minArr = ISNULL(valInt,1) FROM AnagKeyValue WHERE nomeVar = 'minutiRoundDay'
|
||||
|
||||
-- calcolo minuti
|
||||
SELECT @minPerm = (CEILING(CONVERT(FLOAT,minOrd-minLav)/@minArr)*@minArr)
|
||||
FROM TimbratureExpl
|
||||
WHERE isOkLav = 0
|
||||
AND idxDipendente = @idxDipendente
|
||||
AND dataLav = @dataRif
|
||||
|
||||
-- INSERT giustificativo!
|
||||
INSERT INTO Giustificativi
|
||||
VALUES (@dataRif,@idxDipendente,@codGiust,@minPerm,1)
|
||||
END
|
||||
COMMIT TRAN
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
/*******************************************************************************
|
||||
* STORED PROCEDURE stp_TE_doChkFun
|
||||
*
|
||||
* effettua check finali sulla riga di timbrature esplore indicata, contiene varie logiche
|
||||
* anche da + installazioni clienti
|
||||
*
|
||||
* mod: S.E.L. 2013.03.28
|
||||
*
|
||||
*******************************************************************************/
|
||||
alter PROCEDURE stp_TE_doChkFun
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME
|
||||
)
|
||||
AS
|
||||
SET NOCOUNT ON;
|
||||
|
||||
|
||||
-- recupero tipo di fuction da usare
|
||||
DECLARE @chkFun NVARCHAR(50) = ''
|
||||
DECLARE @chkFunCod NVARCHAR(50) = ''
|
||||
DECLARE @chkFunRes NVARCHAR(50) = ''
|
||||
DECLARE @minPP INT = 0
|
||||
|
||||
SELECT @chkFun = dbo.f_chkFunDip(@idxDipendente)
|
||||
-- controllo tipo di funzione... e imposto risultato!
|
||||
/*
|
||||
IF(@chkFun = 'PP60m')
|
||||
BEGIN
|
||||
SELECT @minPP = 60, @chkFunCod = 'P', @chkFunRes = 'Mancata pausa pranzo 60m'
|
||||
END
|
||||
ELSE IF(@chkFun = 'PP30m')
|
||||
BEGIN
|
||||
SELECT @minPP = 30, @chkFunCod = 'P', @chkFunRes = 'Mancata pausa pranzo 30m'
|
||||
END
|
||||
*/
|
||||
IF(@chkFun LIKE 'PP%m')
|
||||
BEGIN
|
||||
SELECT @minPP=REPLACE(REPLACE(@chkFun,'PP',''),'m',''), @chkFunCod = 'P'
|
||||
SELECT @chkFunRes = 'Mancata pausa pranzo ' + CAST(@minPP AS NVARCHAR) + 'm'
|
||||
END
|
||||
|
||||
-- se c'è check da fare faccio COMUNQUE update!
|
||||
IF(@chkFun <>'')
|
||||
BEGIN
|
||||
UPDATE TimbratureExpl
|
||||
SET chkFunCod = CASE WHEN (minArcoPres - minLav) < @minPP - minPerm THEN @chkFunCod ELSE '' END, -- chk pause > PP imposta (- minuti permesso caricati)
|
||||
chkFunRes = CASE WHEN (minArcoPres - minLav) < @minPP - minPerm THEN @chkFunRes ELSE '' END -- chk pause > PP imposta (- minuti permesso caricati)
|
||||
WHERE idxDipendente = @idxDipendente AND dataLav = @dataRif
|
||||
AND (minOrd > 0 AND minLav > 0) -- controllo DEBBA lavorare e ABBIA lavorato
|
||||
AND block = 0 -- controllo NON sia bloccato
|
||||
END
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(328, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,69 @@
|
||||
-- richiama update x sistemazione voci PERM --> MPP
|
||||
|
||||
BEGIN TRAN ;
|
||||
|
||||
WITH cte as (
|
||||
SELECT g.dataLav
|
||||
,g.idxDipendente
|
||||
,codGiust
|
||||
,minuti
|
||||
,automatico
|
||||
,dbo.f_chkFunDip(g.idxDipendente) AS chk
|
||||
,dbo.f_chkFunDipMin(g.idxDipendente,g.dataLav,'MPP') AS minChk -- calcolo gli eventuali minuti MPP
|
||||
,t.minArcoPres
|
||||
,t.minLav
|
||||
,t.minArcoPres-t.minLav as chkDiff
|
||||
FROM dbo.Giustificativi AS g
|
||||
LEFT JOIN TimbratureExpl AS t ON g.idxDipendente = t.idxDipendente AND g.dataLav = t.dataLav
|
||||
WHERE codGiust = 'PERM'
|
||||
AND minuti <= 60
|
||||
AND dbo.f_chkFunDip(g.idxDipendente) <> ''
|
||||
AND minuti = dbo.f_chkFunDipMin(g.idxDipendente,g.dataLav,'MPP')
|
||||
)
|
||||
UPDATE dbo.Giustificativi
|
||||
SET codGiust = 'MPP'
|
||||
FROM dbo.Giustificativi AS g
|
||||
INNER JOIN cte ON g.idxDipendente = cte.idxDipendente
|
||||
AND g.dataLav = cte.dataLav
|
||||
AND g.codGiust = 'PERM'
|
||||
AND g.minuti = cte.minuti
|
||||
|
||||
-- test
|
||||
SELECT g.dataLav
|
||||
,g.idxDipendente
|
||||
,codGiust
|
||||
,minuti
|
||||
,automatico
|
||||
,dbo.f_chkFunDip(g.idxDipendente)
|
||||
,dbo.f_chkFunDipMin(g.idxDipendente,g.dataLav,'MPP') -- calcolo gli eventuali minuti MPP
|
||||
,t.minArcoPres
|
||||
,t.minLav
|
||||
,t.minArcoPres-t.minLav
|
||||
FROM dbo.Giustificativi AS g
|
||||
LEFT JOIN TimbratureExpl AS t ON g.idxDipendente = t.idxDipendente AND g.dataLav = t.dataLav
|
||||
WHERE codGiust = 'MPP'
|
||||
AND minuti <= 60
|
||||
AND dbo.f_chkFunDip(g.idxDipendente) <> ''
|
||||
AND minuti = dbo.f_chkFunDipMin(g.idxDipendente,g.dataLav,'MPP')
|
||||
|
||||
COMMIT
|
||||
|
||||
|
||||
-- ricalcolo giornate
|
||||
|
||||
DECLARE @RC int
|
||||
DECLARE @idxDipendente int
|
||||
DECLARE @inizio datetime
|
||||
DECLARE @fine datetime
|
||||
|
||||
|
||||
EXECUTE @RC = [dbo].[stp_ricalcolaTimbExpl_byPeriodoUser]
|
||||
0
|
||||
,'20130301'
|
||||
,'20130501'
|
||||
GO
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(330, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,381 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
alter table TimbratureExpl drop
|
||||
constraint DF_TimbratureExpl_minOrd ,
|
||||
constraint DF_TimbratureExpl_minLav ,
|
||||
constraint DF_TimbratureExpl_minNonLav ,
|
||||
constraint DF_TimbratureExpl_minStra ,
|
||||
constraint DF_TimbratureExpl_minPerm ,
|
||||
constraint DF_TimbratureExpl_minFer ,
|
||||
constraint DF_TimbratureExpl_minMal ,
|
||||
constraint DF_TimbratureExpl_minFest ,
|
||||
constraint DF_TimbratureExpl_minMpp ,
|
||||
constraint DF_TimbratureExpl_isOkTim ,
|
||||
constraint DF_TimbratureExpl_chkFunRes ,
|
||||
constraint DF_TimbratureExpl_chkFunCod ,
|
||||
constraint DF_TimbratureExpl_block ,
|
||||
constraint DF_TimbratureExpl_isOk ;
|
||||
go
|
||||
|
||||
exec sp_rename 'PK_TimbratureExpl_1', 'tmp__PK_TimbratureExpl_1', 'OBJECT';
|
||||
go
|
||||
|
||||
exec sp_rename 'TimbratureExpl', 'tmp__TimbratureExpl_0', 'OBJECT';
|
||||
go
|
||||
|
||||
create table TimbratureExpl(
|
||||
dataLav date not null,
|
||||
idxDipendente int not null,
|
||||
CognomeNome nvarchar(100),
|
||||
entrata_1 datetime,
|
||||
uscita_1 datetime,
|
||||
entrata_2 datetime,
|
||||
uscita_2 datetime,
|
||||
entrata_3 datetime,
|
||||
uscita_3 datetime,
|
||||
entrata_4 datetime,
|
||||
uscita_4 datetime,
|
||||
h_lav float,
|
||||
h_giust as (((((CONVERT([float],[minPerm],(0))+[minFer])+[minMal])+[minFest])+[minMpp])/(60)),
|
||||
minLav int constraint DF_TimbratureExpl_minLav default ((0)),
|
||||
minOrd int constraint DF_TimbratureExpl_minOrd default ((0)),
|
||||
minNonLav int constraint DF_TimbratureExpl_minNonLav default ((0)),
|
||||
minStra int constraint DF_TimbratureExpl_minStra default ((0)),
|
||||
minPerm int constraint DF_TimbratureExpl_minPerm default ((0)),
|
||||
minFer int not null constraint DF_TimbratureExpl_minFer default ((0)),
|
||||
minMal int constraint DF_TimbratureExpl_minMal default ((0)),
|
||||
minFest int constraint DF_TimbratureExpl_minFest default ((0)),
|
||||
minMpp int constraint DF_TimbratureExpl_minMpp default ((0)),
|
||||
minArcoPres as (datediff(minute,isnull([entrata_1],getdate()),isnull(isnull([uscita_4],isnull([uscita_3],isnull([uscita_2],isnull([uscita_1],[entrata_1])))),getdate()))),
|
||||
isOkTim bit constraint DF_TimbratureExpl_isOkTim default ((0)),
|
||||
isOkApp bit constraint DF_TimbratureExpl_isOk default ((1)),
|
||||
isOkLav as (case when [minOrd]<=((((([minLav]+[minPerm])+[minFer])+[minMal])+[minFest])+[minMpp]) then (1) else (0) end),
|
||||
isOk as (([isOkTim]&[isOkApp])&case when [minOrd]<=((((([minLav]+[minPerm])+[minFer])+[minMal])+[minFest])+[minMpp]) then (1) else (0) end),
|
||||
block bit constraint DF_TimbratureExpl_block default ((0)),
|
||||
chkFunCod nvarchar(50) constraint DF_TimbratureExpl_chkFunCod default (''),
|
||||
chkFunRes nvarchar(50) constraint DF_TimbratureExpl_chkFunRes default (''),
|
||||
|
||||
constraint PK_TimbratureExpl_1 primary key(dataLav,idxDipendente)
|
||||
);
|
||||
go
|
||||
|
||||
create index ix_idxDip on TimbratureExpl(idxDipendente)
|
||||
include(dataLav,CognomeNome,h_lav,minOrd,minStra,minPerm,minFer,block,isOkApp,isOkTim);
|
||||
go
|
||||
|
||||
create index ix_TimbrExpl_CognomeNome_DataLav on TimbratureExpl(CognomeNome,dataLav);
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'totale ore giustificate', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'h_giust';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'minuti non lavorati (ovvero se fatti meno di ordinari e senza giustificativi)', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'minNonLav';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'DATEDIFF(n, ISNULL(entrata_1,GETDATE()), ISNULL(ISNULL(uscita_4,ISNULL(uscita_3,ISNULL(uscita_2,ISNULL(uscita_1,entrata_1)))),GETDATE()))', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'minArcoPres';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'dato sintetico x indicare se TUTTE le timbrature componenti siano approvate', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'isOkApp';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'determina se la giornata sia ok (oreLav + giustificativi >= oreOrd)', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'isOkLav';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'determina se il record sia "bloccato" (archiviazione e blocco mesi precedenti...)', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'block';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'eventuale diagnostica da check function sulla riga indicata (codice)', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'chkFunCod';
|
||||
go
|
||||
|
||||
exec sp_addextendedproperty 'MS_Description', 'eventuale diagnostica da check function sulla riga indicata (spiegazione)', 'SCHEMA', 'dbo', 'TABLE', 'TimbratureExpl', 'COLUMN', 'chkFunRes';
|
||||
go
|
||||
|
||||
insert into TimbratureExpl(dataLav,idxDipendente,CognomeNome,entrata_1,uscita_1,entrata_2,uscita_2,entrata_3,uscita_3,entrata_4,uscita_4,h_lav,minLav,minOrd,minNonLav,minStra,minPerm,minFer,minMal,minFest,minMpp,isOkTim,isOkApp,block,chkFunCod,chkFunRes) select dataLav,idxDipendente,CognomeNome,entrata_1,uscita_1,entrata_2,uscita_2,entrata_3,uscita_3,entrata_4,uscita_4,h_lav,minLav,minOrd,minNonLav,minStra,minPerm,minFer,minMal,minFest,minMpp,isOkTim,isOkApp,block,chkFunCod,chkFunRes from tmp__TimbratureExpl_0;
|
||||
go
|
||||
|
||||
drop table tmp__TimbratureExpl_0;
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
alter PROCEDURE stp_giust_insByDate
|
||||
(
|
||||
@idxDipendente INT = 0,
|
||||
@dataRif DATETIME,
|
||||
@codGiust NVARCHAR(5) = 'PERM'
|
||||
)
|
||||
AS
|
||||
-- =============================================
|
||||
-- Description: QUANDO VIENE USATA ???
|
||||
-- SE c'è anomalia MPP entra sempre in gestione anomalia MPP per prima cosa
|
||||
-- =============================================
|
||||
DECLARE @minPerm INT = 0 -- min necessari x chiudere giornata
|
||||
DECLARE @isPP BIT = 0
|
||||
|
||||
SELECT @isPP = CASE WHEN ISNULL(chkFunCod,'')='P' THEN 1 ELSE 0 END
|
||||
FROM TimbratureExpl WHERE idxDipendente=@idxDipendente AND dataLav=@dataRif
|
||||
|
||||
BEGIN TRAN -- ???? MA SERVE ???
|
||||
|
||||
IF(@isPP=1) -- se carico mancata pausa pranzo
|
||||
BEGIN
|
||||
-- recupero tipo di fuction da usare
|
||||
DECLARE @chkFun NVARCHAR(50) = ''
|
||||
DECLARE @minPP INT = 0
|
||||
|
||||
-- imposto variabili
|
||||
SELECT @chkFun = dbo.f_chkFunDip(@idxDipendente), @codGiust = 'MPP' -- mancata pausa pranzo
|
||||
|
||||
-- controllo tipo di funzione... e imposto risultato!
|
||||
/*
|
||||
IF(@chkFun = 'PP60m')
|
||||
BEGIN
|
||||
SET @minPP = 60
|
||||
END
|
||||
ELSE IF(@chkFun = 'PP30m')
|
||||
BEGIN
|
||||
SET @minPP = 30
|
||||
END
|
||||
*/
|
||||
IF(@chkFun LIKE 'PP%m')
|
||||
BEGIN
|
||||
SELECT @minPP=REPLACE(REPLACE(@chkFun,'PP',''),'m','')
|
||||
END
|
||||
-- calcolo quota permesso
|
||||
SELECT @minPerm = @minPP - (minArcoPres - minLav )
|
||||
FROM TimbratureExpl
|
||||
WHERE idxDipendente = @idxDipendente AND dataLav = @dataRif
|
||||
|
||||
-- INSERT giustificativo mancata pausa pranzo
|
||||
INSERT INTO Giustificativi
|
||||
VALUES (@dataRif,@idxDipendente,@codGiust,@minPerm,1)
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
-- variabili
|
||||
DECLARE @minArr INT
|
||||
--SELECT @minArr=dbo.f_minArrotDip(@idxDipendente)
|
||||
SELECT @minArr = ISNULL(valInt,1) FROM AnagKeyValue WHERE nomeVar = 'minutiRoundDay'
|
||||
|
||||
-- calcolo minuti
|
||||
SELECT @minPerm = (CEILING(CONVERT(FLOAT,minOrd-minLav)/@minArr)*@minArr)-minMpp
|
||||
FROM TimbratureExpl
|
||||
WHERE isOkLav = 0
|
||||
AND idxDipendente = @idxDipendente
|
||||
AND dataLav = @dataRif
|
||||
|
||||
-- INSERT giustificativo!
|
||||
INSERT INTO Giustificativi
|
||||
VALUES (@dataRif,@idxDipendente,@codGiust,@minPerm,1)
|
||||
END
|
||||
COMMIT TRAN
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/******************************************************************************
|
||||
* Function f_oreFestDip
|
||||
* calcola ore festività dipendente x data
|
||||
*
|
||||
* ATTENZIONE: si suppone valga default a lunedì cioé SET DATEFIRST 1
|
||||
*
|
||||
* mod: S.E.L. 2013.05.08
|
||||
*
|
||||
*******************************************************************************/
|
||||
create FUNCTION f_oreFestDip
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME
|
||||
)
|
||||
RETURNS FLOAT
|
||||
AS
|
||||
|
||||
BEGIN
|
||||
|
||||
DECLARE @oreFerie FLOAT = 0
|
||||
DECLARE @trovato INT = 0
|
||||
-- controllo se sia un giorno nel calendario ferie...
|
||||
SET @trovato = ( SELECT ISNULL(COUNT(*),0) FROM CalendFesteFerie WHERE data = @dataRif AND CodGiust='FEST' )
|
||||
IF(@trovato > 0)
|
||||
BEGIN
|
||||
SET @oreFerie = dbo.f_oreOrdDip(@idxDipendente, @dataRif)
|
||||
END
|
||||
|
||||
RETURN @oreFerie
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/******************************************************************************
|
||||
* Function f_oreFerieDip
|
||||
* calcola ore FERIE dipendente x data
|
||||
*
|
||||
* ATTENZIONE: si suppone valga default a lunedì cioé SET DATEFIRST 1
|
||||
*
|
||||
* mod: S.E.L. 2012.11.21
|
||||
*
|
||||
*******************************************************************************/
|
||||
alter FUNCTION f_oreFerieDip
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME
|
||||
)
|
||||
RETURNS FLOAT
|
||||
AS
|
||||
|
||||
BEGIN
|
||||
|
||||
DECLARE @oreFerie FLOAT = 0
|
||||
DECLARE @trovato INT = 0
|
||||
-- controllo se sia un giorno nel calendario ferie...
|
||||
SET @trovato = ( SELECT ISNULL(COUNT(*),0) FROM CalendFesteFerie WHERE data = @dataRif AND CodGiust='FER' )
|
||||
IF(@trovato > 0)
|
||||
BEGIN
|
||||
SET @oreFerie = dbo.f_oreOrdDip(@idxDipendente, @dataRif)
|
||||
END
|
||||
|
||||
RETURN @oreFerie
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_timbratureExplFillDate
|
||||
*
|
||||
* inserisce nelle TimbratureExpl le date mancanti x ogni dipendente, dato il mese indicato (fino a max data corrente...)
|
||||
*
|
||||
* mod: S.E.L. 2012.11.21
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_timbratureExplFillDate
|
||||
(
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
SET DATEFIRST 1
|
||||
-- quanti giorni mi servono? conto giorni del mese
|
||||
DECLARE @numD INT
|
||||
SET @numD = ( SELECT DATEDIFF(dd, @inizio, @fine) )
|
||||
|
||||
-- elenco delle date DEL MESE (compresi sab/dom) fino a max data odierna
|
||||
;WITH myCTE AS
|
||||
(
|
||||
SELECT CONVERT(DATE,DATEADD(dd, (N-1), @inizio)) as Data, idxDipendente, Cognome + ' ' + Nome + ' [' + Matricola + ']' as CognomeNome
|
||||
FROM Tally, Dipendenti
|
||||
WHERE N <= @numD
|
||||
)
|
||||
-- INSERISCO le mancanti con i min da lavorare da tab orari x ogni dipendente e le festività
|
||||
|
||||
INSERT INTO TimbratureExpl(dataLav, idxDipendente, CognomeNome, h_lav, minOrd, minFer, minFest, isOkTim)
|
||||
SELECT mc.Data, mc.idxDipendente, mc.CognomeNome, 0, dbo.f_oreOrdDip(mc.idxDipendente,mc.Data) * 60, dbo.f_oreFerieDip(mc.idxDipendente,mc.Data) * 60, dbo.f_oreFestDip(mc.idxDipendente,mc.Data) * 60, 1
|
||||
FROM myCte as mc LEFT OUTER JOIN TimbratureExpl te
|
||||
ON mc.idxDipendente=te.idxDipendente AND mc.Data = te.dataLav
|
||||
WHERE te.dataLav IS NULL
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- stp_timbratureExpl_getContinuato
|
||||
--
|
||||
-- Recupera la tab timbrature expl filtrando per anomalie di MANCATA PAUSA PRANZO (continuato)
|
||||
-- mod: S.E.L. - 2013..05.08
|
||||
------------------------------------------------------------------------
|
||||
create PROCEDURE stp_timbratureExpl_getContinuato
|
||||
(
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT *
|
||||
FROM TimbratureExpl
|
||||
WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
AND ((dataLav >= @inizio) AND (dataLav <= @fine))
|
||||
AND isOkTim = 1 -- IN == OUT
|
||||
AND (NOT (entrata_1 IS NULL) AND (entrata_2 IS NULL)) --entrata_1 ed uscita_1 ci sono, le altre no --> continuato!
|
||||
AND minOrd > 240 -- orario con + di 4 ore sul giorno!
|
||||
AND chkFunCod ='P'
|
||||
AND (minPerm + minFer + minFest + minMPP) = 0 -- non ci sono compensazioni Mancata Pausa Pranzo
|
||||
ORDER BY dataLav DESC
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(333, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,173 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*----------------------------------
|
||||
* stp_ricalcolaRegAttivitaExpl_byPeriodoUser
|
||||
*
|
||||
* Ricalcola le RegAttivitaExpl x utente e intervallo date
|
||||
* mod: S.E.L. - 2013.01.21
|
||||
*----------------------------------*/
|
||||
alter PROCEDURE stp_ricalcolaRegAttivitaExpl_byPeriodoUser
|
||||
(
|
||||
@idxDipendente INT = 0,
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME
|
||||
)
|
||||
AS
|
||||
|
||||
-- dichiaro variabili x calcolo tempo execuzione e num records!
|
||||
DECLARE @startProc DATETIME = GETDATE()
|
||||
DECLARE @totRecords INT = 0
|
||||
|
||||
BEGIN
|
||||
|
||||
|
||||
-- faccio una tab temporanea con tallyTable x calcolo periodo intero...
|
||||
DECLARE @numD INT
|
||||
SET @numD = ( SELECT DATEDIFF(dd, @inizio, @fine ) )
|
||||
|
||||
-- crea eventuali record mancanti: data, dip, cognome-nome
|
||||
INSERT INTO RegAttivitaExpl(dataLav, idxDipendente)
|
||||
SELECT ty.Data, ty.idxDipendente
|
||||
FROM (
|
||||
SELECT CONVERT(DATE,DATEADD(dd, -N, @fine)) as Data, idxDipendente
|
||||
FROM Tally, Dipendenti
|
||||
WHERE N <= @numD -- solo dati desiderati
|
||||
AND (idxDipendente = @idxDipendente OR @idxDipendente = 0) --filtro su dipendenti
|
||||
) ty LEFT OUTER JOIN RegAttivitaExpl rae ON ty.Data=rae.dataLav AND ty.idxDipendente=rae.idxDipendente
|
||||
WHERE rae.dataLav IS NULL -- righe mancanti!
|
||||
|
||||
-- resetto a zero le eventuali righe che non hanno attività registrate
|
||||
UPDATE rae
|
||||
SET minRegAtt = 0
|
||||
,descrProj = ''
|
||||
FROM RegAttivitaExpl rae
|
||||
LEFT OUTER JOIN (
|
||||
SELECT DISTINCT idxDipendente, CONVERT(DATE,inizio) AS data
|
||||
FROM dbo.RegAttivita
|
||||
WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0) AND (inizio >= DATEADD(DAY,-1,@inizio) AND inizio <= @fine)
|
||||
GROUP BY idxDipendente, CONVERT(DATE,inizio)
|
||||
|
||||
) vra ON rae.dataLav = vra.data AND rae.idxDipendente=vra.idxDipendente
|
||||
WHERE vra.data IS NULL -- righe mancanti!
|
||||
AND ((rae.idxDipendente = @idxDipendente OR @idxDipendente = 0) AND (rae.dataLav >= @inizio AND rae.dataLav < @fine)) -- solo x dip e periodo selezionati
|
||||
|
||||
-- tab temp del record date progetti
|
||||
;WITH myCteRA AS(
|
||||
SELECT idxDipendente, CONVERT(DATE,inizio) AS data, SUM(oreTot) AS oreTot, SUM(dbo.f_minuteInterval(inizio, fine)) as minTot, dbo.f_ProgettiByDate(idxDipendente, CONVERT(DATE,inizio)) AS progetti
|
||||
FROM dbo.RegAttivita
|
||||
WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0) AND (inizio >= DATEADD(DAY,-1,@inizio) AND inizio <= @fine)
|
||||
GROUP BY idxDipendente, CONVERT(DATE,inizio)
|
||||
)
|
||||
|
||||
-- aggiorno la tab delle RegAttivitaExpl
|
||||
UPDATE rae
|
||||
SET minRegAtt = minTot
|
||||
,descrProj = ISNULL(progetti,'')
|
||||
FROM RegAttivitaExpl rae
|
||||
INNER JOIN myCteRA vra ON rae.dataLav = vra.data AND rae.idxDipendente=vra.idxDipendente
|
||||
|
||||
-- aggiorno cognome nome
|
||||
BEGIN TRY
|
||||
UPDATE rae
|
||||
SET CognomeNome = ISNULL(vcn.CognomeNome,'')
|
||||
FROM RegAttivitaExpl rae INNER JOIN v_cognomeNome vcn ON rae.idxDipendente = vcn.idxDipendente
|
||||
WHERE ISNULL(rae.CognomeNome,'') = ''
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
-- non faccio nulla
|
||||
END CATCH
|
||||
END
|
||||
|
||||
--SELECT @numD = @numD * COUNT(*) FROM Dipendenti WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
|
||||
--SELECT @startProc AS startTime, GETDATE() AS endTime, @numD AS numRec, DATEDIFF(ms, @startProc, GETDATE()) AS totMs, CAST(@numD AS FLOAT) * 1000 / DATEDIFF(ms, @startProc, GETDATE()) AS recPerSec
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
create table RegistroEventi(
|
||||
DataOra datetime not null,
|
||||
evento nvarchar(50) not null,
|
||||
commento nvarchar(250),
|
||||
|
||||
constraint PK_RegistroEventi primary key(DataOra,evento)
|
||||
);
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
INSERT INTO dbo.RegistroEventi
|
||||
VALUES ('2013-06-10 12:21:52.250', N'checkAnomalie', N'-')
|
||||
INSERT INTO dbo.RegistroEventi
|
||||
VALUES ('2013-06-10 12:21:52.250', N'dailyDuties', N'-')
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RE_GetByDataEv
|
||||
*
|
||||
* recupera dati da registro eventi x data ed evento
|
||||
*
|
||||
* mod: S.E.L. 2012.10.29
|
||||
*
|
||||
**********************************************************/
|
||||
create PROCEDURE stp_RE_GetByDataEv
|
||||
(
|
||||
@evento NVARCHAR(50),
|
||||
@data AS DATE
|
||||
)
|
||||
AS
|
||||
|
||||
SELECT *
|
||||
FROM RegistroEventi
|
||||
WHERE (evento = @evento) AND (CAST(ISNULL(DataOra, '1900-01-01') AS DATE) = @data)
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(345, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,346 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
alter VIEW v_logCommUt
|
||||
AS
|
||||
SELECT dataLav AS Data, idxDipendente, CognomeNome, h_lav, 0.00 AS h_com, isOk AS okTimbr, isOk AS okLavCom, '---' AS progetto, minOrd, minStra, minPerm,
|
||||
minFer, minMal, minFest, minMpp
|
||||
FROM dbo.TimbratureExpl
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
-- =============================================
|
||||
-- Author: G.Rottoli
|
||||
-- Create date: 2013.03.12
|
||||
-- Description: Stored per export x stampa di controllo tracciato paghe x ETS
|
||||
-- =============================================
|
||||
alter PROCEDURE export.stp_prt_orePagheMensileETS
|
||||
(
|
||||
@Anno NVARCHAR(4),
|
||||
@Mese NVARCHAR(2),
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@flgOnlyErr BIT = 0,
|
||||
@flgSingleUser BIT = 0 -- Stampa x singolo utente ( ritorna dati solo utente loggato SYSTEM_USER )
|
||||
)
|
||||
AS
|
||||
BEGIN
|
||||
|
||||
-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @dateFrom AS SMALLDATETIME;
|
||||
DECLARE @dateTo AS SMALLDATETIME;
|
||||
|
||||
SET @dateFrom = @Anno + @Mese + '01';
|
||||
SET @dateTo = DATEADD( MM, 1, @dateFrom) -1;
|
||||
|
||||
EXEC export.stp_ricalcolaOrePerPaghe @dateFrom ;
|
||||
|
||||
SELECT
|
||||
e.idxDipendente
|
||||
, e.dataLav
|
||||
, e.matricola
|
||||
, e.codExt
|
||||
, e.RifDitta
|
||||
, e.oreStraordAss
|
||||
, e.minLavStra
|
||||
, e.minLavTot
|
||||
, e.minStraProgrMese
|
||||
, e.minPrevExp
|
||||
, e.minLavOrdExp
|
||||
, e.minStraExp
|
||||
, e.minPermExp
|
||||
, e.minFerieExp
|
||||
, e.minMalExp
|
||||
, e.minFestExp
|
||||
, e.hhLavTotExp
|
||||
, e.hhStraProgrMeseExp
|
||||
, e.hhPrevExp
|
||||
, e.hhLavOrdExp
|
||||
, e.hhStraExp
|
||||
, e.hhPermExp
|
||||
, e.hhFerieExp
|
||||
, e.hhMalExp
|
||||
, e.hhFestExp
|
||||
, e.CognomeNome
|
||||
, e.entrata_1
|
||||
, e.uscita_1
|
||||
, e.entrata_2
|
||||
, e.uscita_2
|
||||
, e.entrata_3
|
||||
, e.uscita_3
|
||||
, e.entrata_4
|
||||
, e.uscita_4
|
||||
, e.isOkTim
|
||||
, e.isOkApp
|
||||
, e.isOkLav
|
||||
, e.isOk
|
||||
, e.block
|
||||
, e.chkFunCod
|
||||
, e.chkFunRes
|
||||
, e.arrotMin
|
||||
, e.gruppo
|
||||
, e.exportEnab
|
||||
|
||||
--, e.h_ordinarie
|
||||
--, e.h_lavorate
|
||||
--, e.h_straordinarie
|
||||
--, e.h_permessi
|
||||
--, e.h_NonLavorati
|
||||
--, e.h_ferie
|
||||
--, e.h_malattia
|
||||
--, e.h_festivita
|
||||
--, e.mm_ordinari
|
||||
--, e.mm_lavorati
|
||||
--, e.mm_straordinari
|
||||
--, e.mm_permessi
|
||||
--, e.mm_NonLavorati
|
||||
--, e.mm_ferie
|
||||
--, e.mm_malattia
|
||||
--, e.mm_festivita
|
||||
--, e.minMpp
|
||||
--, e.minLav
|
||||
--, e.minOrd
|
||||
--, e.minNonLav
|
||||
--, e.minStra
|
||||
--, e.minPerm
|
||||
--, e.minFer
|
||||
--, e.minMal
|
||||
--, e.minFest
|
||||
--, e.minArcoPres
|
||||
--, e.h_lav
|
||||
--, e.h_giust
|
||||
FROM dbo.v_OreTimbratureDipendenteExport AS e
|
||||
INNER JOIN dbo.Dipendenti AS dip
|
||||
ON e.idxDipendente=dip.idxDipendente
|
||||
AND ( dip.dominio + '\' + dip.utente = SYSTEM_USER OR @flgSingleUser = 0 )
|
||||
WHERE datalav BETWEEN @dateFrom AND @dateTo
|
||||
AND ( e.idxDipendente = @idxDipendente OR @idxDipendente = 0 OR @flgSingleUser = 1 )
|
||||
AND ( @flgOnlyErr = 0 -- cmq tutti se @flgOnlyErr = False o solo quelli in errore NON USATO ( veto Sam )
|
||||
OR isOk = 0 OR h_ordinarie > ( h_lavorate + h_ferie + h_permessi + h_festivita + h_malattia ) ) -- altrimenti quelle in errore
|
||||
AND e.exportEnab = 1
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_lcuByDipDate
|
||||
*
|
||||
* elenco dati di timbratura e commessa per utente/periodo
|
||||
*
|
||||
* mod: S.E.L. 2012.11.02
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_lcuByDipDate
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataFrom DATETIME,
|
||||
@dataTo DATETIME,
|
||||
@maxErrMin INT = 0, -- minuti massimi di scostamento consentiti per DIFETTO, default 0
|
||||
@maxErrPlus INT = 0 -- minuti massimi di scostamento consentiti per ECCESSO, default 0
|
||||
)
|
||||
with recompile
|
||||
AS
|
||||
|
||||
BEGIN
|
||||
|
||||
-- faccio una tab temporanea con tallyTable x calcolo periodo intero...
|
||||
DECLARE @numD INT
|
||||
SET @numD = ( SELECT DATEDIFF(dd, @dataFrom, @dataTo ) )
|
||||
|
||||
-- tab dei record RegAttività progetti
|
||||
;WITH myCteRA AS(
|
||||
SELECT idxDipendente, dataLav, minRegAtt, descrProj
|
||||
FROM dbo.RegAttivitaExpl
|
||||
WHERE (idxDipendente = @idxDipendente OR @idxDipendente = 0) AND (dataLav >= DATEADD(DAY,-1,@dataFrom) AND dataLav <= @dataTo)
|
||||
|
||||
)
|
||||
|
||||
SELECT mc.Data, mc.idxDipendente, ISNULL(te.CognomeNome,'') AS CognomeNome, ISNULL(te.h_lav,0) AS h_lav, CAST(ISNULL(vra.minRegAtt,0) AS DECIMAL(9,3))/60 AS h_com
|
||||
,ISNULL(te.isOk,0) AS okTimbr
|
||||
,CASE WHEN ISNULL(vra.minRegAtt,0)-ISNULL(te.h_lav,0)*60 >= @maxErrMin AND ISNULL(vra.minRegAtt,0)-ISNULL(te.h_lav,0)*60 <= @maxErrPlus THEN 1 ELSE 0 END AS okLavCom
|
||||
,ISNULL(vra.descrProj,'') AS progetti, ISNULL(te.minOrd,0) AS minOrd, ISNULL(te.minStra,0) AS minStra, ISNULL(te.minPerm,0) AS minPerm, ISNULL(te.minFer,0) AS minFer
|
||||
,ISNULL(te.minMal,0) AS minMal, ISNULL(te.minFest,0) AS minFest, ISNULL(te.minMpp,0) AS minMpp
|
||||
|
||||
FROM (SELECT CONVERT(DATE,DATEADD(dd, -N, @dataTo)) as Data, idxDipendente
|
||||
FROM Tally, Dipendenti
|
||||
WHERE N <= @numD
|
||||
AND (idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
) AS mc
|
||||
LEFT OUTER JOIN myCteRA vra ON mc.Data = vra.dataLav AND mc.idxDipendente=vra.idxDipendente
|
||||
LEFT OUTER JOIN TimbratureExpl te ON mc.Data=te.dataLav AND te.idxDipendente=mc.idxDipendente
|
||||
WHERE (te.idxDipendente = @idxDipendente OR @idxDipendente = 0)
|
||||
ORDER BY mc.Data DESC
|
||||
|
||||
END
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_RA_clonaLastRA_Utente
|
||||
*
|
||||
* clona un attività utente: se c'è da ultima altrimenti da zero x una certa data
|
||||
*
|
||||
* mod: S.E.L. 2013.01.17
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_RA_clonaLastRA_Utente
|
||||
(
|
||||
@idxDipendente INT,
|
||||
@dataRif DATETIME, -- dataOra inizio record attività
|
||||
@durataMin INT = 60 --durata in minuti (default 1 h)
|
||||
)
|
||||
AS
|
||||
|
||||
-- variabili
|
||||
DECLARE @idxFase INT
|
||||
DECLARE @idxRA INT
|
||||
|
||||
-- arrotondo data richiesta solo all'ora...
|
||||
SELECT @dataRif = DATEADD(HOUR, DATEPART(HOUR,@dataRif), CONVERT(DATETIME,(CONVERT(DATE,@dataRif))))
|
||||
|
||||
-- cerco se esista ultima reg attività utente...
|
||||
SELECT @idxRA = ISNULL((SELECT TOP 1 idxRA FROM RegAttivita WHERE idxDipendente = @idxDipendente ORDER BY inizio DESC),0)
|
||||
|
||||
-- se non ho trovato records, ovvero idxRA = 0, prendo ultima fase da elenco
|
||||
IF (@idxRA = 0)
|
||||
BEGIN
|
||||
-- calcolo ultima fase inserita...
|
||||
SELECT TOP 1 @idxFase=ISNULL(idxFase,0) FROM AnagFasi ORDER BY idxFase DESC
|
||||
-- se trovata fase inserisco!
|
||||
IF(@idxFase > 0)
|
||||
BEGIN
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
VALUES (@idxDipendente, @idxFase, @dataRif, DATEADD(MINUTE, @durataMin, @dataRif), '...',0)
|
||||
END
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
-- inserisco su data richiesta duplicazione dell'ultima attività utente...
|
||||
INSERT INTO RegAttivita(idxDipendente, idxFase, inizio, fine, descrizione, importo)
|
||||
SELECT idxDipendente, idxFase, @dataRif, CASE WHEN @durataMin > 0 THEN DATEADD(MINUTE, @durataMin, @dataRif) ELSE DATEADD(minute, DATEDIFF(MINUTE, inizio, fine), @dataRif) END, descrizione, importo
|
||||
FROM RegAttivita
|
||||
WHERE (idxRA = @idxRA)
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/*************************************
|
||||
* STORED PROCEDURE stp_VSProjFasi_search
|
||||
*
|
||||
* dato un campo di ricerca va alla caddia del progetto e della fase che corrispondano
|
||||
* Formati consentiti:
|
||||
* - testo libero fase
|
||||
* - formato commessa ETS full (xxxx-xxxx)
|
||||
* - formato commessa ETS compatto (xx-xx)
|
||||
*
|
||||
* mod : 2013.07.04
|
||||
* aut : S.E. Locatelli
|
||||
**************************************/
|
||||
create PROCEDURE stp_VSProjFasi_search
|
||||
(
|
||||
@textSearch NVARCHAR(50)
|
||||
)
|
||||
AS
|
||||
|
||||
DECLARE @codFase NVARCHAR(500)
|
||||
|
||||
SELECT @codFase = codFase
|
||||
FROM AnagFasi
|
||||
WHERE nomeFase LIKE '%' + @textSearch + '%' OR descrizioneFase LIKE '%' + @textSearch + '%'
|
||||
AND Attivo = 1
|
||||
AND EnableTime = 0
|
||||
|
||||
-- se non ha trovato nulal cerco anche in progetti... e prendo il primo progetto x nome/descrizione e da li la prima fase
|
||||
IF(ISNULL(@codFase,'##################') ='##################')
|
||||
BEGIN
|
||||
SELECT @codFase = af.codFase
|
||||
FROM AnagFasi af INNER JOIN AnagProgetti ap ON af.idxProgetto = ap.idxProgetto
|
||||
WHERE ap.nomeProj LIKE '%' + @textSearch + '%' OR descrProj LIKE '%' + @textSearch + '%'
|
||||
AND ap.Attivo = 1
|
||||
AND af.Attivo = 1
|
||||
AND EnableTime = 0
|
||||
ORDER BY codFase DESC
|
||||
END
|
||||
|
||||
SELECT TOP 1 idxProgetto, idxFase
|
||||
FROM AnagFasi
|
||||
WHERE codFase LIKE @codFase +'%'
|
||||
AND Attivo = 1
|
||||
AND EnableTime <> 0
|
||||
ORDER BY codFase
|
||||
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(355, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,74 @@
|
||||
set xact_abort on;
|
||||
go
|
||||
|
||||
begin transaction;
|
||||
go
|
||||
|
||||
set ANSI_NULLS on;
|
||||
go
|
||||
|
||||
/**********************************************************
|
||||
* STORED stp_freqProjByDipPeriodo
|
||||
*
|
||||
* elenco dei progetti/fasi per dipendente/periodo
|
||||
*
|
||||
* mod: S.E.L. 2013.02.20
|
||||
*
|
||||
**********************************************************/
|
||||
alter PROCEDURE stp_freqProjByDipPeriodo
|
||||
(
|
||||
@idxDipendente INT = 0, -- 0 = tutti
|
||||
@inizio DATETIME,
|
||||
@fine DATETIME,
|
||||
@maxRes INT = 999 -- num max risultati desiderati
|
||||
)
|
||||
AS
|
||||
|
||||
-- calcolo il totale dei risultati per prima cosa...
|
||||
DECLARE @totNum AS INT = 1
|
||||
|
||||
DECLARE @tabFreq AS TABLE
|
||||
(
|
||||
nomeProj NVARCHAR(250)
|
||||
,nomeFase NVARCHAR(250)
|
||||
,qty DECIMAL(9,3)
|
||||
,idxFase INT
|
||||
,idxFaseComm INT
|
||||
)
|
||||
|
||||
INSERT @tabFreq
|
||||
SELECT TOP (@maxRes) nomeProj, nomeFase ,SUM(ra.oreTot) as qty, ra.idxFase, af.idxFaseAncest
|
||||
FROM RegAttivita ra INNER JOIN AnagFasi af ON ra.idxFase=af.idxFase
|
||||
INNER JOIN AnagProgetti ap ON af.idxProgetto=ap.idxProgetto
|
||||
WHERE ra.inizio BETWEEN @inizio AND @fine
|
||||
AND (ra.idxDipendente = @idxDipendente OR @idxDipendente = 0 )
|
||||
GROUP BY nomeProj, nomeFase, ra.idxFase, af.idxFaseAncest
|
||||
ORDER BY qty DESC
|
||||
|
||||
-- calcolo il totale
|
||||
SELECT @totNum = ISNULL(SUM(qty),1) FROM @tabFreq
|
||||
|
||||
;WITH myCTE AS
|
||||
(
|
||||
SELECT idxFaseComm, idxFase, nomeProj, nomeFase, qty/@totNum as freq, qty, @totNum AS tot
|
||||
FROM @tabFreq
|
||||
)
|
||||
|
||||
-- restituisco tab con calcolo freq reale
|
||||
SELECT af.nomeFase as nomeComm, tf.*
|
||||
FROM myCTE tf INNER JOIN AnagFasi af ON tf.idxFaseComm = af.idxFase
|
||||
|
||||
RETURN
|
||||
go
|
||||
|
||||
commit;
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(359, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
@@ -0,0 +1,32 @@
|
||||
set xact_abort on
|
||||
go
|
||||
|
||||
begin transaction
|
||||
go
|
||||
|
||||
INSERT INTO dbo.Vocabolario
|
||||
VALUES (N'EN', N'SpostaOre', N'Spostamento Ore')
|
||||
INSERT INTO dbo.Vocabolario
|
||||
VALUES (N'EN', N'SpostaOreExpl', N'Visualizzazione e spostamento assegnazione ore tra progetti')
|
||||
INSERT INTO dbo.Vocabolario
|
||||
VALUES (N'IT', N'SpostaOre', N'Spostamento Ore')
|
||||
INSERT INTO dbo.Vocabolario
|
||||
VALUES (N'IT', N'SpostaOreExpl', N'Visualizzazione e spostamento assegnazione ore tra progetti')
|
||||
go
|
||||
|
||||
commit transaction
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(304, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
Reference in New Issue
Block a user