DROP TABLE IF EXISTS phpCalendar_AdminSessions;
CREATE TABLE phpCalendar_AdminSessions (
   AdminUserID int(10) unsigned DEFAULT '0' NOT NULL,
   Date date DEFAULT '0000-00-00' NOT NULL,
   SessionID varchar(100) NOT NULL,
   KEY AdminUserID (AdminUserID),
   KEY SessionID (SessionID)
);

DROP TABLE IF EXISTS phpCalendar_AdminUsers;
CREATE TABLE phpCalendar_AdminUsers (
   Username varchar(100) NOT NULL,
   Password varchar(100) NOT NULL,
   Salutation varchar(100) NOT NULL,
   FirstName varchar(100) NOT NULL,
   LastName varchar(100) NOT NULL,
   Title varchar(100) NOT NULL,
   Email varchar(100) NOT NULL,
   LocationID int(10) unsigned DEFAULT '0' NOT NULL,
   AdminUserID bigint(20) unsigned NOT NULL auto_increment,
   PRIMARY KEY (AdminUserID),
   UNIQUE AdminUserID (AdminUserID),
   KEY Username (Username, Password)
);

DROP TABLE IF EXISTS phpCalendar_Config;
CREATE TABLE phpCalendar_Config (
   LocationTitle varchar(100) NOT NULL,
   AllowPublicSubmission tinyint(1) unsigned DEFAULT '0' NOT NULL,
   ApprovePublicSubmission tinyint(1) unsigned DEFAULT '0' NOT NULL,
   ApprovalBySiteAdmin tinyint(1) unsigned DEFAULT '0' NOT NULL,
   ApprovalByLocationAdmin tinyint(1) unsigned DEFAULT '0' NOT NULL,
   AllowCrossLocationSubmission tinyint(1) unsigned DEFAULT '0' NOT NULL,
   DefaultView varchar(100) NOT NULL,
   AllowMonth tinyint(1) unsigned DEFAULT '0' NOT NULL,
   AllowWeek tinyint(1) unsigned DEFAULT '0' NOT NULL,
   AllowDay tinyint(1) unsigned DEFAULT '0' NOT NULL,
   UseEventLocation tinyint(1) unsigned DEFAULT '0' NOT NULL,
   TruncateLength tinyint(20) unsigned DEFAULT '0' NOT NULL,
   SiteTitle tinytext NOT NULL,
   AllowEventPrint tinyint(1) unsigned DEFAULT '0' NOT NULL,
   AdminEmail varchar(100) NOT NULL
);


INSERT INTO phpCalendar_Config VALUES ( 'Category', '1', '1', '0', '1', '0', 'month', '1', '1', '1', '1', '15', 'AppIdeas.com Community Calendar', '1', 'you@yourdomain.com');


DROP TABLE IF EXISTS phpCalendar_Daily;
CREATE TABLE phpCalendar_Daily (
   StartDate date DEFAULT '0000-00-00' NOT NULL,
   StopDate date DEFAULT '0000-00-00' NOT NULL,
   Active tinyint(1) unsigned DEFAULT '0' NOT NULL,
   LocationID bigint(20) unsigned DEFAULT '0' NOT NULL,
   CalendarDetailsID bigint(20) unsigned DEFAULT '0' NOT NULL,
   PRIMARY KEY (CalendarDetailsID),
   KEY CalendarDetailsID_2 (CalendarDetailsID),
   KEY LocationID (LocationID)
);


DROP TABLE IF EXISTS phpCalendar_Details;
CREATE TABLE phpCalendar_Details (
   Title varchar(100) NOT NULL,
   Details text NOT NULL,
   ContactName varchar(100) NOT NULL,
   ContactPhone varchar(100) NOT NULL,
   ContactEmail varchar(100) NOT NULL,
   ContactWeb varchar(100) NOT NULL,
   EventLocationID bigint(20) unsigned DEFAULT '0' NOT NULL,
   StartTime time DEFAULT '00:00:00' NOT NULL,
   StopTime time DEFAULT '00:00:00' NOT NULL,
   ShowStart tinyint(1) DEFAULT '0' NOT NULL,
   ShowStop tinyint(1) DEFAULT '0' NOT NULL,
   LocationID bigint(20) unsigned DEFAULT '0' NOT NULL,
   CalendarDetailsID bigint(20) unsigned NOT NULL auto_increment,
   PRIMARY KEY (CalendarDetailsID),
   UNIQUE CalendarDetailsID (CalendarDetailsID),
   KEY LocationID (LocationID)
);


DROP TABLE IF EXISTS phpCalendar_EventLocations;
CREATE TABLE phpCalendar_EventLocations (
   Title varchar(100) NOT NULL,
   Address1 varchar(100) NOT NULL,
   Address2 varchar(100) NOT NULL,
   City varchar(100) NOT NULL,
   State varchar(100) NOT NULL,
   Zip varchar(100) NOT NULL,
   LocationID int(10) unsigned DEFAULT '0' NOT NULL,
   EventLocationID bigint(20) unsigned NOT NULL auto_increment,
   PRIMARY KEY (EventLocationID),
   UNIQUE CalendarLocationID (EventLocationID),
   KEY LocationID (LocationID)
);


