CREATE TABLE IF NOT EXISTS `simple_cms_pages` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `page_name` varchar(250) DEFAULT NULL,
  `page_path` text,
  `page_title` varchar(250) DEFAULT NULL,
  `page_orden` int,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `simple_cms_files` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `file_name` varchar(250) DEFAULT NULL,
  `file_original_name` varchar(250) DEFAULT NULL,
  `date_added` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `simple_cms_roles` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `role` varchar(250) DEFAULT NULL,
  `status` enum('T','F') DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `simple_cms_sections` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `section_type` enum('section','banner','setting') DEFAULT 'section',
  `section_name` varchar(250) NOT NULL,
  `section_width` int(10) unsigned NOT NULL,
  `section_width_type` enum('px','%') DEFAULT 'px',
  `section_height` int(10) unsigned NOT NULL,
  `section_height_type` enum('px','%') DEFAULT 'px',
  `small_width` int(10) unsigned DEFAULT NULL,
  `small_height` int(10) unsigned DEFAULT NULL,
  `large_width` int(10) unsigned DEFAULT NULL,
  `large_height` int(10) unsigned DEFAULT NULL,
  `section_character` int(10) DEFAULT NULL,
  `section_content` longtext,
  `animation` varchar(100) DEFAULT NULL,
  `images` int(10) DEFAULT NULL,
  `date_added` datetime DEFAULT NULL,
  `setting_title` varchar(250) DEFAULT NULL,
  `setting_description` text,
  `setting_search` enum('T','F') DEFAULT NULL,
  `setting_keywords` text,
  `setting_icon` varchar(250) DEFAULT NULL,
  `setting_facebook_1` varchar(250) DEFAULT NULL,
  `setting_facebook_2` varchar(250) DEFAULT NULL,
  `setting_facebook_3` varchar(250) DEFAULT NULL,
  `setting_analytics` text,
  `setting_background` longtext,
  `setting_video_fill` varchar(250) DEFAULT NULL,
  `setting_color_fill` varchar(250) DEFAULT NULL,
  `setting_image_fill_0` varchar(250) DEFAULT NULL,
  `setting_image_fill_1` varchar(250) DEFAULT NULL,
  `setting_image_fill_2` varchar(250) DEFAULT NULL,
  `setting_image_fill_3` varchar(250) DEFAULT NULL,
  `setting_image_fill_4` varchar(250) DEFAULT NULL,
  `setting_image_fill_5` varchar(250) DEFAULT NULL,
  `setting_image_fill_6` varchar(250) DEFAULT NULL,
  `setting_image` enum('original','tile','parallax_original','parallax_tile','fade_slider') DEFAULT NULL,  
  `setting_video` enum('true','false') DEFAULT NULL,  
  `plugins_to_edit_content` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `simple_cms_gallery` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `foreign_id` int(10) unsigned DEFAULT NULL,
  `mime_type` varchar(255) DEFAULT NULL,
  `path` varchar(255) DEFAULT NULL,
  `small_path` varchar(255) DEFAULT NULL,
  `large_path` varchar(255) DEFAULT NULL,
  `url` varchar(255) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `status` enum('T','F') NOT NULL DEFAULT 'T',
  `order` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `foreign` (`foreign_id`),
  KEY `status` (`status`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `simple_cms_users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `role_id` int(10) unsigned NOT NULL,
  `full_name` varchar(250) NOT NULL,
  `email` varchar(250) NOT NULL,
  `password` varchar(250) NOT NULL,
  `section_allow` enum('0','1') DEFAULT NULL,
  `user_allow` enum('0','1') DEFAULT NULL,
  `blog_allow` enum('0','1') DEFAULT NULL,
  `status` enum('T','F') DEFAULT NULL,
  `last_login` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ;

CREATE TABLE IF NOT EXISTS `simple_cms_users_files` (
  `user_id` int(10) unsigned NOT NULL,
  `file_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`user_id`,`file_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `simple_cms_users_sections` (
  `user_id` int(10) unsigned NOT NULL,
  `section_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`user_id`,`section_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `simple_cms_users_pages` (
  `user_id` int(10) unsigned NOT NULL,
  `page_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`user_id`,`page_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `simple_cms_pages_sections` (
  `page_id` int(10) unsigned NOT NULL,
  `section_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`page_id`,`section_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `simple_cms_options` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `key` varchar(255) NOT NULL DEFAULT '',
  `tab_id` tinyint(3) unsigned DEFAULT NULL,
  `group` enum('borders','colors','fonts','sizes') DEFAULT NULL,
  `value` text,
  `description` text,
  `label` text,
  `type` enum('string','text','int','float','enum','color') NOT NULL DEFAULT 'string',
  `order` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`,`key`),
  KEY `tab_id` (`tab_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


INSERT INTO `simple_cms_roles` (`id`, `role`, `status`) VALUES
(1, 'admin', 'T'),
(2, 'editor', 'T');

INSERT INTO `simple_cms_options` (`id`,`key`, `tab_id`, `group`, `value`, `description`, `label`, `type`, `order`) VALUES
(NULL, 'admin_email_address', 1, NULL, 'no-responder@clickresult.es', 'Administrator email<br />\r\n<span style="font-size: 0.9em">This is the email address where confirmation email will be sent when a new comment is posted</span>', NULL, 'string', 1),
(NULL, 'blog_url', 1, NULL, '', 'BLOG URL to the web page where BLOG is placed', NULL, 'string', 2),
(NULL, 'forgot_subject', 1, NULL, 'Admin panel CMS', 'Forgot password subject', NULL, 'string', 3),
(NULL, 'forgot_message', 1, NULL, 'Apreciado administrador, \r\n\r\nEste es un mensaje automático, para recuperar su contraseña.\r\n\r\nEmail: {Email}\r\nContraseña: {Password}\r\n\r\nSaludos,\r\n\r\nAdmin Panel', 'Forgot password message<br/>\r\n<br/>\r\nAvailble Token:<br/>\r\n{Email}<br/>\r\n{Password}', NULL, 'text', 4);