Commits

Anonymous committed f6ca7a9

bug fixes

  • Participants
  • Parent commits c11538d

Comments (0)

Files changed (168)

 GO
 IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
 GO
+PRINT N'Creating index [AttendanceFlagIndex] on [dbo].[Attend]'
+GO
+CREATE NONCLUSTERED INDEX [AttendanceFlagIndex] ON [dbo].[Attend] ([AttendanceFlag]) INCLUDE ([MeetingDate], [OrganizationId], [PeopleId])
+GO
+IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
+GO
+IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
+GO
 PRINT N'Creating index [IX_Attend_3] on [dbo].[Attend]'
 GO
 CREATE NONCLUSTERED INDEX [IX_Attend_3] ON [dbo].[Attend] ([PeopleId])
     SELECT @lastmeet = MAX(MeetingDate) 
     FROM dbo.Meetings
     WHERE OrganizationId = @orgid
+    AND MeetingDate <= GETDATE()
     
     SELECT @yearago = DATEADD(year, -1, @lastmeet)
 			
 		WHERE a.OrganizationId = @orgid
 			AND PeopleId = @pid
 			AND a.MeetingDate >= @yearago
+			AND a.MeetingDate <= GETDATE()
 	) AS InlineView
 	GROUP BY [Year], [Week], AttendCredit
 	ORDER BY [Year] DESC, [Week] DESC
 AS
 RETURN 
 (
-	SELECT 
-		pp.OrganizationId, 
-		oo.OrganizationName, 
-		oo.LeaderName, 
-		consecutive, 
-		pp.PeopleId, 
-		pp.Name2, 
-		pp.HomePhone, 
-		pp.CellPhone, 
-		pp.EmailAddress, 
-		lastmeeting, 
-		MeetingId, 
-		ConsecutiveAbsentsThreshold
-	FROM
-	(
-		SELECT 
-			m.PeopleId, 
-			p.Name2, 
-			p.EmailAddress, 
-			p.HomePhone, 
-			p.CellPhone, 
-			m.OrganizationId, 
-			m.MemberTypeId, 
-			at.Id AttendTypeId,
-			(
-				SELECT COUNT(*) FROM dbo.Attend a
-				JOIN dbo.Meetings mm ON a.MeetingId = mm.MeetingId
-				WHERE mm.OrganizationId = m.OrganizationId
-				AND p.PeopleId = a.PeopleId
-				AND a.MeetingDate >= ISNULL((SELECT MAX(MeetingDate) 
-											  FROM Attend aa 
-											  WHERE aa.OrganizationId = a.OrganizationId 
-											  AND aa.PeopleId = a.PeopleId 
-											  AND aa.EffAttendFlag = 1)
-										, '1/1/1900')
-				AND a.MeetingDate < GETDATE()
-				AND a.EffAttendFlag = 0
-			) AS consecutive
-		FROM dbo.OrganizationMembers m
-		JOIN lookup.MemberType mt ON m.MemberTypeId = mt.Id
-		JOIN lookup.AttendType at ON at.Id = mt.AttendanceTypeId
-		JOIN dbo.People p ON m.PeopleId = p.PeopleId
-	) pp
-	JOIN
-	(
-		SELECT 
-			o.OrganizationId, 
-			o.OrganizationName, 
-			o.LeaderName, 
-			m.MeetingDate lastmeeting, 
-			m.MeetingId, 
-			ISNULL(o.ConsecutiveAbsentsThreshold, 2) AS ConsecutiveAbsentsThreshold
-		FROM dbo.Organizations o
-		JOIN dbo.Meetings m ON o.OrganizationId = m.OrganizationId 
-			AND m.MeetingDate = ( SELECT MAX(a.MeetingDate) FROM dbo.Attend a
-								  WHERE a.OrganizationId = o.OrganizationId
-								  AND a.EffAttendFlag = 1 
-								  AND a.MeetingDate > DATEADD(d, -@days, GETDATE()) 
-								  AND a.MeetingDate < GETDATE()
-								)
-		WHERE (o.OrganizationId = @orgid OR @orgid IS NULL)
+WITH LastAbsents AS
+(
+  SELECT OrganizationId, PeopleId, MAX(MeetingDate) ld
+  FROM Attend
+  WHERE AttendanceFlag = 1
+  GROUP BY OrganizationId, PeopleId
+)
+SELECT 
+	tt.OrganizationId, 
+	o.OrganizationName, 
+	o.LeaderName, 
+	consecutive,
+	tt.PeopleId,
+	p.Name2,
+	p.HomePhone,
+	p.CellPhone,
+	p.EmailAddress,
+		(SELECT MAX(MeetingDate) 
+		 FROM dbo.Attend aa 
+		 WHERE aa.PeopleId = tt.PeopleId  
+		 AND aa.OrganizationId = tt.OrganizationId 
+		 AND aa.AttendanceFlag = 1) 
+	lastmeeting,
+	m.MeetingId,
+	ConsecutiveAbsentsThreshold
+FROM
+(
+SELECT a.OrganizationId, a.PeopleId, count(*) As consecutive
+FROM dbo.Attend a
+JOIN LastAbsents la 
+			ON la.OrganizationId = a.OrganizationId 
+			AND la.PeopleId = a.PeopleId
+			AND a.MeetingDate > la.ld
+group by a.OrganizationId, a.PeopleId
+) tt
+JOIN dbo.Organizations o ON tt.OrganizationId = o.OrganizationId
+JOIN dbo.Meetings m ON tt.OrganizationId = m.OrganizationId 
+	AND m.MeetingDate = ( SELECT MAX(a.MeetingDate) FROM dbo.Attend a
+						  JOIN dbo.Meetings mm ON mm.MeetingId = a.MeetingId
+						  WHERE mm.OrganizationId = tt.OrganizationId
+						  AND a.AttendanceFlag = 1 
+						  AND mm.MeetingDate > DATEADD(d, -@days, GETDATE()) 
+						  AND mm.MeetingDate < GETDATE()
+						)
+JOIN OrganizationMembers om ON om.PeopleId = tt.PeopleId AND om.OrganizationId = o.OrganizationId
+JOIN dbo.People p ON tt.PeopleId = p.PeopleId
+JOIN lookup.MemberType mt ON om.MemberTypeId = mt.Id
+JOIN lookup.AttendType at ON at.Id = mt.AttendanceTypeId
+WHERE consecutive > ISNULL(ConsecutiveAbsentsThreshold, 2)
+AND m.MeetingDate IS NOT NULL
+AND at.Id NOT IN (70, 100) --inservice and homebound
+AND om.MemberTypeId != 230 --inactive
+		AND (tt.OrganizationId = @orgid OR @orgid IS NULL)
 		AND (@divid IS NULL 
 			OR EXISTS(SELECT NULL 
 						FROM dbo.DivOrg 
-						WHERE OrgId = o.OrganizationId AND DivId = @divid))
-	) oo ON pp.OrganizationId = oo.OrganizationId
-	WHERE consecutive >= ISNULL(oo.ConsecutiveAbsentsThreshold, 2)
-	AND (pp.OrganizationId = @orgid OR @orgid IS NULL)
-	AND lastmeeting IS NOT NULL
-	AND pp.AttendTypeId NOT IN (70, 100) --inservice and homebound
-	AND pp.MemberTypeId != 230 --inactive
+						WHERE OrgId = tt.OrganizationId AND DivId = @divid))
 )
 GO
 IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
 		COUNT(*) AS [Count], 
 		SUM(Amount) AS Amount, 
 		SUM(PledgeAmount) AS PledgeAmount, 
-		FundId, 
+		c2.FundId, 
 		FundName,
