SET sql_mode = 'ALLOW_INVALID_DATES';

UPDATE `configuration` SET `configuration_value` = 'osConcert Version 10.2' WHERE `configuration`.`configuration_id` = 242;

DELETE FROM admin_menus_description WHERE `admin_menus_description`.`menu_id` = 428;
DELETE FROM admin_menus_description WHERE `admin_menus_description`.`menu_id` = 429;

UPDATE `categories` SET `categories_products_lock`=0;

  DROP TABLE IF EXISTS `row_status`;

CREATE TABLE `row_status` (
  `row_status_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `row_status_name` VARCHAR(64) NOT NULL,
  `products_status` TINYINT UNSIGNED NOT NULL,   -- numeric code used in your app
  `sort_order` TINYINT UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`row_status_id`),
  UNIQUE KEY `uniq_products_status` (`products_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `row_status` (`row_status_id`, `row_status_name`, `products_status`, `sort_order`) VALUES
(1, 'In Stock', 1, 10),
(2, 'Reserved', 0, 20),
(3, 'Hidden',   8, 30),
(4, 'Blocked',  3, 40)
ON DUPLICATE KEY UPDATE
  `row_status_name` = VALUES(`row_status_name`),
  `sort_order`      = VALUES(`sort_order`);
  
UPDATE `configuration` SET `set_function` = 'tep_cfg_select_option(array(\"QR\",\"none\"),' WHERE `configuration`.`configuration_id` = 294;

DELETE FROM configuration WHERE `configuration`.`configuration_id` = 306;  


DROP TABLE IF EXISTS `template`;

CREATE TABLE `template` (
  `template_id` int(11) NOT NULL AUTO_INCREMENT,
  `template_name` varchar(64) DEFAULT '0',
  `date_added` datetime DEFAULT NULL,
  `last_modified` datetime DEFAULT NULL,
  `template_image` varchar(64) DEFAULT NULL,
  `show_footer` varchar(3) NOT NULL DEFAULT 'no',
  `include_column_left` varchar(64) NOT NULL,
  `include_column_right` varchar(64) NOT NULL,
  `howto` varchar(4) NOT NULL,
  `header_banner` text DEFAULT NULL,
  `show_breadcrumb` varchar(6) DEFAULT 'yes',
  `active` char(1) NOT NULL DEFAULT '1',
  `show_header_pane` varchar(6) DEFAULT 'no',
  `languages_in_header` char(3) DEFAULT 'no',
  `container_border` char(3) NOT NULL,
  `cart_in_header` varchar(6) DEFAULT 'yes',
  `show_page_login` char(3) NOT NULL,
  `customer_greeting` char(3) NOT NULL DEFAULT 'yes',
  `show_topbar` varchar(6) DEFAULT 'no',
  `template_color` varchar(28) NOT NULL,
  `header_height` int(11) NOT NULL,
  PRIMARY KEY (`template_id`),
  KEY `IDX_TEMPLATE_NAME` (`template_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7;

INSERT INTO `template`
(`template_id`,`template_name`,`date_added`,`last_modified`,`template_image`,`show_footer`,`include_column_left`,`include_column_right`,`howto`,`header_banner`,`show_breadcrumb`,`active`,`show_header_pane`,`languages_in_header`,`container_border`,`cart_in_header`,`show_page_login`,`customer_greeting`,`show_topbar`,`template_color`,`header_height`) VALUES
(1,'darkzone','2020-04-21 00:00:00','2025-09-10 00:00:00','', 'no','no','no','no','no','yes','1','no','no','yes','yes','no','yes','no','red',84),
(4,'theevent','2020-04-21 00:00:00','2025-09-10 00:00:00','', '',  'no','no','no','',  'yes','1','yes','no','',  'yes','no','yes','no','red',84),
(5,'restaurantly','2022-02-11 00:00:00','2025-09-10 00:00:00','', '',  'no','no','no','',  'yes','1','yes','no','',  'yes','no','yes','yes','default',75),
(6,'lightzone','2020-04-21 00:00:00','2025-09-10 00:00:00','', 'no','no','no','no','no','yes','1','no','no','yes','yes','no','yes','no','red',84);

UPDATE `configuration` SET `configuration_group_id` = '151' WHERE `configuration`.`configuration_id` = 283; 
UPDATE `configuration` SET `configuration_group_id` = '151' WHERE `configuration`.`configuration_id` = 564; 
UPDATE `configuration` SET `configuration_group_id` = '151' WHERE `configuration`.`configuration_id` = 1041; 
UPDATE `configuration` SET `configuration_group_id` = '151' WHERE `configuration`.`configuration_id` = 275; 
UPDATE `configuration` SET `configuration_group_id` = '151' WHERE `configuration`.`configuration_id` = 14; 
UPDATE `configuration` SET `configuration_group_id` = '151' WHERE `configuration`.`configuration_id` = 13; 
UPDATE `configuration` SET `configuration_title` = 'Banner Message at Checkout' WHERE `configuration`.`configuration_id` = 911; 
UPDATE `configuration` SET `configuration_title` = 'Enable SEO URLs? Contact Support' WHERE `configuration`.`configuration_id` = 119; 
UPDATE `configuration` SET `configuration_description` = 'Enable the SEO URLs? This is a global setting and will turn them off completely. Contact Support for instructions.' WHERE `configuration`.`configuration_id` = 119; 
UPDATE `configuration` SET `configuration_title` = 'Product Info Personal Message' WHERE `configuration`.`configuration_id` = 282; 
UPDATE `configuration` SET `configuration_value` = 'webp,jpeg,jpg,png,gif' WHERE `configuration`.`configuration_id` = 213; 

DELETE FROM configuration WHERE `configuration`.`configuration_id` = 75;
DELETE FROM configuration WHERE `configuration`.`configuration_id` = 84;

DROP TABLE IF EXISTS `orders_barcode`;

CREATE TABLE  `orders_barcode` (
  barcode_id     BIGINT NOT NULL AUTO_INCREMENT,
  orders_id      INT    NOT NULL DEFAULT 0,
  products_id    BIGINT NOT NULL DEFAULT 0,
  showtime       VARCHAR(255) NOT NULL,
  products_name  VARCHAR(255) NOT NULL,
  barcode        VARCHAR(255) NOT NULL,
  created        INT    NOT NULL DEFAULT 0,
  scanned        TINYINT(1) NOT NULL DEFAULT 0,
  scanned_date   INT    NOT NULL DEFAULT 0,
  location       VARCHAR(255) NOT NULL DEFAULT '',
  data           TEXT NOT NULL,
  PRIMARY KEY (barcode_id),
  UNIQUE KEY uniq_barcode (barcode),
  KEY idx_order_product (orders_id, products_id)
) ENGINE=InnoDB
  DEFAULT CHARSET=utf8mb4
  COLLATE=utf8mb4_general_ci;
  
DELETE FROM admin_menus_description WHERE `admin_menus_description`.`menu_id` = 151;

DELETE FROM `configuration` WHERE `configuration`.`configuration_id` = 233;
DELETE FROM `configuration` WHERE `configuration`.`configuration_id` = 234;
DELETE FROM `configuration` WHERE `configuration`.`configuration_id` = 235;
DELETE FROM `configuration` WHERE `configuration`.`configuration_id` = 236;
DELETE FROM `configuration` WHERE `configuration`.`configuration_id` = 237;

DELETE FROM configuration_group WHERE `configuration_group`.`configuration_group_id` = 902;
UPDATE `configuration_group` SET `configuration_access_key` = 'Marketing Footer Newsletter' WHERE `configuration_group`.`configuration_group_id` = 934; 
DELETE FROM admin_menus WHERE `admin_menus`.`menu_id` = 71;
DELETE FROM configuration_group WHERE `configuration_group`.`configuration_group_id` = 924;
DELETE FROM configuration_group WHERE `configuration_group`.`configuration_group_id` = 112;
UPDATE `configuration` SET `set_function` = 'tep_cfg_select_option(array(\"tinyMce\"),' WHERE `configuration`.`configuration_id` = 188; 


INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES
(2105, 'Your Text For GA Ticket Placeholder', 'TEXT_GA_TICKET', 'Ticket', 'Your Custom Text For [[Ticket Type]] Placeholder', 920, 2, '2023-01-01', '2023-01-01', NULL, NULL),
(2106, 'Your Text For Seat Ticket Placeholder', 'TEXT_SEAT_TICKET', 'Seat', 'Your Custom Text For [[Ticket Type]] Placeholder', 920, 3, '2023-01-01', '2023-01-01', NULL, NULL),
(2107, 'Your Text For Menu Ticket Placeholder', 'TEXT_MENU_TICKET', 'Menu Item', 'Your Custom Text For [[Ticket Type]] Placeholder', 920, 4, '2023-01-01', '2023-01-01', NULL, NULL),
(2108, 'Your Text For Default Ticket Placeholder', 'TEXT_DEFAULT_TICKET', 'Ticket', 'Your Custom Text For [[Ticket Type]] Placeholder', 920, 1, '2023-01-01', '2023-01-01', NULL, NULL);

INSERT INTO `admin_files` (`admin_files_id`, `admin_files_name`, `admin_files_is_boxes`, `admin_files_to_boxes`, `admin_groups_id`, `admin_files_type`, `admin_files_help_id`, `admin_new_group_id`) VALUES (NULL, 'event_open_scheduler.php', '0', '0', '1', 'D', 'D', NULL); 

INSERT INTO `admin_menus` (`menu_id`, `parent_id`, `admin_groups_id`, `menu_pos`, `filename`, `params`, `menu_item_type`) VALUES ('418', '400', '1', '500', 'event_open_scheduler.php', '', ''); 
INSERT INTO `admin_menus_description` (`menu_id`, `menu_text`, `language_id`) VALUES ('418', 'Open-Sales Scheduler', '1'); 


CREATE TABLE IF NOT EXISTS event_open_schedule (
  id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  categories_id INT UNSIGNED NOT NULL,
  open_at DATETIME NOT NULL,
  processed TINYINT(1) NOT NULL DEFAULT 0,
  processed_at DATETIME NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  UNIQUE KEY uniq_cat_open (categories_id, open_at),
  KEY idx_pending_time (processed, open_at),
  KEY idx_cat (categories_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO `admin_files` (`admin_files_id`, `admin_files_name`, `admin_files_is_boxes`, `admin_files_to_boxes`, `admin_groups_id`, `admin_files_type`, `admin_files_help_id`, `admin_new_group_id`) VALUES (NULL, 'password_reset_log.php', '0', '0', '1', 'D', 'D', NULL); 

INSERT INTO `admin_files` (`admin_files_id`, `admin_files_name`, `admin_files_is_boxes`, `admin_files_to_boxes`, `admin_groups_id`, `admin_files_type`, `admin_files_help_id`, `admin_new_group_id`) VALUES (NULL, 'ajax_resend_password_reset.php', '0', '0', '1', 'D', 'D', NULL); 

INSERT INTO `admin_menus` (`menu_id`, `parent_id`, `admin_groups_id`, `menu_pos`, `filename`, `params`, `menu_item_type`) VALUES ('441', '1', '1', '5', 'password_reset_log.php', '', ''); 
INSERT INTO `admin_menus_description` (`menu_id`, `menu_text`, `language_id`) VALUES ('441', 'Password Reset Log', '1'); 

UPDATE `admin_files` SET `admin_new_group_id` = '14' WHERE `admin_files`.`admin_files_id` = 1237; 

INSERT INTO `admin_files` (`admin_files_id`, `admin_files_name`, `admin_files_is_boxes`, `admin_files_to_boxes`, `admin_groups_id`, `admin_files_type`, `admin_files_help_id`, `admin_new_group_id`) VALUES (NULL, 'media_upload.php', '0', '0', '1', 'D', 'D', NULL); 
INSERT INTO `admin_files` (`admin_files_id`, `admin_files_name`, `admin_files_is_boxes`, `admin_files_to_boxes`, `admin_groups_id`, `admin_files_type`, `admin_files_help_id`, `admin_new_group_id`) VALUES (NULL, 'media_picker.php', '0', '0', '1', 'D', 'D', NULL); 

INSERT INTO `admin_menus` (`menu_id`, `parent_id`, `admin_groups_id`, `menu_pos`, `filename`, `params`, `menu_item_type`) VALUES ('442', '11', '1', '250', 'media_upload.php', '', ''); 
INSERT INTO `admin_menus_description` (`menu_id`, `menu_text`, `language_id`) VALUES ('442', 'Media Upload', '1'); 

INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added)
VALUES
('Popup 1 Background Color', 'POPUP1_BG_COLOR', '#333333', 'Hex color used when Popup 1 image is empty.', 6, 50, NOW()),
('Popup 2 Background Color', 'POPUP2_BG_COLOR', '#333333', 'Hex color used when Popup 2 image is empty.', 6, 51, NOW());


INSERT INTO `sql_queries` VALUES('osconcert_v9_1_2.sql', CURDATE());
INSERT INTO `sql_queries` VALUES('osconcert_v9_1_2.sql', CURDATE());