-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sql
More file actions
208 lines (159 loc) · 6.16 KB
/
Copy pathinstall.sql
File metadata and controls
208 lines (159 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
IF ((SELECT COUNT([Role_ID])
FROM dp_Roles
WHERE Role_Name='GroupCheckIn') = 0)
BEGIN
INSERT INTO dp_Roles
([Role_Name]
,[Domain_ID]
,[Mass_Email_Quota]
,[_AdminRole])
VALUES
('GroupCheckIn'
,1
,NULL
,0)
INSERT INTO dp_User_Roles
([User_ID]
,[Role_ID]
,[Domain_ID])
SELECT UR.User_ID
,(SELECT [Role_ID]
FROM dp_Roles
WHERE Role_Name='GroupCheckIn') AS RoleID
,UR.Domain_ID
FROM dp_User_Roles UR
LEFT JOIN dp_Roles AS R ON R.Role_ID = UR.Role_ID
LEFT JOIN dp_Users AS U ON U.User_ID = UR.User_ID
WHERE Role_Name='Administrators'
END
GO
/****** Object: StoredProcedure [dbo].[api_GroupCheckIn_GetCheckInEvents] Script Date: 01/09/2012 15:38:29 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[api_GroupCheckIn_GetCheckInEvents]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[api_GroupCheckIn_GetCheckInEvents]
GO
/****** Object: StoredProcedure [dbo].[api_GroupCheckIn_GetGroupMembers] Script Date: 01/09/2012 15:38:29 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[api_GroupCheckIn_GetGroupMembers]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[api_GroupCheckIn_GetGroupMembers]
GO
/****** Object: StoredProcedure [dbo].[api_GroupCheckIn_GetGroupsByActivity] Script Date: 01/09/2012 15:38:30 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[api_GroupCheckIn_GetGroupsByActivity]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[api_GroupCheckIn_GetGroupsByActivity]
GO
/****** Object: StoredProcedure [dbo].[api_GroupCheckIn_GetCheckInEvents] Script Date: 01/09/2012 15:38:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[api_GroupCheckIn_GetCheckInEvents]
@DomainID int
,@ShowEventsFromTime datetime
,@ShowEventsThroughTime DateTime
AS
BEGIN
DECLARE @DefaultEarlyCheckIn smallint
DECLARE @DefaultLateCheckIn smallint
SET @DefaultEarlyCheckIn = 240 -- 4 hours
SET @DefaultLateCheckIn = 30 -- 1/2 hour
SELECT
Event_ID AS RecordID
,RIGHT(CONVERT(varchar(25), Event_Start_Date, 100),7) + ' ' + Event_Title + ISNULL(' | ' + M.Ministry_Name + ISNULL(' | ' + Cong.Congregation_Name,''),'') AS RecordDescription
,Event_Title
,Congregation_Name
,Ministry_Name
,Prog.[Program_Name]
,Event_Start_Date
,Event_End_Date
,DATEADD(n,ISNULL([Early_Check-in_Period],@DefaultEarlyCheckIn)*-1,Event_Start_Date) AS EarlyCheckinStart
,DATEADD(n,ISNULL([Late_Check-in_Period],@DefaultLateCheckIn),Event_Start_Date) AS LateCheckinStop
FROM Events
INNER JOIN Programs Prog ON Prog.Program_ID = Events.Program_ID
INNER JOIN Ministries M ON M.Ministry_ID = Prog.Ministry_ID
LEFT OUTER JOIN Congregations Cong ON Cong.Congregation_ID = Events.Congregation_ID
WHERE Events.Domain_ID = @DomainID
-- AND (Events.Congregation_ID = @CongregationID OR @CongregationID = 0)
-- AND (Prog.Ministry_ID = @MinistryID OR @MinistryID = 0)
AND Events.[Allow_Check-in] = 1
AND (@ShowEventsFromTime BETWEEN DATEADD(n,ISNULL([Early_Check-in_Period],@DefaultEarlyCheckIn)*-1,Event_Start_Date) AND Event_End_Date OR Event_Start_Date BETWEEN @ShowEventsFromTime AND @ShowEventsThroughTime)
-- AND DATEADD(n,ISNULL([Early_Check-in_Period],@DefaultEarlyCheckIn)*-1,Event_Start_Date) <= @LocalTime
-- AND @LocalTime < Event_End_Date
-- AND DATEADD(n,ISNULL([Late_Check-in_Period],@DefaultLateCheckIn),Event_Start_Date) >= @LocalTime
ORDER BY Event_Start_Date
END
GO
/****** Object: StoredProcedure [dbo].[api_GroupCheckIn_GetGroupMembers] Script Date: 01/09/2012 15:38:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[api_GroupCheckIn_GetGroupMembers]
@DomainID int
,@EventID int
,@GroupID INT
AS
BEGIN
SELECT C.Display_Name
, C.Contact_ID
, P.Participant_ID
, EP.Event_Participant_ID
, EP.Participation_Status_ID
, GP.Group_Participant_ID
, GP.Group_ID
, GR.Role_Title
, GRT.Group_Role_Type
, EP.Event_ID
, EP.Time_In
, EP.Time_Out
FROM Group_Participants GP
INNER JOIN Participants P ON P.Participant_ID = GP.Participant_ID
INNER JOIN Contacts C ON C.Contact_ID = P.Contact_ID
INNER JOIN Group_Roles GR ON GR.Group_Role_ID = GP.Group_Role_ID
INNER JOIN Group_Role_Types GRT ON GRT.Group_Role_Type_ID = GR.Group_Role_Type_ID
LEFT OUTER JOIN Event_Participants EP ON EP.Group_Participant_ID = GP.Group_Participant_ID AND EP.Event_ID = @EventID
--may need an outer apply statmeent for EP join in case there is more than one record
WHERE GP.Group_ID = @GroupID
AND GP.Domain_ID = @DomainID
AND GETDATE() BETWEEN GP.Start_Date AND ISNULL(GP.End_Date,GETDATE())
UNION
SELECT C.Display_Name
, C.Contact_ID
, P.Participant_ID
, EP.Event_Participant_ID
, EP.Participation_Status_ID
, NULL AS Group_Participant_ID
, 0 AS Group_ID
, RIGHT(PS.Participation_Status,DATALENGTH(PS.Participation_Status)-3) AS Role_Title
, 'Participant' AS Role_Type
, E.Event_ID
, EP.Time_In
, EP.Time_Out
FROM Events E
INNER JOIN Event_Participants EP ON EP.Event_ID = E.Event_ID AND EP.Group_Participant_ID IS NULL --AND EP.Participation_Status_ID IN (1,2)
INNER JOIN Participation_Statuses PS ON PS.Participation_Status_ID = EP.Participation_Status_ID
INNER JOIN Participants P ON P.Participant_ID = EP.Participant_ID
INNER JOIN Contacts C ON C.Contact_ID = P.Contact_ID
WHERE E.Event_ID = @EventID AND E.Domain_ID = @DomainID AND @GroupID = 0
ORDER BY Display_Name
END
GO
/****** Object: StoredProcedure [dbo].[api_GroupCheckIn_GetGroupsByActivity] Script Date: 01/09/2012 15:38:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[api_GroupCheckIn_GetGroupsByActivity]
@DomainID int
,@EventID int
AS
BEGIN
SELECT E.Event_Title, E.Prohibit_Guests, G.Group_ID AS Record_ID, G.Group_Name AS [Description]
FROM Events E
INNER JOIN Event_Groups EG ON EG.Event_ID = E.Event_ID
INNER JOIN Groups G ON G.Group_ID = EG.Group_ID
WHERE E.Event_ID = @EventID AND E.Domain_ID = @DomainID
UNION
SELECT E.Event_Title, E.Prohibit_Guests, 0 AS Record_ID, '*Registered - No Group' AS [Description]
FROM Events E
WHERE E.Event_ID = @EventID AND E.Domain_ID = @DomainID
ORDER BY [Description]
END
GO