+		CASE WHEN BundleHeaderTypeId = 4 THEN 1 ELSE 0 END AS [OnLine],
 		CASE WHEN QBSyncID IS NULL THEN 0 ELSE 1 END QBSynced
-	FROM dbo.Contributions2(@fd, @td, @campusid, NULL, @nontaxded, @includeUnclosed)
-	GROUP BY CreditGiverId, HeadName, SpouseName, FundId, FundName, CASE WHEN QBSyncID IS NULL THEN 0 ELSE 1 END
+	FROM dbo.Contributions2(@fd, @td, @campusid, NULL, @nontaxded, @includeUnclosed) c2
+	JOIN dbo.BundleHeader h ON c2.BundleHeaderId = h.BundleHeaderId
+	GROUP BY CreditGiverId, HeadName, SpouseName, c2.FundId, FundName, 
+		CASE WHEN BundleHeaderTypeId = 4 THEN 1 ELSE 0 END,
+		CASE WHEN QBSyncID IS NULL THEN 0 ELSE 1 END
 	) tt 
 	JOIN dbo.People p ON p.PeopleId = tt.CreditGiverId
 	JOIN lookup.MemberStatus ms ON p.MemberStatusId = ms.Id
 GO
 IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
 GO
+PRINT N'Creating [dbo].[RecentAbsents2]'
+GO
+CREATE FUNCTION [dbo].[RecentAbsents2](@orgid INT, @divid INT, @days INT)
+RETURNS 
+@ret TABLE 
+(
+OrganizationId INT,
+OrganizationName VARCHAR(70),
+LeaderName VARCHAR(60),
+consecutive INT,
+PeopleId INT,
+Name2 VARCHAR(50),
+HomePhone VARCHAR(15),
+CellPhone VARCHAR(15),
+EmailAddress VARCHAR(50),
+MeetingId INT,
+ConsecutiveAbsentsThreshhold INT
+)
+AS
+BEGIN
+DECLARE @t TABLE ( Oid INT NOT NULL, Pid INT NOT NULL, consecutive INT,
+PRIMARY KEY (Oid, Pid));
+
+WITH LastAbsents AS
+(
+  SELECT OrganizationId, PeopleId, MAX(MeetingDate) ld
+  FROM Attend
+  WHERE EffAttendFlag = 0
+  GROUP BY OrganizationId, PeopleId
+)
+INSERT INTO @t (Oid, Pid, consecutive) 
+SELECT a.OrganizationId, a.PeopleId, count(*) As ConsecutiveAbsents
+FROM dbo.Attend a
+INNER JOIN LastAbsents la 
+			ON la.OrganizationId = a.OrganizationId 
+			AND la.PeopleId = a.PeopleId
+			AND a.MeetingDate > la.ld
+			AND a.MeetingDate < GETDATE()
+		WHERE (a.OrganizationId = @orgid OR @orgid IS NULL)
+		AND (@divid IS NULL 
+			OR EXISTS(SELECT NULL 
+						FROM dbo.DivOrg 
+						WHERE OrgId = a.OrganizationId AND DivId = @divid))
+group by a.OrganizationId, a.PeopleId
+		
+		
+INSERT INTO @ret (
+	OrganizationId,
+	OrganizationName,
+	LeaderName,
+	consecutive,
+	PeopleId,
+	Name2,
+	HomePhone,
+	CellPhone,
+	EmailAddress,
+	ConsecutiveAbsentsThreshhold
+)
+	SELECT 
+		 pp.OrganizationId
+		,oo.OrganizationName
+		,oo.LeaderName
+		,consecutive
+		,pp.PeopleId 
+		,pp.Name2
+		,pp.HomePhone
+		,pp.CellPhone
+		,pp.EmailAddress
+		,ConsecutiveAbsentsThreshold
+	FROM @t t
+	JOIN
+	(
+		SELECT 
+			m.PeopleId, 
+			p.Name2, 
+			p.EmailAddress, 
+			p.HomePhone, 
+			p.CellPhone, 
+			m.OrganizationId, 
+			m.MemberTypeId, 
+			at.Id AttendTypeId
+		FROM dbo.OrganizationMembers m
+		JOIN lookup.MemberType mt ON m.MemberTypeId = mt.Id
+		JOIN lookup.AttendType at ON at.Id = mt.AttendanceTypeId
+		JOIN dbo.People p ON m.PeopleId = p.PeopleId
+	) pp ON t.Pid = pp.PeopleId AND t.Oid = pp.OrganizationId
+	JOIN
+	(
+		SELECT 
+			o.OrganizationId, 
+			o.OrganizationName, 
+			o.LeaderName, 
+			ISNULL(o.ConsecutiveAbsentsThreshold, 2) AS ConsecutiveAbsentsThreshold
+		FROM dbo.Organizations o
+		WHERE (o.OrganizationId = @orgid OR @orgid IS NULL)
+		AND (@divid IS NULL 
+			OR EXISTS(SELECT NULL 
+						FROM dbo.DivOrg 
+						WHERE OrgId = o.OrganizationId AND DivId = @divid))
+	) oo ON pp.OrganizationId = oo.OrganizationId
+	WHERE consecutive >= ISNULL(oo.ConsecutiveAbsentsThreshold, 2)
+	AND pp.AttendTypeId NOT IN (70, 100) --inservice and homebound
+	AND pp.MemberTypeId != 230 --inactive	
+	RETURN 
+END
+GO
+IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
+GO
+IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
+GO
+PRINT N'Creating [dbo].[RecentAbsentsSP]'
+GO
+CREATE PROCEDURE [dbo].[RecentAbsentsSP](@orgid INT, @divid INT, @days INT)
+AS
+BEGIN
+	SELECT
+		o.OrganizationId,
+		o.OrganizationName,
+		o.LeaderName,
+		consecutive, 
+		om.PeopleId,
+		p.Name2,
+		p.HomePhone,
+		p.CellPhone,
+		p.EmailAddress,
+			(SELECT MAX(Attend.MeetingDate) 
+			 FROM dbo.Attend
+			 JOIN dbo.Meetings mm ON dbo.Attend.MeetingId = mm.MeetingId
+			 WHERE mm.OrganizationId = o.OrganizationId 
+			 AND AttendanceFlag = 1 
+			 AND mm.MeetingDate > DATEADD(d, -@days, GETDATE()) 
+			 AND mm.MeetingDate < GETDATE())
+		lastmeeting,
+			(SELECT MAX(mm.MeetingDate)
+			FROM Attend 
+			JOIN dbo.Meetings mm ON dbo.Attend.MeetingId = mm.MeetingId
+			WHERE AttendanceFlag = 1 
+			AND mm.OrganizationId = o.OrganizationId
+			AND Attend.PeopleId = om.PeopleId)
+		lastattend,
+		ISNULL(o.ConsecutiveAbsentsThreshold, 2) ConsecutiveAbsentsThreshold
+	FROM 
+		(SELECT 
+			OrganizationId, 
+			PeopleId, 
+			COUNT(*) consecutive
+		 FROM dbo.Attend a
+		 WHERE MeetingDate > (SELECT MAX(MeetingDate)
+							  FROM Attend 
+							  WHERE AttendanceFlag = 1 
+							  AND a.OrganizationId = OrganizationId
+							  AND a.PeopleId = PeopleId
+							  GROUP BY OrganizationId, PeopleId)
+		 GROUP BY OrganizationId, PeopleId
+	    ) tt1
+	JOIN OrganizationMembers om ON tt1.OrganizationId = om.OrganizationId AND tt1.PeopleId = om.PeopleId
+	JOIN dbo.People p ON om.PeopleId = p.PeopleId
+	JOIN Organizations o ON om.OrganizationId = o.OrganizationId
+	JOIN lookup.MemberType mt ON om.MemberTypeId = mt.Id
+	JOIN lookup.AttendType at ON at.Id = mt.AttendanceTypeId
+	where (o.OrganizationId = @orgid OR @orgid IS NULL)
+	AND consecutive >= ISNULL(o.ConsecutiveAbsentsThreshold, 2)
+	AND at.Id NOT IN (70, 100) --inservice and homebound
+	AND om.MemberTypeId != 230 --inactive
+	AND (@divid IS NULL 
+		OR EXISTS(SELECT NULL 
+					FROM dbo.DivOrg 
+					WHERE OrgId = o.OrganizationId AND DivId = @divid))
+	ORDER BY o.OrganizationName, o.OrganizationId, consecutive, p.Name2
+END
+GO
+IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
+GO
+IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
+GO
+PRINT N'Creating [dbo].[ConsecutiveAbsents]'
+GO
+CREATE FUNCTION [dbo].[ConsecutiveAbsents](@orgid INT, @divid INT, @days INT)
+RETURNS TABLE
+AS
+RETURN
+(
+	WITH LastAbsents AS
+	(
+	  SELECT OrganizationId, PeopleId, MAX(MeetingDate) ld
+	  FROM Attend
+	  WHERE AttendanceFlag = 1
+	  GROUP BY OrganizationId, PeopleId
+	)
+	SELECT a.OrganizationId, a.PeopleId, count(*) As consecutive,
+			(SELECT MAX(MeetingDate) 
+			 FROM dbo.Attend aa 
+			 WHERE aa.PeopleId = a.PeopleId  
+			 AND aa.OrganizationId = a.OrganizationId 
+			 AND aa.AttendanceFlag = 1) 
+		lastattend
+	FROM dbo.Attend a
+	JOIN LastAbsents la 
+				ON la.OrganizationId = a.OrganizationId 
+				AND la.PeopleId = a.PeopleId
+				AND a.MeetingDate > la.ld
+			where (a.OrganizationId = @orgid OR @orgid IS NULL)
+			AND (@divid IS NULL 
+				OR EXISTS(SELECT NULL 
+							FROM dbo.DivOrg 
+							WHERE OrgId = a.OrganizationId AND DivId = @divid))
+	group by a.OrganizationId, a.PeopleId
+)
+/*
+	SELECT 
+		tt.OrganizationId, 
+		--o.OrganizationName, 
+		--o.LeaderName, 
+		consecutive,
+		tt.PeopleId,
+		--p.Name2,
+		--p.HomePhone,
+		--p.CellPhone,
+		--p.EmailAddress,
+			(SELECT MAX(MeetingDate) 
+			 FROM dbo.Attend aa 
+			 WHERE aa.PeopleId = tt.PeopleId  
+			 AND aa.OrganizationId = tt.OrganizationId 
+			 AND aa.AttendanceFlag = 1) 
+		lastattend
+		--lastmeeting,
+		--m.MeetingId,
+		--ConsecutiveAbsentsThreshold
+	FROM
+	(
+	SELECT a.OrganizationId, a.PeopleId, count(*) As consecutive
+	FROM dbo.Attend a
+	JOIN LastAbsents la 
+				ON la.OrganizationId = a.OrganizationId 
+				AND la.PeopleId = a.PeopleId
+				AND a.MeetingDate > la.ld
+	group by a.OrganizationId, a.PeopleId
+	) tt
+	JOIN dbo.Organizations o ON tt.OrganizationId = o.OrganizationId
+	JOIN dbo.Meetings m ON tt.OrganizationId = m.OrganizationId 
+		AND m.MeetingDate = ( SELECT MAX(a.MeetingDate) FROM dbo.Attend a
+							  JOIN dbo.Meetings mm ON mm.MeetingId = a.MeetingId
+							  WHERE mm.OrganizationId = tt.OrganizationId
+							  AND a.AttendanceFlag = 1 
+							  AND mm.MeetingDate > DATEADD(d, -@days, GETDATE()) 
+							  AND mm.MeetingDate < GETDATE()
+							)
+	JOIN OrganizationMembers om ON om.PeopleId = tt.PeopleId AND om.OrganizationId = o.OrganizationId
+	JOIN dbo.People p ON tt.PeopleId = p.PeopleId
+	JOIN lookup.MemberType mt ON om.MemberTypeId = mt.Id
+	JOIN lookup.AttendType at ON at.Id = mt.AttendanceTypeId
+	WHERE consecutive > ISNULL(ConsecutiveAbsentsThreshold, 2)
+	AND m.MeetingDate IS NOT NULL
+	AND at.Id NOT IN (70, 100) --inservice and homebound
+	AND om.MemberTypeId != 230 --inactive
+			AND (tt.OrganizationId = @orgid OR @orgid IS NULL)
+			AND (@divid IS NULL 
+				OR EXISTS(SELECT NULL 
+							FROM dbo.DivOrg 
+							WHERE OrgId = tt.OrganizationId AND DivId = @divid))
+*/	
+GO
+IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
+GO
+IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
+GO
 PRINT N'Creating [dbo].[AttendMeetingInfo]'
 GO
 CREATE PROCEDURE [dbo].[AttendMeetingInfo]
 GO
 PRINT N'Creating [dbo].[DeleteSpecialTags]'
 GO
