DECLARE @prodCount As int = 0
SET @prodCount = (Select Count(*) FROM pal_Product)
TRUNCATE TABLE pal_Module
SET IDENTITY_INSERT [dbo].[pal_Module] ON 
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) 
VALUES (1, N'Content', 1, N'Admin_Content.aspx', N'module/content.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) 
VALUES (3, N'Users', 3, N'Admin_Users.aspx', NULL, 1, 0, 1, NULL, NULL, NULL, 1, NULL)
IF @prodCount > 0
BEGIN 
	INSERT INTO  [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) 
	VALUES (4, N'Products', 4, N'Admin_Products.aspx', N'module/featuredProducts.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL) 
END 
ELSE
BEGIN 
	INSERT INTO  [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) 
	VALUES (4, N'Products', 4, N'Admin_Products.aspx', N'module/featuredProducts.ascx', 0, 1, NULL, NULL, NULL, NULL, NULL, NULL) 
END

INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (5, N'Product Categories', 5, N'Admin_ProductCategories.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (6, N'Product Brands', 6, N'Admin_ProductBrands.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (7, N'Banners', 7, N'Admin_Banners.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (8, N'Templates', 8, N'Admin_Templates.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (9, N'Gallery', 9, N'Admin_Gallery.aspx', NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (10, N'Surface', 10, N'Admin_Surface.aspx', N'surface/surface.ascx', 1, 1, 1, N'oSurface', NULL, NULL, 1, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (11, N'Canvas', 11, N'Admin_Canvas.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (12, N'Practices', 12, N'Medical_Practices.aspx', NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (13, N'Doctors', 13, N'Medical_Doctors.aspx', NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (14, N'Tariffs', 14, N'Medical_Tariffs.aspx', N'medical/tariffs.ascx', 1, 1, 1, N'oTariffPlan', N'name', N'code', NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (15, N'Procedures', 15, N'Medical_Procedures.aspx', N'medical/procedures.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (16, N'Medical Schemes', 16, N'Medical_Schemes.aspx', N'medical/schemes.ascx', 1, 1, 1, N'oMedicalScheme', N'name', N'code', NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (17, N'Notes', 17, N'', NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (18, N'Debtors Reports', 18, N'', N'module/debtorsReports.ascx', 0, 1, 0, N'', N'', N'', NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (19, N'Tasks', 19, N'Admin_Tasks.aspx', N'module/task.ascx', 1, 0, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (20, N'FAQ', 20, N'Admin_FAQ.aspx', N'module/faq.ascx', 1, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (21, N'Medical Administrators', 21, N'Medical_MedAdmins.aspx', NULL, 1, 0, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (22, N'Calendar', 22, N'Admin_Calendar.aspx', N'module/calendar.ascx', 1, 1, 0, N'calendar', NULL, NULL, 0, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (23, N'ICD10', 23, N'Medical_ICD10.aspx', N'medical/icd10.ascx', 1, 0, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (24, N'Enquiry', 24, N'', N'module/enquiry.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (25, N'Promotions', 25, N'Admin_Promotions.aspx', NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (26, N'Sales', 26, N'', N'module/sales.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (27, N'Products and Services', 27, N'Sales_SalesItems.aspx', N'sales/items.ascx', 1, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (28, N'Company Setup', 28, N'Admin_Setup.aspx', N'admin/setup.ascx', 1, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (29, N'Medical Symptoms Manager', 29, N'Medical_Symptoms.aspx', N'medical/symptoms.ascx', 1, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (30, N'Medical Conditions Manager', 30, N'Medical_Conditions.aspx', N'medical/conditions.ascx', 1, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (31, N'BodyMap', 31, NULL, N'module/bodyMap.ascx', 1, 0, 0, N'bodyMap', NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (32, N'Medical History', 32, NULL, N'module/medicalHistory.ascx', 1, 0, 0, N'medicalHistory', NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (33, N'Medical Symptoms', 33, NULL, N'module/medicalSymptoms.ascx', 1, 0, 0, N'medicalSymptoms', NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (34, N'Medical Listings', 34, NULL, N'module/medicalListings.ascx', 1, 0, 0, N'medicalListings', NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (35, N'Medical Subjectives', 35, NULL, N'module/medicalSubjectives.ascx', 1, 0, 0, N'medicalSubjectives', NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (36, N'Medical Patient Sign In', 36, NULL, N'module/medicalPatientSignin.ascx', 1, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (37, N'Campaigns', 37, N'Admin_Campaigns.aspx', N'admin/campaigns.ascx', 1, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (38, N'Diagnosis', 38, N'Medical_Diagnosis.aspx', N'module/diagnosis.ascx', 1, 0, 0, N'diagnosis', NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (39, N'Image Map', 39, NULL, N'module/imageMap.ascx', 1, 0, 0, N'imageMap', NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (40, N'Procedure Booking', 40, NULL, N'module/procedureBooking.ascx', 1, 0, 0, N'procedureBooking', NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (41, N'Medical Complaints', 41, NULL, N'module/medicalComplaints.ascx', 1, 0, 0, N'medicalComplaints', NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (42, N'Practice Extras Manager', 42, N'Medical_PracticeExtras.aspx', N'medical/practiceExtras.ascx', 1, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (43, N'Practice Extras', 43, NULL, N'module/medicalPracticeExtras.ascx', 1, 0, 0, N'medicalPracticeExtras', NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (44, N'Medical Patient Que', 44, NULL, N'module/medicalPatientQue.ascx', 1, 1, 0, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (45, N'Media', 45, N'Admin_Media.aspx', N'module/media.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (46, N'Medical Trauma Manager', 46, N'Medical_Trauma.aspx', N'medical/traumaticEvents.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (47, N'Loyalty Stores', 47, N'Admin_LoyaltyStores.aspx', N'admin/loyaltyStores.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (48, N'Loyalty Groups', 48, N'Admin_LoyaltyGroups.aspx', N'admin/loyaltyGroups.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (49, N'Loyalty Members', 49, N'', N'module/loyaltyMembers.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (50, N'Report', 50, N'Admin_Report.aspx', N'module/report.ascx', 1, 1, NULL, NULL, NULL, NULL, 0, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (51, N'Surface Item Code', 51, N'Admin_SurfaceCode.aspx', N'admin/surfaceCodes.ascx', 1, 1, 1, N'oSurfaceItemCode', N'code', N'code', NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (52, N'Surface Notes', 52, NULL, N'module/surfaceNotes.ascx', 1, 0, 0, NULL, NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (53, N'Job cards', 53, N'Admin_Jobcards.aspx', N'module/jobcards.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (54, N'SMS Credits', 54, N'Admin_SMSCredit.aspx', N'admin/smsCredit.ascx', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (55, N'Image Gallery', 55, NULL, N'admin/surfaceGallery.ascx', 1, 0, 0, NULL, NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (56, N'Report Builder', 56, N'Admin_Report.aspx', N'admin/report.ascx', 1, 1, NULL, NULL, NULL, NULL, 0, NULL)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (57, N'Surface Communication', 57, NULL, N'module/surfaceComms.ascx', 1, 0, 0, NULL, NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (58, N'Billing Instructions', 58, NULL, N'admin/billingInstructions.ascx', 1, 0, 0, NULL, NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (59, N'Video Gallery', 59, NULL, N'admin/surfaceGalleryVideo.ascx', 1, 0, 0, NULL, NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (60, N'Surface Event', 60, NULL, N'module/surfaceEvents.ascx', 1, 0, 0, NULL, NULL, NULL, NULL, 1)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (61, N'Surface Copy', 61, N'Admin_SurfaceCopy.aspx', N'admin/surfaceCopy.ascx', 1, 1, 0, NULL, NULL, NULL, NULL, 0)
INSERT [dbo].[pal_Module] ([recId], [module], [sequence], [path], [control], [isActive], [isCanvas], [isPicklist], [objectName], [displayField], [valueField], [isCalendar], [isSurfaceField]) VALUES (62, N'File Uploader', 62, NULL, N'admin/fileUploader.ascx', 1, 0, 0, NULL, NULL, NULL, NULL, 1)

SET IDENTITY_INSERT [dbo].[pal_Module] OFF
DBCC CHECKIDENT ('pal_Module', RESEED, 62);