DROP TABLE IF EXISTS phpCalendar_Locations;
CREATE TABLE phpCalendar_Locations (
   Name varchar(100) NOT NULL,
   LocationType int(10) unsigned DEFAULT '0' NOT NULL,
   WebAlias varchar(100) NOT NULL,
   LocationID int(10) unsigned NOT NULL auto_increment,
   PRIMARY KEY (LocationID),
   KEY WebAlias (WebAlias)
);


DROP TABLE IF EXISTS phpCalendar_Monthly;
CREATE TABLE phpCalendar_Monthly (
   DayOfMonth tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL,
   DisplayStart date DEFAULT '0000-00-00' NOT NULL,
   DisplayStop date DEFAULT '0000-00-00' NOT NULL,
   Active tinyint(1) unsigned DEFAULT '0' NOT NULL,
   LocationID bigint(20) unsigned DEFAULT '0' NOT NULL,
   CalendarDetailsID bigint(20) unsigned DEFAULT '0' NOT NULL,
   PRIMARY KEY (CalendarDetailsID),
   KEY CalendarDetailsID_2 (CalendarDetailsID),
   KEY LocationID (LocationID),
   KEY DayOfMonth (DayOfMonth)
);


DROP TABLE IF EXISTS phpCalendar_PeriodicalMonthly;
CREATE TABLE phpCalendar_PeriodicalMonthly (
   WeekNumber tinyint(1) unsigned DEFAULT '0' NOT NULL,
   WeekDays varchar(100) NOT NULL,
   DisplayStart date DEFAULT '0000-00-00' NOT NULL,
   DisplayStop date DEFAULT '0000-00-00' NOT NULL,
   Active tinyint(1) unsigned DEFAULT '0' NOT NULL,
   LocationID bigint(20) unsigned DEFAULT '0' NOT NULL,
   CalendarDetailsID bigint(20) unsigned DEFAULT '0' NOT NULL,
   PRIMARY KEY (CalendarDetailsID),
   KEY CalendarDetailsID_2 (CalendarDetailsID),
   KEY LocationID (LocationID),
   KEY WeekNumber (WeekNumber)
);

DROP TABLE IF EXISTS phpCalendar_PeriodicalYearly;
CREATE TABLE phpCalendar_PeriodicalYearly (
   Month tinyint(2) unsigned DEFAULT '0' NOT NULL,
   WeekDays varchar(100) NOT NULL,
   WeekNumber tinyint(1) unsigned DEFAULT '0' NOT NULL,
   DisplayStart date DEFAULT '0000-00-00' NOT NULL,
   DisplayStop date DEFAULT '0000-00-00' NOT NULL,
   Active tinyint(1) unsigned DEFAULT '0' NOT NULL,
   LocationID bigint(20) unsigned DEFAULT '0' NOT NULL,
   CalendarDetailsID bigint(20) unsigned DEFAULT '0' NOT NULL,
   PRIMARY KEY (CalendarDetailsID),
   KEY CalendarDetailsID_2 (CalendarDetailsID),
   KEY LocationID (LocationID),
   KEY Month (Month),
   KEY DayOfMonth (WeekDays),
   KEY WeekNumber (WeekNumber)
);


DROP TABLE IF EXISTS phpCalendar_Weekly;
CREATE TABLE phpCalendar_Weekly (
   DaysOfWeek varchar(100) NOT NULL,
   DisplayStart date DEFAULT '0000-00-00' NOT NULL,
   DisplayStop date DEFAULT '0000-00-00' NOT NULL,
   Active tinyint(1) unsigned DEFAULT '0' NOT NULL,
   LocationID bigint(20) unsigned DEFAULT '0' NOT NULL,
   CalendarDetailsID bigint(20) unsigned DEFAULT '0' NOT NULL,
   PRIMARY KEY (CalendarDetailsID),
   KEY CalendarDetailsID_2 (CalendarDetailsID),
   KEY LocationID (LocationID)
);


DROP TABLE IF EXISTS phpCalendar_Yearly;
CREATE TABLE phpCalendar_Yearly (
   Month tinyint(2) unsigned DEFAULT '0' NOT NULL,
   DayOfMonth tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL,
   DisplayStart date DEFAULT '0000-00-00' NOT NULL,
   DisplayStop date DEFAULT '0000-00-00' NOT NULL,
   Active tinyint(1) unsigned DEFAULT '0' NOT NULL,
   LocationID bigint(20) unsigned DEFAULT '0' NOT NULL,
   CalendarDetailsID bigint(20) unsigned DEFAULT '0' NOT NULL,
   PRIMARY KEY (CalendarDetailsID),
   KEY CalendarDetailsID_2 (CalendarDetailsID),
   KEY LocationID (LocationID),
   KEY Month (Month),
   KEY DayOfMonth (DayOfMonth)
);