--- =============================================
--- Author:		<Author,,Name>
--- Create date: <Create Date,,>
--- Description:	<Description,,>
--- =============================================
 CREATE PROCEDURE [dbo].[DeleteSpecialTags](@pid INT = null)
 AS
 BEGIN
 JOIN dbo.Tag t ON tp.Id = t.Id
 WHERE t.TypeId = 1 AND t.PeopleId IS NULL
 
+DELETE dbo.TagShare
+FROM dbo.TagShare s
+JOIN dbo.Tag t ON s.TagId = t.Id
+WHERE TypeId = 1 AND t.PeopleId IS NULL
+
 DELETE FROM dbo.Tag
 WHERE TypeId = 1 AND PeopleId IS NULL
 
 GO
 IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
 GO
+PRINT N'Creating [dbo].[StatusFlag]'
+GO
+CREATE FUNCTION [dbo].[StatusFlag] 
+(
+	@pid INT
+)
+
+RETURNS VARCHAR(50)
+AS
+BEGIN
+	DECLARE @Result VARCHAR(8000)
+
+SELECT @Result = COALESCE(@Result + ', ', '') + SUBSTRING(c.Description, 5, 50)
+FROM dbo.People p
+JOIN dbo.TagPerson tp ON p.PeopleId = tp.PeopleId
+JOIN dbo.Tag t ON tp.Id = t.Id
+JOIN dbo.QueryBuilderClauses c ON c.Description LIKE (t.Name + ':%')
+WHERE t.Name LIKE 'F[0-0][0-9]'
+
+AND c.GroupId IS NULL
+
+	RETURN @Result
+
+END
+
+GO
+IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
+GO
+IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
+GO
+PRINT N'Creating [dbo].[SaveUsers]'
+GO
+-- ================================================
+-- Template generated from Template Explorer using:
+-- Create Procedure (New Menu).SQL
+CREATE PROCEDURE [dbo].[SaveUsers]
+AS
+BEGIN
+	SET NOCOUNT ON;
+	
+	SELECT Name, EmailAddress, 
+		LEFT(Roles, LEN(Roles) -1) AS Roles
+	FROM (SELECT DISTINCT Name, EmailAddress,
+			(SELECT RoleName + ',' AS [text()] 
+			FROM Roles r
+			JOIN dbo.UserRole ur ON r.RoleId = ur.RoleId
+			WHERE ur.UserId = u.UserId
+			FOR XML PATH ('')) Roles
+	FROM dbo.Users u
+	WHERE EmailAddress NOT IN ('david@bvcms.com','karen@bvcms.com', 'support@bvcms.com')
+	) tt
+
+END
+GO
+IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
+GO
+IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
+GO
+PRINT N'Creating [dbo].[StatusFlags]'
+GO
+CREATE FUNCTION [dbo].[StatusFlags](@flags VARCHAR(100))
+RETURNS TABLE 
+AS
+RETURN 
+(
+SELECT PeopleId,
+SUBSTRING((Select ', ' + SUBSTRING(c.Description, 5, 50) AS [text()]
+FROM dbo.People p1
+JOIN dbo.TagPerson tp ON p1.PeopleId = tp.PeopleId
+JOIN dbo.Tag t ON tp.Id = t.Id
+JOIN dbo.QueryBuilderClauses c ON c.Description LIKE (t.Name + ':%')
+JOIN dbo.Split(@flags, ',') ff ON t.Name = ff.Value
+WHERE p1.PeopleId = p2.PeopleId
+ORDER BY ff.TokenID
+FOR XML PATH ('')),3, 1000) StatusFlags
+From dbo.People p2
+)
+GO
+IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
+GO
+IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
+GO
+PRINT N'Creating [dbo].[StatusGrid]'
+GO
+CREATE PROCEDURE [dbo].[StatusGrid](@tagid INT)
+AS
+BEGIN
+DECLARE @cases VARCHAR(MAX) = ''
+SELECT @cases = @cases +
+', MAX(CASE t.Name WHEN ''' + t.Name + ''' THEN ''X'' ELSE '''' END) AS [' 
++ REPLACE(
+	+ REPLACE(SUBSTRING(c.Description, 5, 50), ' ', '_')
+, '.', '_') + ']
+'
+FROM Tag t
+JOIN dbo.QueryBuilderClauses c ON LEFT(c.Description,3) = t.Name
+WHERE t.TypeId = 100
+GROUP BY t.Name, c.Description
+ORDER BY t.Name
+
+DECLARE @sql VARCHAR(MAX) = '
+SELECT 
+PreferredName First, 
+LastName Last, 
+ISNULL(CAST(Age AS VARCHAR),'''') Age, 
+ms.Description Marital,
+REPLACE(ISNULL(CONVERT(VARCHAR(10), dbo.FirstMeetingDateLastLear(p.PeopleId), 20), ''''), ''/'', ''-'') FirstAttend,
+tt.*
+FROM dbo.People p
+JOIN lookup.MaritalStatus ms on p.MaritalStatusId = ms.Id
+JOIN 
+(
+SELECT pp.PeopleId
+' + @cases +
+'FROM
+dbo.People pp
+JOIN dbo.TagPerson tp ON pp.PeopleId = tp.PeopleId
+JOIN Tag t ON tp.Id = t.Id
+WHERE t.Name LIKE ''F[0-9][0-9]''
+GROUP BY pp.PeopleId
+) tt
+ON p.PeopleId = tt.PeopleId
+WHERE EXISTS(SELECT NULL FROM dbo.TagPerson tp WHERE tp.Id = ' + CAST(@tagid AS VARCHAR)
++ ' AND tp.PeopleId = p.PeopleId)'
+PRINT @sql
+EXEC (@sql)
+END
+GO
+IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
+GO
+IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
+GO
+PRINT N'Creating [dbo].[ActivityAll]'
+GO
+
+CREATE VIEW [dbo].[ActivityAll]
+	AS
+	SELECT Machine, ActivityDate, ISNULL(u.Name, '') Name, ISNULL(g.UserId, 0) UserId, g.Activity FROM dbo.ActivityLog g
+	LEFT JOIN dbo.Users u ON g.UserId = u.UserId
+GO
+IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
+GO
+IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
+GO
 PRINT N'Creating [dbo].[UpdateAllMeetingCounters]'
 GO
 
 GO
 IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
 GO
+PRINT N'Creating [dbo].[ActivityOld]'
+GO
+CREATE TABLE [dbo].[ActivityOld]
+(
+[Id] [bigint] NOT NULL IDENTITY(1, 1),
+[ActivityDate] [datetime] NULL,
+[UserId] [int] NULL,
+[Activity] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
+[PageUrl] [varchar] (410) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
+[Machine] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
+[OrgId] [int] NULL,
+[PeopleId] [int] NULL
+)
+GO
+IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
+GO
+IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
+GO
 PRINT N'Creating [dbo].[Address]'
 GO
 CREATE TABLE [dbo].[Address]
 INSERT INTO [dbo].[QueryBuilderClauses] ([QueryId], [ClauseOrder], [GroupId], [Field], [Comparison], [TextValue], [DateValue], [CodeIdValue], [StartDate], [EndDate], [Organization], [Days], [SavedBy], [Description], [IsPublic], [CreatedOn], [Quarters], [SavedQueryIdDesc], [Tags], [Schedule], [Program], [Division], [Age], [Campus], [OrgType]) VALUES (67, 1, 66, 'RecentAttendCount', 'GreaterEqual', '1', NULL, NULL, NULL, NULL, 0, 365, NULL, NULL, 0, '2013-02-01T19:50:37.390', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL)
 INSERT INTO [dbo].[QueryBuilderClauses] ([QueryId], [ClauseOrder], [GroupId], [Field], [Comparison], [TextValue], [DateValue], [CodeIdValue], [StartDate], [EndDate], [Organization], [Days], [SavedBy], [Description], [IsPublic], [CreatedOn], [Quarters], [SavedQueryIdDesc], [Tags], [Schedule], [Program], [Division], [Age], [Campus], [OrgType]) VALUES (68, 1, 66, 'RecentHasIndContributions', 'Equal', NULL, NULL, '1,T', NULL, NULL, 0, 365, NULL, NULL, 0, '2013-02-01T19:50:37.390', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL)
 INSERT INTO [dbo].[QueryBuilderClauses] ([QueryId], [ClauseOrder], [GroupId], [Field], [Comparison], [TextValue], [DateValue], [CodeIdValue], [StartDate], [EndDate], [Organization], [Days], [SavedBy], [Description], [IsPublic], [CreatedOn], [Quarters], [SavedQueryIdDesc], [Tags], [Schedule], [Program], [Division], [Age], [Campus], [OrgType]) VALUES (69, 1, 60, 'IncludeDeceased', 'Equal', NULL, NULL, '1,T', NULL, NULL, 0, 0, NULL, NULL, 0, '2013-02-01T19:50:37.390', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL)
+INSERT INTO [dbo].[QueryBuilderClauses] ([QueryId], [ClauseOrder], [GroupId], [Field], [Comparison], [TextValue], [DateValue], [CodeIdValue], [StartDate], [EndDate], [Organization], [Days], [SavedBy], [Description], [IsPublic], [CreatedOn], [Quarters], [SavedQueryIdDesc], [Tags], [Schedule], [Program], [Division], [Age], [Campus], [OrgType]) VALUES (70, 0, NULL, 'Group', 'AllTrue', NULL, NULL, NULL, NULL, NULL, 0, 0, 'Public', 'F01:Recent New Visitor', 1, '2013-04-18T23:33:27.880', NULL, '0', NULL, 0, 0, 0, NULL, NULL, NULL)
+INSERT INTO [dbo].[QueryBuilderClauses] ([QueryId], [ClauseOrder], [GroupId], [Field], [Comparison], [TextValue], [DateValue], [CodeIdValue], [StartDate], [EndDate], [Organization], [Days], [SavedBy], [Description], [IsPublic], [CreatedOn], [Quarters], [SavedQueryIdDesc], [Tags], [Schedule], [Program], [Division], [Age], [Campus], [OrgType]) VALUES (71, 0, 70, 'RecentVisitNumber', 'Equal', NULL, NULL, '1,T', NULL, NULL, 0, 30, NULL, NULL, 0, '2013-04-18T23:33:27.887', '1', '0', NULL, 0, 0, 0, NULL, NULL, NULL)
+INSERT INTO [dbo].[QueryBuilderClauses] ([QueryId], [ClauseOrder], [GroupId], [Field], [Comparison], [TextValue], [DateValue], [CodeIdValue], [StartDate], [EndDate], [Organization], [Days], [SavedBy], [Description], [IsPublic], [CreatedOn], [Quarters], [SavedQueryIdDesc], [Tags], [Schedule], [Program], [Division], [Age], [Campus], [OrgType]) VALUES (72, 0, NULL, 'Group', 'AllTrue', NULL, NULL, NULL, NULL, NULL, 0, 0, 'Public', 'F02:Active Attender', 1, '2013-04-18T23:33:27.890', NULL, '0', NULL, 0, 0, 0, NULL, NULL, NULL)
+INSERT INTO [dbo].[QueryBuilderClauses] ([QueryId], [ClauseOrder], [GroupId], [Field], [Comparison], [TextValue], [DateValue], [CodeIdValue], [StartDate], [EndDate], [Organization], [Days], [SavedBy], [Description], [IsPublic], [CreatedOn], [Quarters], [SavedQueryIdDesc], [Tags], [Schedule], [Program], [Division], [Age], [Campus], [OrgType]) VALUES (73, 1, 72, 'RecentAttendCount', 'GreaterEqual', '10', NULL, '1,T', NULL, NULL, 0, 140, NULL, NULL, 0, '2013-04-18T23:33:27.890', NULL, '0', NULL, 0, 0, 0, NULL, NULL, NULL)
+INSERT INTO [dbo].[QueryBuilderClauses] ([QueryId], [ClauseOrder], [GroupId], [Field], [Comparison], [TextValue], [DateValue], [CodeIdValue], [StartDate], [EndDate], [Organization], [Days], [SavedBy], [Description], [IsPublic], [CreatedOn], [Quarters], [SavedQueryIdDesc], [Tags], [Schedule], [Program], [Division], [Age], [Campus], [OrgType]) VALUES (74, 0, NULL, 'Group', 'AllTrue', NULL, NULL, NULL, NULL, NULL, 0, 0, 'Public', 'F03:In Fellowship', 1, '2013-04-18T23:33:27.890', NULL, '0', NULL, 0, 0, 0, NULL, NULL, NULL)
+INSERT INTO [dbo].[QueryBuilderClauses] ([QueryId], [ClauseOrder], [GroupId], [Field], [Comparison], [TextValue], [DateValue], [CodeIdValue], [StartDate], [EndDate], [Organization], [Days], [SavedBy], [Description], [IsPublic], [CreatedOn], [Quarters], [SavedQueryIdDesc], [Tags], [Schedule], [Program], [Division], [Age], [Campus], [OrgType]) VALUES (75, 1, 74, 'InBFClass', 'Equal', NULL, NULL, '1,T', NULL, NULL, 0, 0, NULL, NULL, 0, '2013-04-18T23:33:27.890', NULL, '0', NULL, 0, 0, 0, NULL, NULL, NULL)
+INSERT INTO [dbo].[QueryBuilderClauses] ([QueryId], [ClauseOrder], [GroupId], [Field], [Comparison], [TextValue], [DateValue], [CodeIdValue], [StartDate], [EndDate], [Organization], [Days], [SavedBy], [Description], [IsPublic], [CreatedOn], [Quarters], [SavedQueryIdDesc], [Tags], [Schedule], [Program], [Division], [Age], [Campus], [OrgType]) VALUES (76, 0, NULL, 'Group', 'AllTrue', NULL, NULL, NULL, NULL, NULL, 0, 0, 'Public', 'F04:Member', 1, '2013-04-21T20:19:25.660', NULL, '0', NULL, 0, 0, 0, NULL, NULL, NULL)
+INSERT INTO [dbo].[QueryBuilderClauses] ([QueryId], [ClauseOrder], [GroupId], [Field], [Comparison], [TextValue], [DateValue], [CodeIdValue], [StartDate], [EndDate], [Organization], [Days], [SavedBy], [Description], [IsPublic], [CreatedOn], [Quarters], [SavedQueryIdDesc], [Tags], [Schedule], [Program], [Division], [Age], [Campus], [OrgType]) VALUES (77, 1, 76, 'MemberStatusId', 'Equal', NULL, NULL, '10,Yes', NULL, NULL, 0, 0, NULL, NULL, 0, '2013-04-21T20:19:25.660', NULL, '0', NULL, 0, 0, 0, NULL, NULL, NULL)
 SET IDENTITY_INSERT [dbo].[QueryBuilderClauses] OFF
 SET IDENTITY_INSERT [dbo].[Roles] ON
 INSERT INTO [dbo].[Roles] ([RoleId], [RoleName], [hardwired]) VALUES (1, 'Admin', 1)
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('DbConvertedDate', '5/19/2011')
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('DefaultHost', 'https://testdb.bvcms.com')
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('ImpersonatePassword', 'impersonate')
-INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('LastBatchRun', '2013-04-16T04:33:40')
+INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('LastBatchRun', '2013-04-29T04:33:12')
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('MaxExcelRows', '10000')
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('MinContributionAmount', '25')
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('NameOfChurch', 'Fake People')
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('NewPeopleManagerIds', '1')
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('QAServer', 'http://bbcsql:2021/')
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('RenderEmailTemplate', 'Local')
+INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('StatusFlags', 'F04,F01,F02,F03')
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('UseEmailTemplates', 'true')
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('UseMemberProfileAutomation', 'true')
 INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('UseStandardExtraValues', 'true')
+INSERT INTO [dbo].[Setting] ([Id], [Setting]) VALUES ('UseStatusFlags', 'false')
 INSERT INTO [dbo].[StreetTypes] ([Type]) VALUES ('ALLEE')
 INSERT INTO [dbo].[StreetTypes] ([Type]) VALUES ('ALLEY')
 INSERT INTO [dbo].[StreetTypes] ([Type]) VALUES ('ALLY')
 INSERT INTO [dbo].[Tag] ([Id], [Name], [TypeId], [Owner], [Active], [PeopleId]) VALUES (9, 'JustAdded', 1, NULL, NULL, 3)
 INSERT INTO [dbo].[Tag] ([Id], [Name], [TypeId], [Owner], [Active], [PeopleId]) VALUES (15, 'Fake People', 1, NULL, NULL, 3)
 INSERT INTO [dbo].[Tag] ([Id], [Name], [TypeId], [Owner], [Active], [PeopleId]) VALUES (21, 'JustAdded', 1, NULL, NULL, 2)
+INSERT INTO [dbo].[Tag] ([Id], [Name], [TypeId], [Owner], [Active], [PeopleId]) VALUES (71, 'F01', 100, NULL, NULL, NULL)
+INSERT INTO [dbo].[Tag] ([Id], [Name], [TypeId], [Owner], [Active], [PeopleId]) VALUES (72, 'F02', 100, NULL, NULL, NULL)
+INSERT INTO [dbo].[Tag] ([Id], [Name], [TypeId], [Owner], [Active], [PeopleId]) VALUES (73, 'F03', 100, NULL, NULL, NULL)
+INSERT INTO [dbo].[Tag] ([Id], [Name], [TypeId], [Owner], [Active], [PeopleId]) VALUES (74, 'F04', 100, NULL, NULL, NULL)
 SET IDENTITY_INSERT [dbo].[Tag] OFF
 INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (3, 2)
 INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (3, 3)
 INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (15, 146)
 INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (15, 147)
 INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (15, 148)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 2)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 3)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 5)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 6)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 7)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 8)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 9)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 13)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 23)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 24)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 28)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 29)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 35)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 41)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 42)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 43)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 44)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 45)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 46)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 47)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 53)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 54)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 55)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 56)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 57)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 61)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 62)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 64)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 66)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 67)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 69)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 70)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 75)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 78)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 79)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 80)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 81)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 87)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 92)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 94)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 95)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 99)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 100)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 102)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 106)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 110)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 111)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 112)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 113)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 114)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 118)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 122)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 123)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 130)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 133)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 147)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (73, 148)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 4)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 5)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 6)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 7)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 8)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 9)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 11)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 12)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 13)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 23)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 24)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 28)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 29)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 38)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 43)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 44)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 54)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 55)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 57)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 58)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 61)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 66)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 67)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 81)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 82)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 99)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 111)
+INSERT INTO [dbo].[TagPerson] ([Id], [PeopleId]) VALUES (74, 112)
 SET IDENTITY_INSERT [dbo].[Transaction] ON
 INSERT INTO [dbo].[Transaction] ([Id], [TransactionDate], [TransactionGateway], [DatumId], [testing], [amt], [ApprovalCode], [Approved], [TransactionId], [Message], [AuthCode], [amtdue], [URL], [Description], [Name], [Address], [City], [State], [Zip], [Phone], [Emails], [Participants], [OrgId], [OriginalId], [regfees], [donate], [fund], [financeonly], [voided], [credited], [coupon], [settled], [batch], [batchref], [batchtyp], [fromsage], [LoginPeopleId], [First], [MiddleInitial], [Last], [Suffix]) VALUES (1, NULL, 'ServiceU', 1, 1, 105.0000, NULL, NULL, NULL, NULL, NULL, 100.0000, 'https://starterdb.bvcms.com:443/onlinereg/Index/30?testing=true', 'Children''s Camp', 'George Eaton', NULL, NULL, NULL, NULL, NULL, '', NULL, 30, NULL, 105.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
 INSERT INTO [dbo].[Transaction] ([Id], [TransactionDate], [TransactionGateway], [DatumId], [testing], [amt], [ApprovalCode], [Approved], [TransactionId], [Message], [AuthCode], [amtdue], [URL], [Description], [Name], [Address], [City], [State], [Zip], [Phone], [Emails], [Participants], [OrgId], [OriginalId], [regfees], [donate], [fund], [financeonly], [voided], [credited], [coupon], [settled], [batch], [batchref], [batchtyp], [fromsage], [LoginPeopleId], [First], [MiddleInitial], [Last], [Suffix]) VALUES (2, '2011-05-29T20:22:44.433', 'ServiceU', 2, 1, 105.0000, NULL, 1, 'Coupon(Admin)(testing)', 'Transaction Completed', NULL, 100.0000, 'https://starterdb.bvcms.com:443/onlinereg/Index/30?testing=true', 'Children''s Camp', 'Jackson Eaton', NULL, NULL, NULL, NULL, NULL, '"Sharon Eaton" <karen@bvcms.com>', 'Org: Children''s Camp<br/>

CmsCheckin/CmsCheckin.csproj

     <CreateDesktopShortcut>true</CreateDesktopShortcut>
     <PublishWizardCompleted>true</PublishWizardCompleted>
     <BootstrapperEnabled>false</BootstrapperEnabled>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
       <DependentUpon>StartUp.cs</DependentUpon>
     </EmbeddedResource>
     <None Include="app.config" />
+    <None Include="packages.config" />
     <None Include="Properties\DataSources\Match.datasource" />
     <None Include="Settings1.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
   </ItemGroup>
   <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">

CmsCheckin/packages.config

+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="ZXing.Net" version="0.11.0.1" targetFramework="net40-Client" />
+</packages>

CmsWeb/Areas/Dialog/Views/AddAttendeesFromTag/Progress.cshtml

 @{
-    CassetteConfiguration.BundleRefCss();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefJs();
 }
 @model CmsData.AddToOrgFromTagRun
 @using CmsWeb

CmsWeb/Areas/Dialog/Views/AddOrganization/Index.cshtml

 @using CmsWeb
 @using UtilityExtensions
 @{
-    CassetteConfiguration.BundleRefCss();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefJs();
 }
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>

CmsWeb/Areas/Dialog/Views/AddToOrgFromTag/Progress.cshtml

 @model CmsData.AddToOrgFromTagRun
 @using CmsWeb
 @{
-    CassetteConfiguration.BundleRefCss();
-    CassetteConfiguration.BundleRefJs(); 
+    CassetteBundleConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefJs(); 
     Bundles.Reference("OrgMembersDialog");
 }
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

CmsWeb/Areas/Dialog/Views/DeleteMeeting/Progress.cshtml

 @model CmsData.DeleteMeetingRun
 @using CmsWeb
 @{
-    CassetteConfiguration.BundleRefCss();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("OrgMembersDialog");
 }
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

CmsWeb/Areas/Dialog/Views/OrgMemberDialog/Index.cshtml

 @using CmsWeb
 @model CmsData.OrganizationMember
 @{
-    CassetteConfiguration.BundleRefCss();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("OrgMemberDialog");
 }
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

CmsWeb/Areas/Dialog/Views/OrgMembersDialog/Index.cshtml

 @model CmsWeb.Models.OrgMembersDialogModel
 @using CmsWeb
 @{
-    CassetteConfiguration.BundleRefCss();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("OrgMembersDialog");
 }
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

CmsWeb/Areas/Dialog/Views/OrgMembersDialog/Update.cshtml

 @using CmsWeb
 @{
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
 }
 <html>
     @Bundles.RenderScripts()

CmsWeb/Areas/Dialog/Views/RepairTransactions/Progress.cshtml

 @model CmsData.RepairTransactionsRun
 @using CmsWeb
 @{
-    CassetteConfiguration.BundleRefCss();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("OrgMembersDialog");
 }
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

CmsWeb/Areas/Dialog/Views/SearchAdd/Index.cshtml

 @model CmsWeb.Models.SearchModel
 @using CmsWeb
 @{
-    CassetteConfiguration.BundleRefCss();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
         @<text>
             @Html.Partial("DatePickerDefaults")

CmsWeb/Areas/Dialog/Views/SearchDivisions/Index.cshtml

 @using CmsWeb.Models
 @using CmsWeb
 @{
-    CassetteConfiguration.BundleRefCss();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("SearchDivisions");
 }
 <html>

CmsWeb/Areas/Dialog/Views/SearchOrgs/Index.cshtml

 @using CmsWeb
 @model SearchOrgsModel
 @{
-    CassetteConfiguration.BundleRefCss();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("SearchOrgs");
 }
 <html>

CmsWeb/Areas/Dialog/Views/TransactionHistory/Index.cshtml

 @using UtilityExtensions
 @{
     Layout = null;
-    CassetteConfiguration.BundleRefCss();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
         @<text>
             @Html.Partial("DatePickerDefaults")

CmsWeb/Areas/Finance/Models/PostBundleModel.cs

         public object GetNamePidFromId()
         {
             IEnumerable<object> q;
-            if (pid.Length > 0 && (pid[0] == 'e' || pid[0] == '-'))
+            if (pid != null && pid.Length > 0 && (pid[0] == 'e' || pid[0] == '-'))
             {
                 var env = pid.Substring(1).ToInt();
                 q = from e in DbUtil.Db.PeopleExtras

CmsWeb/Areas/Finance/Views/Bundle/Index.cshtml

 @{
     ViewBag.Title = "Contribution Bundles";
     Layout = "/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("bundle");
 }
 @section head 

CmsWeb/Areas/Finance/Views/Bundles/Index.cshtml

 @{
     ViewBag.Title = "Contribution Bundles";
     Layout = "/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("bundles");
 }
 <table class="roundbox">

CmsWeb/Areas/Finance/Views/Contributions/Index.cshtml

 @{
     ViewBag.Title = "Contributions";
     Layout = "/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
         @<script src="/Scripts/js/Contributions.js"></script>);
 }

CmsWeb/Areas/Finance/Views/FinanceReports/ContributionYears.cshtml

 @{
     Layout = "/Views/Shared/Reports.cshtml";
     ViewBag.Title = "ContributionYears";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
     @<script type="text/javascript">
         $(function () {

CmsWeb/Areas/Finance/Views/FinanceReports/DonorTotalsByRange.cshtml

 @{
     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "Donor Totals By Range";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("TotalsByRange");
 }
 @section head

CmsWeb/Areas/Finance/Views/FinanceReports/ManagedGiving.cshtml

 @{
 	ViewBag.Title = "ManagedGiving";
     Layout = "/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
         @<script type="text/javascript">
             $(function () {

CmsWeb/Areas/Finance/Views/FinanceReports/TotalsByFund.cshtml

     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "Totals By Fund";
     var qbh = new QuickBooksHelper();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("TotalsByFund");
 }
 @section head

CmsWeb/Areas/Finance/Views/Fund/Index.cshtml

 @{
     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "Funds";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("Funds");
 }
 

CmsWeb/Areas/Finance/Views/PostBundle/Index.cshtml

 @{
     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "PostBundle";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("PostBundle");
 }
 @section head 

CmsWeb/Areas/Finance/Views/Statements/Index.cshtml

 @{
     Layout = "/Views/Shared/Reports.cshtml";
     ViewBag.Title = "Contribution Statements";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
     @<script>
         $(function() {

CmsWeb/Areas/Finance/Views/Statements/Progress.cshtml

 @using CmsWeb
 @using UtilityExtensions
 @{
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
 }
 <html>
 <head>

CmsWeb/Areas/Main/Models/Other/PeopleSearchModel.cs

             if (m.marital != 99)
                 qb.AddNewClause(QueryType.MaritalStatusId, CompareType.Equal,
                                 QueryModel.IdCode(cv.MaritalStatusCodes(), m.marital));
-            foreach (var f in m.statusflags)
-                qb.AddNewClause(QueryType.StatusFlag, CompareType.Equal,
-                                QueryModel.IdCode(cv.StatusFlags(), f));
+            if(m.statusflags != null)
+                foreach (var f in m.statusflags)
+                    qb.AddNewClause(QueryType.StatusFlag, CompareType.Equal,
+                                    QueryModel.IdCode(cv.StatusFlags(), f));
             qb.AddNewClause(QueryType.IncludeDeceased, CompareType.Equal, "1,T");
             DbUtil.Db.SubmitChanges();
             return qb.QueryId;

CmsWeb/Areas/Main/Views/ContactSearch/ContactTypeTotals.cshtml

 @{
     ViewBag.Title = "ContactTypeTotals";
     Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
     @<script>
         $(function() {

CmsWeb/Areas/Main/Views/ContactSearch/Index.cshtml

 @{
     ViewBag.Title = "ContactSearch";
     Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("ContactSearch");
 }
 <form action="" id="form" method="POST">

CmsWeb/Areas/Main/Views/Coupon/Index.cshtml

 @{
     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "Coupon";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
 @<script>
     $(function () {

CmsWeb/Areas/Main/Views/Coupon/List.cshtml

 @using UtilityExtensions
 @model CmsWeb.Models.CouponModel
 @{
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
 }
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" >

CmsWeb/Areas/Main/Views/Email/Compose.cshtml

 			  where e.Id == tID
 			  select e;
     var c = t.FirstOrDefault();
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
         @<script src="/ckeditor2/ckeditor.js" type="text/javascript"></script>
         );

CmsWeb/Areas/Main/Views/Email/Index.cshtml

 @{
     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "Email";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
         @<script src="/ckeditor2/ckeditor.js" type="text/javascript"></script>);
     Bundles.Reference("email");

CmsWeb/Areas/Main/Views/Email/SelectTemplate.cshtml

     Layout = "~/Views/Shared/SiteLayout.cshtml";
 	 const int WRAP_COUNT = 3;
 	 var wrapAt = WRAP_COUNT;
-     CassetteConfiguration.BundleRefJs();
+     CassetteBundleConfiguration.BundleRefJs();
      Bundles.AddInlineScript(
 	@<script type="text/javascript">
 		$(document).ready(function () {

CmsWeb/Areas/Main/Views/Family/Index.cshtml

 @{
     ViewBag.Title = "Family";
     Layout = "/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("family");
 }
 @section head

CmsWeb/Areas/Main/Views/Meeting/Index.cshtml

 @{
     ViewBag.Title = "Meeting";
     Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("meeting");
     if (!Model.meeting.GroupMeetingFlag)
     {

CmsWeb/Areas/Main/Views/Meeting/iPad.cshtml

 <head>
     <title>Page Title</title>
     <meta name="viewport" content="width=device-width, initial-scale=1" />
-	<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
-	<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
-	<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
-    <script src="~/Scripts/meeting-ipad.js"></script>
+    <link href="~/Content/jquery.mobile-1.3.0.min.css" rel="stylesheet" />
+    <script src="~/Scripts/jQuery/jquery-1.9.1.min.js"></script>
+    <script src="~/Scripts/Mobile/jquery.mobile-1.3.0.min.js"></script>
+    <script src="~/Scripts/Meeting/meeting-ipad.js"></script>
 </head>
 <body>
     @Html.Hidden("meetingid", Model.meeting.MeetingId)

CmsWeb/Areas/Main/Views/Meeting/tickets.cshtml

 @{
     ViewBag.Title = "Meeting Tickets";
     Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("meeting-ticket");
 }
 

CmsWeb/Areas/Main/Views/MemberDirectory/Index.cshtml

 @{
     ViewBag.Title = "Member Directory";
     Layout = "/Views/Shared/Reports.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
     @<script type="text/javascript">
         $(function() {

CmsWeb/Areas/Main/Views/MemberDocs/Index.cshtml

 @{
     ViewBag.Title = "MembershipDocs";
     Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
     @<script type="text/javascript">
         $(function () {

CmsWeb/Areas/Main/Views/OrgChildren/Index.cshtml

 @{
     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "OrgChildren";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("OrgChildren");
 }
 @section head

CmsWeb/Areas/Main/Views/OrgGroups/Index.cshtml

 @{
     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "OrgGroups";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("OrgGroups");
 }           
 @section head

CmsWeb/Areas/Main/Views/OrgSearch/Index.cshtml

 @{
     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "OrgSearch";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("OrgSearch");
 }
 <form id="orgsearchform" method="post">

CmsWeb/Areas/Main/Views/OrgSearch/Results.cshtml

 @using UtilityExtensions
 @model CmsWeb.Models.OrgSearchModel
-@section scripts
-{
     @if (User.IsInRole("edit"))
     {
     <script type="text/javascript">
         });
     </script>
     }
-}
 
 <table id="results" class="grid">
 <thead>

CmsWeb/Areas/Main/Views/Organization/Index.cshtml

     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "Organization";
     Bundles.Reference("orgcss");
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
         @<script src="/ckeditor2/ckeditor.js" type="text/javascript"></script>);
     Bundles.Reference("org");

CmsWeb/Areas/Main/Views/PeopleSearch/Index.cshtml

 @{
 	ViewBag.Title = "People Search";
 	Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("PeopleSearch");
 }
 @section head 

CmsWeb/Areas/Main/Views/Person/Index.cshtml

     var isfinance = User.IsInRole("Finance");
     var ismanager = User.IsInRole("Manager");
     var memberedit = isadmin || User.IsInRole("Membership");
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("person");
     if(memberedit)
     {

CmsWeb/Areas/Main/Views/Person/UserDialog.cshtml

 @using CmsWeb
 @model CmsData.User
 @{
-    CassetteConfiguration.BundleRefCss();
+    CassetteBundleConfiguration.BundleRefCss();
     Bundles.Reference("dialogcss");
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("UserDialog");
 }
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

CmsWeb/Areas/Main/Views/QueryBuilder/Main.cshtml

 @{
     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "SearchBuilder";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("querybuilder");
 }
 @section head 

CmsWeb/Areas/Main/Views/QuickSearch/Index.cshtml

 	ViewBag.Title = "Quick Search";
 	Layout = "~/Views/Shared/SiteLayout.cshtml";
     var target = Util2.TargetLinkPeople ? "target='people'" : "";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("QuickSearch");
 }
 <form id="quicksearch" method="post" action="/QuickSearch/Index">

CmsWeb/Areas/Main/Views/RegSetting/Edit.cshtml

 @{
     ViewBag.Title = "EditRegSetting";
     Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
     @<script type="text/javascript">
         $(function () {

CmsWeb/Areas/Main/Views/RegSetting/Index.cshtml

 @{
     ViewBag.Title = "RegSetting";
     Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
 @<script type="text/javascript">
     $(function () {

CmsWeb/Areas/Main/Views/Reports/Attendance.cshtml

 @{
     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "AttendanceReport";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
     @<script type="text/javascript">
         $(function() {

CmsWeb/Areas/Main/Views/Reports/ChurchAttendance.cshtml

 @{
     Layout = "/Views/Shared/Reports.cshtml";
     ViewBag.Title = "ChurchAttendanceReport";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("ChurchAttendance");
 }
 @section head {

CmsWeb/Areas/Main/Views/Reports/ChurchAttendance2.cshtml

 @{
     Layout = "/Views/Shared/Reports.cshtml";
     ViewBag.Title = "AvgChurchAttendanceReport";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
     @<script type="text/javascript">
         $(function() {

CmsWeb/Areas/Main/Views/Reports/ExtraValues.cshtml

 @{
     ViewBag.Title = "ExtraValues";
     Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
     @<script type="text/javascript">
         $(function () {

CmsWeb/Areas/Main/Views/Reports/ExtraValuesGrid.cshtml

     ViewBag.Title = "ExtraValuesGrid";
     Layout = "~/Views/Shared/SiteLayout.cshtml";
     var target = Util2.TargetLinkPeople ? "target='people'" : "";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
     @<script src="/Content/js/FixedHeader.js" type="text/javascript"></script>);
     Bundles.AddInlineScript(

CmsWeb/Areas/Main/Views/Reports/Meetings.cshtml

 @{
     ViewBag.Title = "Meetings";
     Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("Meetings");
 }
 <h2>Meetings</h2>

CmsWeb/Areas/Main/Views/SMS/Options.cshtml

 
     var groups = TwilioHelper.getAvailableLists(Util.UserId);
     var count = TwilioHelper.getSendCount(ViewBag.QBID);
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
     @<script type="text/javascript">
         var maxSMS = 160;

CmsWeb/Areas/Main/Views/SavedQuery/Index.cshtml

 @{
     ViewBag.Title = "SavedQuery";
     Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("SavedQuery");
 }
 <div class="roundbox" style="display: table">

CmsWeb/Areas/Main/Views/Tags/Index.cshtml

 @{
 	ViewBag.Title = "Tags";
 	Layout = "~/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("SearchUsers");
     Bundles.Reference("Tags");
 }

CmsWeb/Areas/Main/Views/Task/List.cshtml

 @{
     Layout = "/Views/Shared/SiteLayout.cshtml";
     ViewBag.Title = "Tasks";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("task");
 }
 

CmsWeb/Areas/Main/Views/Volunteering/Edit.cshtml

     Layout = "/Views/Shared/SiteLayout.cshtml";
     var s = from e in DbUtil.Db.VolApplicationStatuses
             select e;
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.AddInlineScript(
 @<script type="text/javascript">
     $(function () {

CmsWeb/Areas/Main/Views/Volunteering/Index.cshtml

 @{
     ViewBag.Title = "Volunteer";
     Layout = "/Views/Shared/SiteLayout.cshtml";
-    CassetteConfiguration.BundleRefJs();
+    CassetteBundleConfiguration.BundleRefJs();
     Bundles.Reference("volunteering");
 
     IQueryable<BackgroundCheck> bg = null;

CmsWeb/Areas/Manage/Controllers/AccountController.cs

 using System.Web.Configuration;
 using System.Data.SqlClient;
 using CmsWeb.Models;
-using Rackspace.CloudFiles.Domain;
+using net.openstack.Core.Domain;
+using net.openstack.Providers.Rackspace;
+using User = CmsData.User;
 
 namespace CmsWeb.Areas.Manage.Controllers
 {
 				baseurl = rackspacecdn;
 				var username = ConfigurationManager.AppSettings["RackspaceUser"];
 				var key = ConfigurationManager.AppSettings["RackspaceKey"];
-				var userCreds = new UserCredentials(username, key);
-	            var connection = new Rackspace.CloudFiles.Connection(userCreds);
-                connection.PutStorageItem("AllFiles", file.InputStream, fn);
+                var cloudIdentity = new CloudIdentity() { APIKey = key, Username = username };
+                var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
+                cloudFilesProvider.CreateObject("AllFiles", file.InputStream, fn);
 			}
 			else // local server
 			{

CmsWeb/Areas/Manage/Models/UploadPeopleModel.cs

         private void UpdateField(Person p, string[] a, string prop, string s, object value)
         {
             if (names.ContainsKey(s))
+                if (value != null)
+                    p.UpdateValue(psb, prop, value);
+        }
+
+        private void SetField(Family f, string[] a, string prop, string s)
+        {
+            if (names.ContainsKey(s))
                 if (a[names[s]].HasValue())
-                    p.UpdateValue(psb, prop, value);
+                    Util.SetProperty(f, prop, a[names[s]]);
+        }
+
+        private void SetField(Person p, string[] a, string prop, string s)
+        {
+            if (names.ContainsKey(s))
+                if (a[names[s]].HasValue())
+                    Util.SetProperty(p, prop, a[names[s]]);
+        }
+
+        private void SetField(Person p, string[] a, string prop, string s, object value)
+        {
+            if (names.ContainsKey(s))
+                if (value != null)
+                    Util.SetProperty(p, prop, a[names[s]]);
         }
 
         private string GetDigits(string[] a, string s)
 
         private int Gender(string[] a)
         {
-            if (names.ContainsKey("Gender"))
-                if (a[names["Gender"]].HasValue())
+            if (names.ContainsKey("gender"))
+                if (a[names["gender"]].HasValue())
                 {
-                    var v = a[names["Gender"]].TrimEnd();
+                    var v = a[names["gender"]].ToLower().TrimEnd();
                     switch (v)
                     {
-                        case "Male":
-                        case "M":
+                        case "male":
+                        case "m":
                             return 1;
-                        case "Female":
-                        case "F":
+                        case "female":
+                        case "f":
                             return 2;
                     }
                 }
             return 0;
         }
 
-        private int Marital(string i, string[] a)
+        private int Marital(string[] a)
         {
-            if (names.ContainsKey(i))
-                if (a[names[i]].HasValue())
+            if (names.ContainsKey("marital"))
+                if (a[names["marital"]].HasValue())
                 {
-                    var v = a[names[i]].TrimEnd();
+                    var v = a[names["marital"]].ToLower().TrimEnd();
                     switch (v)
                     {
-                        case "Married":
-                        case "M":
+                        case "married":
+                        case "m":
                             return 20;
-                        case "Single":
-                        case "S":
+                        case "single":
+                        case "s":
                             return 10;
-                        case "Widowed":