--
-- Host: localhost    Database: cpfulfillment_PrintOS_Brick
-- ------------------------------------------------------


--
-- Table structure for table `AdItems`
--

CREATE TABLE `AdItems` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `NAME` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL,
  `STARTDATE` date NOT NULL,
  `ENDDATE` date NOT NULL,
  `LANGUAGE` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL,
  `IMAGEPATH` varchar(200) COLLATE utf8mb3_unicode_ci NOT NULL,
  `URL` varchar(500) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SORTORDER` int DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `AdItems`
--


--
-- Table structure for table `AdItemsBrand`
--

CREATE TABLE `AdItemsBrand` (
  `ID` int NOT NULL,
  `BRANDNAME` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`ID`,`BRANDNAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `AdItemsBrand`
--


--
-- Table structure for table `accountMgrHeader`
--

CREATE TABLE `accountMgrHeader` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `ENTEREDBY` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `DATEENTERED` datetime NOT NULL,
  `STATUS` int NOT NULL,
  `TITLE` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL,
  `DATECLOSED` datetime DEFAULT NULL,
  `LANGUAGE` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ACCOUNT` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `BANNER` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `BRANCHNUMBER` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ADDRESS` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `CITY` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PROVINCE` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `COUNTRY` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `POSTAL` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PHONE` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `FAX` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `APPOINTMENTPHONE` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `CONTACTFIRST` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `CONTACTLAST` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `EMAIL` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `NOTE` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `BOUTIQUEFIRST` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `BOUTIQUELAST` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `TAGLINENAME` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `AFFILIATEDNAME` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `PHARMLEGALNAME` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `PHARMPHOTONAME` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT '',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `accountMgrHeader`
--


--
-- Table structure for table `accountMgrMessages`
--

CREATE TABLE `accountMgrMessages` (
  `MESSAGEID` int NOT NULL AUTO_INCREMENT,
  `TICKETID` int NOT NULL,
  `DATEENTERED` datetime NOT NULL,
  `ENTEREDBY` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `CLIENTMESSAGE` int NOT NULL,
  `MESSAGE` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`MESSAGEID`,`TICKETID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `accountMgrMessages`
--


--
-- Table structure for table `branchAssetDefinition`
--

CREATE TABLE `branchAssetDefinition` (
  `TAG` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `TYPE` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL,
  `NAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `VALIDATEPATTERN` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `VALIDATEERRORMSG` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `DISPLAYORDER` int NOT NULL,
  `USERACCESSIBLE` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`TAG`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `branchAssetDefinition`
--


--
-- Table structure for table `branchSkinDefinition`
--

CREATE TABLE `branchSkinDefinition` (
  `SKINNAME` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `STYLEFILENAME` varchar(45) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`SKINNAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `branchSkinDefinition`
--

INSERT INTO `branchSkinDefinition` VALUES ('DEFAULT','site');

--
-- Table structure for table `branches`
--

CREATE TABLE `branches` (
  `CODE` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `NAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `MANAGEMENTEMAIL` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `TREASUREREMAIL` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `TAXGROUP` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL,
  `STATUS` int NOT NULL DEFAULT '1',
  `COMMENTS` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `CREATEDDATE` datetime DEFAULT NULL,
  `MODIFIEDDATE` datetime DEFAULT NULL,
  `SHIPZONE` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'None',
  `SKIN` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'DEFAULT',
  PRIMARY KEY (`CODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `branches`
--

INSERT INTO `branches` VALUES ('11','Edmonton - Main','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('12','Edmonton Distribution Centre','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('13','Lloydminster','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('14','Edmonton - South','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('15','Fort McMurray','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('17','Red Deer','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('18','Regina','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('1B','Calgary - South - CLOSED','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('1D','Prince Albert','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('1E','Edmonton - WEM - NO HANGING POSTERS','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('1G','Lethbridge','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('1H','Saskatoon','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('1J','Grande Prairie','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('1M','Medicine Hat','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('1P','Calgary - North (Sunridge) - with Brick Outlet','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('1Q','Edmonton - North','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('1U','Edmonton - South Common','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('1V','Calgary - Deerfoot Meadows','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('1X','Calgary - Beacon Hill','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('22','Delta Distribution Centre','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('26','Kelowna','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2C','Prince George','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2D','West Vancouver (Park Royal)','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2G','Abbotsford','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2K','Kamloops - with Brick Outlet','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2L','Langley','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2M','Surrey - South (Whiterock)','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2N','Nanaimo','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2Q','Coquitlam','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2S','Surrey - Central','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2T','Vancouver - Granville','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2U','Richmond - with Brick Outlet','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2V','Vancouver','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('2W','Victoria (Langford) - with Brick Outlet','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('31','Kingston','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('32','Québec Distribution Centre','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('33','Ottawa - East (Gloucester)','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('34','Ottawa - West (Nepean)','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('35','Trois-Riviéres','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('36','Laval','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('37','Anjou','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('38','St. Hubert','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('39','Lasalle','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('3A','Kirkland - with Brick Outlet','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('3C','Marché Central - with Brick Outlet','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('3E','Boisbriand','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('3F','Lachenaie - with Brick Outlet','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('3G','Gatineau','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('3H','Drummondville','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('3I','Ste-Foy','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('3J','Lebourgneuf','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('3K','Sherbrooke','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('3L','Victoriaville','NA@NA.com','NA@NA.com','QC',1,'',NULL,NULL,'None','DEFAULT'),('3M','Moncton - SHIP BOTH EN & FR - FRANCHISE PRICING','NA@NA.com','NA@NA.com','NB',1,'',NULL,NULL,'None','DEFAULT'),('3N','Fredericton - FRANCHISE PRICING','NA@NA.com','NA@NA.com','NB',1,'',NULL,NULL,'None','DEFAULT'),('3Q','Halifax - FRANCHISE PRICING','NA@NA.com','NA@NA.com','NS',1,'',NULL,NULL,'None','DEFAULT'),('3S','Saint John - FRANCHISE PRICING','NA@NA.com','NA@NA.com','NB',1,'',NULL,NULL,'None','DEFAULT'),('3T','Kanata','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('42','Mississauga Distribution Centre','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('44','Scarborough','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('47','Richmond Hill - with Brick Outlet','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('48','Brantford','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4A','Mississauga - South (Dundas St. E) - with Brick Outlet','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4B','Burlington CC Zone','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4C','Toronto - Geary - with Brick Outlet','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4D','Peterborough','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4E','Brampton','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4F','Windsor (Legacy Park Dr.)','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4H','Hamilton','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4I','London','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4J','Barrie','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4K','Scarborough - William Kitchen','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4L','Belleville','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4M','Kitchener','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4N','North York - 401 (Weston Rd)','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4P','St. Catharines','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4T','Whitby','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4U','Sarnia','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('4W','Sudbury','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('52','Calgary Distribution Centre','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('53','Mississauga - North (McLaughlin Rd)','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('54','North York - Dufferin','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('55','Newmarket','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('57','Brampton - East (Airport)','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('58','Markham','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('59','Niagara Falls - Brick Lite','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('5A','Orangeville','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('5B','Milton - Brick Lite','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('5C','Hamilton - East','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('5D','Waterloo','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6B','Burlington','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6D','North York','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6I','Oakville','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6K','Toronto - College Park','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6P','Vaughan Mills','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6S','Richmond Hill','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6T','Toronto - Leslie/Lakeshore','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6U','London North','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6V','Etobicoke','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6W','Brampton','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6X','Bolton','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('6Y','London South','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('72','Winnipeg Distribution Centre','NA@NA.com','NA@NA.com','MB',1,'',NULL,NULL,'None','DEFAULT'),('7A','Winnipeg - West','NA@NA.com','NA@NA.com','MB',1,'',NULL,NULL,'None','DEFAULT'),('7B','Winnipeg - West','NA@NA.com','NA@NA.com','MB',1,'',NULL,NULL,'None','DEFAULT'),('7D','Thunder Bay','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('7E','Winnipeg - East','NA@NA.com','NA@NA.com','MB',1,'',NULL,NULL,'None','DEFAULT'),('7F','Winnipeg - South','NA@NA.com','NA@NA.com','MB',1,'',NULL,NULL,'None','DEFAULT'),('9A','Hinton','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('9B','Morden','NA@NA.com','NA@NA.com','MB',1,'',NULL,NULL,'None','DEFAULT'),('9C','Drumheller - CORPORATE PRICING','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('9D','Hanna - CORPORATE PRICING','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('9E','Cold Lake - CORPORATE PRICING','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('9F','Wainwright','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('9G','Drayton Valley - NO ELECTRONICS','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('9H','Slave Lake','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('9K','Cranbrook','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('9L','Powell River','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('9M','Castlegar','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('9N','Thompson','NA@NA.com','NA@NA.com','MB',1,'',NULL,NULL,'None','DEFAULT'),('9Q','Stettler - CORPORATE PRICING','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('A5','Fort Saskatchewan','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('AA','Airdrie','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('AE','Edmonton - North','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('AF','Fort McMurray','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('AK','Okotoks','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('AQ','Calgary - McKenzie (Sheppard)','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('AR','Red Deer','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('AS','Spruce Grove','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('AT','Leduc','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('AW','St. Albert','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('AX','Calgary - Signal Hill','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('B1','Campbell River','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('B2','Terrace - FRANCHISE PRICING','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('B3','Chilliwack','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('B4','Courtenay','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('B6','Duncan','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('B8','Pitt Meadows','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('BE','Vernon','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('BI','Victoria (Douglas)','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('BJ','Fort St. John','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('BM','Squamish','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('BS','Surrey - Newton (King George)','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('BX','Williams Lake','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('BY','Penticton','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('C3','Brooks - CORPORATE PRICING','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('CE','Swift Current','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('CF','Whitehorse','NA@NA.com','NA@NA.com','YT',1,'',NULL,NULL,'None','DEFAULT'),('CG','Estevan','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('CI','Port Alberni - CORPORATE PRICING','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('CJ','Gibsons','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('CM','Pincher Creek','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('CPDI','Creative Path Digital Imaging Inc. ','peggy@creativepath.com','peggy@creativepath.com','ON',1,'1455-16th Avenue, Unit 1 & 2','2016-01-02 22:14:44','2019-07-15 20:01:00','None','DEFAULT'),('CR','Peace River','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('D2','Athabasca','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('DA','Barrhead','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('DB','Westlock','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('DD','Whitecourt','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('DE','St. Paul - CORPORATE PRICING','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('DG','Vegreville','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('DH','Bonnyville - CORPORATE PRICING','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('DI','Yellowknife','NA@NA.com','NA@NA.com','NT',1,'',NULL,NULL,'None','DEFAULT'),('DJ','Ponoka','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('DK','Olds','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('DL','Edson','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('EA','Chatham','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('EF','Stratford','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('EG','Guelph','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('EW','Owen Sound','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('FA','Sault Ste Marie','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('FB','Wawa','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('FE','Timmins','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('FH','Moosonee - SHIP VIA TIMMINS','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('FK','Goderich','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('GA','Cornwall','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('GB','Hawkesbury','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('GF','New Glasgow','NA@NA.com','NA@NA.com','NS',1,'',NULL,NULL,'None','DEFAULT'),('GG','Woodstock','NA@NA.com','NA@NA.com','NB',1,'',NULL,NULL,'None','DEFAULT'),('GH','Brockville','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('GJ','Bathurst','NA@NA.com','NA@NA.com','NB',1,'',NULL,NULL,'None','DEFAULT'),('GK','Amherst','NA@NA.com','NA@NA.com','NS',1,'',NULL,NULL,'None','DEFAULT'),('H1','Vaughan','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('H2','Scarborough - Eglington','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('H3','Mississauga - SuperStore - with Brick Outlet','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('JA','Canmore','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('JC','Brandon','NA@NA.com','NA@NA.com','MB',1,'',NULL,NULL,'None','DEFAULT'),('JD','Salmon Arm - CORPORATE PRICING','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('JF','North Battleford','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('JG','Dawson Creek','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('JH','Camrose','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('JI','High Level','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('JJ','Humboldt','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('JL','Swan River','NA@NA.com','NA@NA.com','MB',1,'',NULL,NULL,'None','DEFAULT'),('JP','Meadow Lake','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('KA','New Liskeard','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('KB','Orillia','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('KC','Collingwood','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('KG','Gravenhurst - UPH ONLY','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('KK','Huntsville','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('KM','Midland','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('KN','North Bay','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('KP','Pembroke','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('KS','Simcoe - NO FLYER STAND INSERTS','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('M2','Stoney Creek','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('M3','Mississauga','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('M4','Cambridge','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('M5','Ajax - NO HANGING POSTERS - MATT/UPH ONLY','NA@NA.com','NA@NA.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('Markham','The Brick Markham','peggy@creativepath.com','peggy@creativepath.com','ON',1,'',NULL,NULL,'None','DEFAULT'),('MJ','Moose Jaw','NA@NA.com','NA@NA.com','MB',1,'',NULL,NULL,'None','DEFAULT'),('NA','Rocky Mountain House','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('NB','Wetaskiwin','NA@NA.com','NA@NA.com','AB',1,'',NULL,NULL,'None','DEFAULT'),('NorthYork','The Brick North York','peggy@creativepath.com','peggy@creativepath.com','ON',1,'','2021-04-26 10:24:47','2021-04-26 10:25:46','None','DEFAULT'),('PR','Pacific Reach','NA@NA.com','NA@NA.com','BC',1,'',NULL,NULL,'None','DEFAULT'),('RichmondHill','The Brick Richmond Hill','peggy@creativepath.com','peggy@creativepath.com','ON',1,'','2021-04-26 10:26:45','2021-04-26 10:27:24','None','DEFAULT'),('SE','Regina - East','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('SH','Saskatoon - South','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('SS','Saskatoon - CLOSED','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('SY','Yorkton','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT'),('UR','Regina','NA@NA.com','NA@NA.com','SK',1,'',NULL,NULL,'None','DEFAULT');

--
-- Table structure for table `branchesAddresses`
--

CREATE TABLE `branchesAddresses` (
  `CODE` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `LANGUAGE` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ISMAIN` tinyint(1) NOT NULL DEFAULT '0',
  `ADDRESS` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ADDRESS2` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `CITY` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `PROVINCE` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `COUNTRY` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `POSTALCODE` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `PHONE` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `FAX` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`CODE`,`LANGUAGE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `branchesAddresses`
--

INSERT INTO `branchesAddresses` VALUES ('11','EN',1,'10705 - 101 Street','','Edmonton','AB','Canada','T5H 2S4','',''),('12','EN',1,'11411 - 170 Street','','Edmonton','AB','Canada','T5M 3Y6','',''),('13','EN',1,'5517 - 44 Street','','Lloydminster','AB','Canada','T9V 0B1','',''),('14','EN',1,'9856 Argyll Rd','','Edmonton','AB','Canada','T6E 0G6','',''),('15','EN',1,'Unit 110, 19 Riedel Street','','Ft McMurray','AB','Canada','T9H 3H8','',''),('17','EN',1,'5111 - 22 St.','','Red Deer','AB','Canada','T4R 2K1','',''),('18','EN',1,'2425 - 7th Ave North','','Regina','SK','Canada','S4R 0K4','',''),('1B','EN',1,'9655 MacLeod Trail South','','Calgary','AB','Canada','T2J 0P6','',''),('1D','EN',1,'1403 Central Avenue','','Prince Albert','SK','Canada','S6V 7J4','',''),('1E','EN',1,'Unit 2923 8770 - 170 Street','','Edmonton','AB','Canada','T5T 4J2','',''),('1G','EN',1,'3727 Mayor Magrath Dr S','','Lethbridge','AB','Canada','T1K 8A8','',''),('1H','EN',1,'2035 - 1st Ave North','','Saskatoon','SK','Canada','S7K 0T5','',''),('1J','EN',1,'11345 - 104 Avenue','','Grande Prairie','AB','Canada','T8V 0N7','',''),('1M','EN',1,'3201-13 Avenue S.E.','','Medicine Hat','AB','Canada','T1B 1E2','',''),('1P','EN',1,'3451 Sunridge Way NE','','Calgary','AB','Canada','T1Y 7H5','',''),('1Q','EN',1,'Unit 101, 12222 - 137 Avenue','','Edmonton','AB','Canada','T5L 4X5','',''),('1U','EN',1,'1920 - 99 Street','','Edmonton','AB','Canada','T6K 1K9','',''),('1V','EN',1,'9 Heritage Meadows Way S.E.','','Calgary','AB','Canada','T2H 0A7','',''),('1X','EN',1,'11860 Sarcee Trail NW','','Calgary','AB','Canada','T3R 0A1','',''),('22','EN',1,'7555 Beedie Way','','Delta','BC','Canada','V4G 0A5','',''),('26','EN',1,'Unit 100, 948 McCurdy Rd','','Kelowna','BC','Canada','V1X 2P7','',''),('2C','EN',1,'2454 Ferry Avenue','','Prince George','BC','Canada','V2N 0B1','',''),('2D','EN',1,'2205 Park Royal South','','West Vancouver','BC','Canada','V7T 2W5','',''),('2G','EN',1,'2067 Sumas Way ','','Abbotsford ','BC','Canada','V2S 8H6','',''),('2K','EN',1,'1689 E. Trans Canada Hwy','','Kamloops','BC','Canada','V2C 3Z5','',''),('2L','EN',1,'Unit 400, 20020 Willowbrook Dr','','Langley','BC','Canada','V2Y 2T4','',''),('2M','EN',1,'15858 - 24 Ave.','','Surrey','BC','Canada','V3Z 0G1','',''),('2N','EN',1,'6361 Hammond Bay Rd','','Nanaimo','BC','Canada','V9T 5Y1','',''),('2Q','EN',1,'Unit 122, 3000 Lougheed Hwy','','Coquitlam','BC','Canada','V3B 1C5','',''),('2S','EN',1,'Unit 3700, 10153 King George Blvd.','','Surrey','BC','Canada','V3T 2W1','',''),('2T','EN',1,'2360 Granville Street','','Vancouver','BC','Canada','V6H 3G3','',''),('2U','EN',1,'Unit 150, 3100 St Edwards Dr','','Richmond','BC','Canada','V6X 4C4','',''),('2V','EN',1,'2999 Grandview Hwy','','Vancouver','BC','Canada','V5M 2E4','',''),('2W','EN',1,'Unit 500, 2945 Jacklin Road','','Langford','BC','Canada','V9B 4E3','',''),('31','EN',1,'Unit 1, 770 Gardiners Road','','Kingston','ON','Canada','K7M 3X9','',''),('32','EN',1,'10001 Metropolitain Blvd. Est','','Pointe-aux-Trembles','QC','Canada','H1B 5Y3','',''),('33','EN',1,'1960 Cyrville Road','','Gloucester','ON','Canada','K1B 1A5','',''),('34','EN',1,'565 West Hunt Club Rd','','Nepean','ON','Canada','K2E 1B2','',''),('35','EN',1,'3335 boul. des Recollets','','Trois Rivieres','QC','Canada','G9A 6M1','',''),('36','EN',1,'1530 boul. le Corbusier','','Laval','QC','Canada','H7S 1Y8','',''),('37','EN',1,'7999 Boul. Les Galeries d\'Anjou','','Pointe-aux-Trembles','QC','Canada','H1M 1W9','',''),('38','EN',1,'1451 Boul. des Promenades','','Saint-Hubert','QC','Canada','J3Y 5K2','',''),('39','EN',1,'6867 boul. Newman','','Lasalle','QC','Canada','H8N 1X1','',''),('3A','EN',1,'17080 Transcanadienne Ouest','','Kirkland','QC','Canada','H9J 2M5','',''),('3C','EN',1,'8701 L\'Acadie Boulevard','','Montreal','QC','Canada','H4N 3K1','',''),('3E','EN',1,'3400 ave des Grandes-Tourelles','','Boisbriand','QC','Canada','J7H 0A2','',''),('3F','EN',1,'274 Montee Des Pionniers','','Lachenaie','QC','Canada','J6V 1S6','',''),('3G','EN',1,'920 Boul Maloney Ouest','','Gatineau','QC','Canada','J8T 3R6','',''),('3H','EN',1,'870 Rue Hains','','Drummondville','QC','Canada','J2C 7Y8','',''),('3I','EN',1,'1150 Aut Duplessis','','Quebec','QC','Canada','G2G 2B5','',''),('3J','EN',1,'1540, 5401 Boulevard des Galeries de la Capitale','','Quebec','QC','Canada','G2K 1N4','',''),('3K','EN',1,'1150 Boul. Plateau St Joseph','','Sherbrooke','QC','Canada','J1L 0A5','',''),('3L','EN',1,'#1650, 525 Boulevard Jutras Est.','','Victoriaville','QC','Canada','G6P 7H4','',''),('3M','EN',1,'75 Trinity Drive','','Moncton','NB','Canada','E1G 2J7','',''),('3N','EN',1,'Unit Y0091, 1381 Regent St.','','Fredericton','NB','Canada','E3C 1A2','',''),('3Q','EN',1,'192 Chain Lake Drive','','Halifax','NS','Canada','B3S 1C5','',''),('3S','EN',1,'Unit U011, 519 Westmorland Rd.','','Saint John','NB','Canada','E2J 3W9','',''),('3T','EN',1,'Unit C, 8231 Campeau Drive','','Kanata','ON','Canada','K2T 1B7','',''),('42','EN',1,'6765 Kennedy Road','','Mississauga','ON','Canada','L5T 0A2','',''),('44','EN',1,'1165 Kennedy Road','','Scarborough','ON','Canada','M1P 2K8','',''),('47','EN',1,'Unit 6, 45 Red Maple Road','','Richmond Hill','ON','Canada','L4B 4M6','',''),('48','EN',1,'410 Fairview Drive','','Brantford','ON','Canada','N3R 7V7','',''),('4A','EN',1,'1607 Dundas Street East','','Mississauga','ON','Canada','L4X 1L5','',''),('4B','EN',1,'990 Fraser Drive','','Burlington','ON','Canada','L7L 5P5','',''),('4C','EN',1,'1352 Dufferin Street','','Toronto','ON','Canada','M6H 4G4','',''),('4D','EN',1,'1200 Lansdowne St. W.','','Peterborough','ON','Canada','K9J 2A1','',''),('4E','EN',1,'188 Clarence Street','','Brampton','ON','Canada','L6W 1T4','',''),('4F','EN',1,'4001 Legacy Park Dr.','','Windsor','ON','Canada','N8W 5S6','',''),('4H','EN',1,'1441 Upper James Street','','Hamilton','ON','Canada','L9B 1K2','',''),('4I','EN',1,'1040 Wharncliffe Road','','London','ON','Canada','N6L 1H2','',''),('4J','EN',1,'52 Caplan Avenue','','Barrie','ON','Canada','L4N 9J2','',''),('4K','EN',1,'19 William Kitchen Rd','','Scarborough','ON','Canada','M1P 5B7','',''),('4L','EN',1,'200 Bell Boulevard','','Belleville','ON','Canada','K8P 5L8','',''),('4M','EN',1,'4283 King Street East','','Kitchener','ON','Canada','N2P 2E9','',''),('4N','EN',1,'2625 B Weston Rd','','North York','ON','Canada','M9N 3W1','',''),('4P','EN',1,'275 Fourth Avenue','','St Catharines','ON','Canada','L2R 6P9','',''),('4T','EN',1,'25 Consumers Drive','','Whitby','ON','Canada','L1N 9S2','',''),('4U','EN',1,'Unit 3, 1379 London Rd','','Sarnia','ON','Canada','N7S 1P6','',''),('4W','EN',1,'747 Notre Dame Ave','','Sudbury','ON','Canada','P3A 2T2','',''),('52','EN',1,'5500 - 22 St. SE','','Calgary','AB','Canada','T2C 3G4','',''),('53','EN',1,'Unit 2, 5800 McLaughlin Rd','','Mississauga','ON','Canada','L5R 4B7','',''),('54','EN',1,'4250 Dufferin Street','','North York','ON','Canada','M3H 5W4','',''),('55','EN',1,'Unit A, 17940 Yonge Street','','Newmarket','ON','Canada','L3Y 8S4','',''),('57','EN',1,'24 Coventry Road','','Brampton','ON','Canada','L6T 5P9','',''),('58','EN',1,'Unit 1, 9809 Highway 48','','Markham','ON','Canada','L6E 0E5','',''),('59','EN',1,'7555 Montrose Road','','Niagara Falls','ON','Canada','L2H 2E9','',''),('5A','EN',1,'Unit 1, 215 Centennial Road','','Orangeville','ON','Canada','L9W 5K9','',''),('5B','EN',1,'1205 Maple Avenue','','Milton','ON','Canada','L9T 0A5','',''),('5C','EN',1,'Unit F01, 1267 Barton Street East','','Hamilton','ON','Canada','L8H 2V4','',''),('5D','EN',1,'1200 Lansdowne St. W.','','Kitchener','ON','Canada','N2N 0B1','',''),('6B','EN',1,'Unit 10, 2455 Appleby Line','','Burlington','ON','Canada','L7L 0B6','',''),('6D','EN',1,'3013 Dufferin Rd.','','North York','ON','Canada','M6B 3T4','',''),('6I','EN',1,'Unit C001, 310 N. Service Rd.','','Oakville','ON','Canada','L6M 2R7','',''),('6K','EN',1,'Unit G2, 444 Yonge St.','','Toronto','ON','Canada','M5B 2H4','',''),('6P','EN',1,'Unit 505, 255 Bass Pro Mills Dr.','','Vaughan','ON','Canada','L4K 0A2','',''),('6S','EN',1,'Unit 5, 1500 Elgin Mills Road East','','Richmond Hill','ON','Canada','L4S 0B2','',''),('6T','EN',1,'1015 Lakeshore Blvd. E.','','Toronto','ON','Canada','M4M 1B4','',''),('6U','EN',1,'Unit 10, 1422 Fanshawe Park Road West','','London','ON','Canada','N6G 0A4','',''),('6V','EN',1,'Unit 1, 1555 The Queensway','','Etobicoke','ON','Canada','M8Z 1T8','',''),('6W','EN',1,'Unit E-3, 11795 Bramalea Road','','Brampton','ON','Canada','L6R 3S9','',''),('6X','EN',1,'12748 Highway 50','','Bolton','ON','Canada','L7E 4G1','',''),('6Y','EN',1,'3059 Wonderland Rd.','','London','ON','Canada','N6L 1R4','',''),('72','EN',1,'1065 St James Street','','Winnipeg','MB','Canada','R3A 0K6','',''),('7A','EN',1,'1065 St James Street','','Winnipeg','MB','Canada','R3A 0K5','',''),('7B','EN',1,'1250 St. James Street','','Winnipeg','MB','Canada','R3H 0L1','',''),('7D','EN',1,'869 Fort William Road','','Thunder Bay','ON','Canada','P7B 0A9','',''),('7E','EN',1,'1487 Regent Ave West','','Winnipeg','MB','Canada','R7C 1A5','',''),('7F','EN',1,'1731 Kenaston Blvd','','Winnipeg','MB','Canada','R3Y 1V5','',''),('9A','EN',1,'566 Switzer Drive','','Hinton','AB','Canada','T7V 1G7','',''),('9B','EN',1,'570 Stephen Street','','Morden','MB','Canada','R6M 1T7','',''),('9C','EN',1,'11 Railway Avenue','','Drumheller','AB','Canada','T0J 0Y0','',''),('9D','EN',1,'114 - 2nd Avenue West','','Hanna','AB','Canada','T0J 1P0','',''),('9E','EN',1,'4204 50 St.','','Cold Lake','AB','Canada','T9M 1S6','',''),('9F','EN',1,'2618 - 14th Avenue','','Wainwright','AB','Canada','T9W 0A4','',''),('9G','EN',1,'5212 - 50 Street','','Drayton Valley','AB','Canada','T7A 1S8','',''),('9H','EN',1,'213 Main Street North','','Slave Lake','AB','Canada','T0G 2A0','',''),('9K','EN',1,'501 Slater Rd. NW','','Cranbrook','BC','Canada','V1C 4Y5','',''),('9L','EN',1,'Unit 8, 7100 Alberni St.','','Powell River','BC','Canada','V8A 5K9','',''),('9M','EN',1,'4445 Minto Road','','Castlegar','BC','Canada','V1N 4E7','',''),('9N','EN',1,'91 Nelson Rd.','','Thompson','MB','Canada','R8N 0B5','',''),('9Q','EN',1,'6510 - 50 Avenue','','Stettler','AB','Canada','T0C 2L2','',''),('A5','EN',1,'Unit 121, 8701 - 94 Street','','Ft. Saskatchewan','AB','Canada','T8 L4P7','',''),('AA','EN',1,'73 East Lake Ramp NE','','Airdrie','AB','Canada','T4A 2K4','',''),('AE','EN',1,'13304 St. Albert Trail','','Edmonton','AB','Canada','T5L 4P6','',''),('AF','EN',1,'441 Gregoire Drive','','Fort McMurray','AB','Canada','T9H 4K7','',''),('AK','EN',1,'201 Southridge Drive','','Okotoks','AB','Canada','T1S 2E1','',''),('AQ','EN',1,'Unit 202, 5222 - 130th Avenue SE','','Calgary','AB','Canada','T2Z 0G4','',''),('AR','EN',1,'8071 Gaetz Ave. N.','','Red Deer','AB','Canada','T4P 2V4','',''),('AS','EN',1,'Unit 140, 4 Macleod Ave','','Spruce Grove','AB','Canada','T7X 3Z3','',''),('AT','EN',1,'Unit 102, 5401 Discovery Way','','Leduc','AB','Canada','T9E 8N4','',''),('AW','EN',1,'Unit 20, 445 St. Albert Road','','St. Albert','AB','Canada','T8N 6T9','',''),('AX','EN',1,'5627 Signal Hill Centre SW','','Calgary','AB','Canada','T3H 3P8','',''),('B1','EN',1,'2171 Island Hwy','','Campbell River','BC','Canada','V9W 2G6','',''),('B2','EN',1,'4730 Keith Ave.','','Terrace','BC','Canada','V8G 4K1','',''),('B3','EN',1,'45365 Luckakuck Way','','Chilliwack','BC','Canada','V2R 3C7','',''),('B4','EN',1,'630 - 29th Street','','Courtenay','BC','Canada','V9N 7Y3','',''),('B6','EN',1,'5380 Trans Canada Hwy','','Duncan','BC','Canada','V9L 6W4','',''),('B8','EN',1,'19068 Lougheed Hwy','','Pitt Meadows','BC','Canada','V3Y 2J6','',''),('BE','EN',1,'Unit 100, 5601 Anderson Way','','Vernon','BC','Canada','V1T 8X1','',''),('BI','EN',1,'2835 Douglas Street','','Victoria','BC','Canada','V8T 4M6','',''),('BJ','EN',1,'9403 Alaska Hwy','','Fort St. John.','BC','Canada','V1J 1A3','',''),('BM','EN',1,'Unit1, 38918 Progress Way','','Squamish','BC','Canada','V8B 0K7','',''),('BS','EN',1,'6935 King George Blvd.','','Surrey','BC','Canada','V3W 5A1','',''),('BX','EN',1,'240 North Mackenzie Ave.','','Williams Lake','BC','Canada','V2G 1N6','',''),('BY','EN',1,'350 Ellis Street','','Penticton','BC','Canada','V2A 4L7','',''),('C3','EN',1,'1027-2nd Street West','','Brooks','AB','Canada','T1R 0C3','',''),('CE','EN',1,'1702 Springs Drive','','Swift Current','SK','Canada','S9H 5N1','',''),('CF','EN',1,'125B Industrial Road','','Yellowknife','YT','Canada','Y1A 2T8','',''),('CG','EN',1,'3003 400 King St.','','Estevan','SK','Canada','S4N 2B4','',''),('CI','EN',1,'3550 Johnston Road','','Port Alberni','BC','Canada','V9Y 7W8','',''),('CJ','EN',1,'624 Pratt Road','','Gibsons','BC','Canada','V0N 1V0','',''),('CM','EN',1,'1300 Hewetson Ave','','Pincher Creek','AB','Canada','T0K 1W0','',''),('CPDI','EN',1,'1455-16th Avenue, Unit 1 & 2','','Richmond Hill','ON','Canada','L4B 4W5','905.709.9609','905.709.9610'),('CR','EN',1,'7626-100th Avenue','','Peace River','AB','Canada','T8S 1M5','',''),('D2','EN',1,'5206 - 50 Avenue','','Athabasca','AB','Canada','T9S 1S8','',''),('DA','EN',1,'5026 - 50 Street','','Barrhead','AB','Canada','T7N 1J5','',''),('DB','EN',1,'10550 - 100 Street','','Westlock','AB','Canada','T7P 2C6','',''),('DD','EN',1,'5002 50th Street','','Whitecourt','AB','Canada','T7S 1P4','',''),('DE','EN',1,'4125 50th Ave','','St. Paul','AB','Canada','T0A 3A0','',''),('DG','EN',1,'101A - 5341 50th AVE','','Vegreville','AB','Canada','T9C 0A9','',''),('DH','EN',1,'Box 4945, 5102 - 50th Ave','','Bonnyville','AB','Canada','T9N 2H9','',''),('DI','EN',1,'354 Old Airport Road','','Yellowknife','NT','Canada','X1A 3T4','',''),('DJ','EN',1,'4820 50st','','Ponoka','AB','Canada','T4J 1S1','',''),('DK','EN',1,'5106 50 Avenue','','Olds','AB','Canada','T4P 1P7','',''),('DL','EN',1,'205 50th Street','','Edson','AB','Canada','T7E 1V6','',''),('EA','EN',1,'990 Richmond St.','','Chatham','ON','Canada','N7M 5J5','',''),('EF','EN',1,'805 Downie St.','','Stratford','ON','Canada','N5A 1Y8','',''),('EG','EN',1,'392 Silvercreek Parkway N.,','','Guelph','ON','Canada','N1H 1E7','',''),('EW','EN',1,'1125 - 8th St. East','','Owen Sound','ON','Canada','N4K 1M5','',''),('FA','EN',1,'275 Second Line West','','Sault Ste Marie','ON','Canada','P6C 2J4','',''),('FB','EN',1,'41 Broadway Avenue','','Wawa','ON','Canada','P0S 1K0','',''),('FE','EN',1,'108 Third Avenue','','Timmins','ON','Canada','P4N 1C3','',''),('FH','EN',1,'147 Ferguson Road','','Moosonee','ON','Canada','P0L 1Y0','',''),('FK','EN',1,'639 Bayfield Rd (PO Box 525)','','Goderich','ON','Canada','N7A 4C7','',''),('GA','EN',1,'1525 Pitt Street','','Cornwall','ON','Canada','K6J 3T9','',''),('GB','EN',1,'895 Rue Main East','','Hawkesbury','ON','Canada','K6A 1B5','',''),('GF','EN',1,'280 Stellarton Road','','New Glasgow','NS','Canada','B2H1M5','',''),('GG','EN',1,'370 Connell Street','','Woodstock','NB','Canada','E7M 5G9','',''),('GH','EN',1,'491 Stewart Blvd','','Brockville','ON','Canada','K6V 7E8','',''),('GJ','EN',1,'700 St. Peter Avenue','','Bathurst','NB','Canada','E2A 2Y7','',''),('GK','EN',1,'21068 La Planche Street','','Amherst','NS','Canada','B4H 3Y6','',''),('H1','EN',1,'137 Chrislea Road','','Vaughan','ON','Canada','L4L 8N6','',''),('H2','EN',1,'20 Ashtonbee Road','','Scarborough','ON','Canada','M1L 4R5','',''),('H3','EN',1,'3025 Ridgeway Road','','Mississauga','ON','Canada','L5L 5P8','',''),('JA','EN',1,'1140 Railway Avenue','','Canmore','AB','Canada','T1W 1P4','',''),('JC','EN',1,'1858 - 18th Street N','','Brandon','MB','Canada','R7C 1A5','',''),('JD','EN',1,'1701 - 10 Ave. SW.','','Salmon Arm','BC','Canada','V1E 1T4','',''),('JF','EN',1,'2731 Hwy 4 North','','North Battleford','SK','Canada','S9A 3E6','',''),('JG','EN',1,'11616 - 8th Street','','Dawson Creek','BC','Canada','V1G 4R7','',''),('JH','EN',1,'5000 - 51st Ave.','','Camrose','AB','Canada','T4V 0V6','',''),('JI','EN',1,'9702 Rainbow Blvd.','','High Level','AB','Canada','T0H 1Z0','',''),('JJ','EN',1,'640 Main Street','','Humboldt','SK','Canada','S0K 2A0','',''),('JL','EN',1,'619 Main Street','','Swan River','MB','Canada','R0L 1Z0','',''),('KA','EN',1,'997498 Hwy 11 North','','New Liskeard','ON','Canada','P0J 1P0','',''),('KB','EN',1,'1087 Brodie Drive','','Orillia','ON','Canada','L3V 6H4','',''),('KC','EN',1,'10216 Hwy 26 East','','Collingwood','ON','Canada','L9Y 4H9','',''),('KG','EN',1,'165 Muskoka Road North','','Gravenhurst','ON','Canada','P1P 1X2','',''),('KK','EN',1,'70 King William Street','','Huntsville','ON','Canada','P1H 2A5','',''),('KM','EN',1,'16825 Highway 12','','Midland','ON','Canada','L4R 0A9','',''),('KN','EN',1,'34 Marshall Avenue East','','North Bay','ON','Canada','P1A 1R1','',''),('KP','EN',1,'1200 Pembroke St W.','','Pembroke','ON','Canada','K8A 7T1','',''),('KS','EN',1,'48 Sydenham St','','Simcoe','ON','Canada','N3Y 4X8','',''),('M2','EN',1,'5-1784 Stone Church Rd E','','Hamilton','ON','Canada','L8J 0B4','',''),('M3','EN',1,'3140 Argentia Rd','','Mississauga','ON','Canada','L5N 0B1','',''),('M4','EN',1,'5252 541 Hespeler Road','','Cambridge','ON','Canada','N1R 6J2','',''),('M5','EN',1,'Unit A4B, 40 Kingston Road East','','Ajax','ON','Canada','L1Z 1G1','',''),('Markham','EN',1,'#1 9809 MarkhamRoad','','Markham','ON','Canada','L6E 0E5','905-201-3470',''),('MJ','EN',1,'10 Chester Road','','Moose Jaw','MB','Canada','S6J 1M2','',''),('NA','EN',1,'5128 - 50th Street','','Rocky Mountain','AB','Canada','T4T 1A1','',''),('NB','EN',1,'3725 56 Street','','Wetaskiwin','AB','Canada','T9A 2V6','',''),('NorthYork','EN',1,'4250 Dufferin Street','','North York','ON','Canada','M3H 5W4','416-635-5522',''),('PR','EN',1,'1011 United Blvd','','Coquitlam','BC','Canada','V3K 6V3','',''),('RichmondHill','EN',1,'45 Red Maple Road','','Richmond Hill','ON','Canada','L4B 4M6','905-731-2221',''),('SE','EN',1,'2770 Victoria Ave','','Regina','SK','Canada','S4N 6M5','',''),('SH','EN',1,'Unit 100, 3047 Clarence Avenue South','','Saskatoon','SK','Canada','S7T 0B4','',''),('SS','EN',1,'60 - 33rd Street East','','Saskatoon','SK','Canada','S7K 0R9','',''),('SY','EN',1,'Box 1887, 91 - 7th Ave South','','Yorkton','SK','Canada','S3N 3V2','',''),('UR','EN',1,'920 Park Street','','Regina','SK','Canada','S4N 4Y3','','');

--
-- Table structure for table `branchesAssetData`
--

CREATE TABLE `branchesAssetData` (
  `BRANCHCODE` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `TAG` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `VALUE` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`BRANCHCODE`,`TAG`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `branchesAssetData`
--


--
-- Table structure for table `branchesFixtures`
--

CREATE TABLE `branchesFixtures` (
  `BRANCHCODE` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `FIXTURECODE` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `FIXTUREQTY` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`BRANCHCODE`,`FIXTURECODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `branchesFixtures`
--


--
-- Table structure for table `campaign_fixtures`
--

CREATE TABLE `campaign_fixtures` (
  `CODE` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `DESCRIPTION` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `NOTES` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`CODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `campaign_fixtures`
--


--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `CATID` int NOT NULL AUTO_INCREMENT,
  `NAME` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `DESCRIPTION` varchar(200) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ICONURL` varchar(200) COLLATE utf8mb3_unicode_ci NOT NULL,
  `LANGUAGE` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'EN',
  `USERLEVEL` int NOT NULL DEFAULT '0',
  `COMMENTS` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `CREATEDDATE` datetime DEFAULT NULL,
  `MODIFIEDDATE` datetime DEFAULT NULL,
  PRIMARY KEY (`CATID`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` VALUES (25,'Business Card',' ','icon_businesscard.png','EN',0,'','2021-04-23 15:52:30','2021-04-23 15:54:00'),(26,'Hanging Poster',' ','icon_hanging.png','EN',0,'','2021-05-07 15:50:46','2021-05-21 14:26:57'),(27,'Furniture',' ','icon_furniture.png','EN',0,'','2021-05-07 15:52:26','2021-05-21 12:55:08'),(28,'Mattresses',' ','icon_mattresses.png','EN',0,'','2021-05-21 12:56:48','2021-05-21 13:02:22'),(29,'Appliances',' ','icon_appliances.png','EN',0,'','2021-05-21 12:57:26','2021-05-21 13:02:30'),(30,'Electronics',' ','icon_electronics.png','EN',0,'','2021-05-21 12:58:12','2021-05-21 13:02:39');

--
-- Table structure for table `categoriesBrand`
--

CREATE TABLE `categoriesBrand` (
  `CATID` int NOT NULL,
  `BRANDNAME` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`CATID`,`BRANDNAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `categoriesBrand`
--

INSERT INTO `categoriesBrand` VALUES (25,'ALL'),(26,'ALL'),(27,'ALL'),(28,'ALL'),(29,'ALL'),(30,'ALL');

--
-- Table structure for table `downloadLog`
--

CREATE TABLE `downloadLog` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `USERNAME` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `BRANCHCODE` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ITEMID` int NOT NULL,
  `LOGTIME` datetime NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `downloadLog`
--


--
-- Table structure for table `emailTransmissionLog`
--

CREATE TABLE `emailTransmissionLog` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `TOEMAIL` varchar(100) DEFAULT NULL,
  `CCEMAIL` varchar(100) DEFAULT NULL,
  `SUBJECT` varchar(1000) DEFAULT NULL,
  `BODY` text,
  `ATTACHMENTS` varchar(1000) DEFAULT NULL,
  `INITIALSTATUS` varchar(10) DEFAULT NULL,
  `STATUS` varchar(10) DEFAULT NULL,
  `DATE` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=223 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `emailTransmissionLog`
--

INSERT INTO `emailTransmissionLog` VALUES (219,'peggy@creativepath.com','','A new artwork has been created in the MRM system.','<html>\n    <body>\n        <div style=\"font-family:Ubuntu,\'Lucida Grande\',Helvetica,Arial,sans-serif; font-size:11px; line-height:1.3; margin: 20px auto; padding: 20px; width:700px; min-height:900px; border-width:1px; border-style:solid; border-color:rgb(221,221,221);\">\n\n            <h5 style=\"font-size:22px;line-height:1.2;margin: 0px 0px 20px 0px;padding:15px 15px 15px 5px;color:rgb(0,0,0);font-weight:normal;text-align:left\">\n                A new artwork has been created in the MRM system.\n            </h5>\n\n            <div style=\"text-align:center; margin:0 auto; width:500px;\">\n            <div style=\"border:1px solid #000; padding:3px;\">\n                <img src=\"http://thebrick.cpfulfillment.com/companyResources/BRICK/uploadFiles/BRK-4000715-RichmondHill-BCardQRFea_Brick-00001.jpg\" style=\"width:490px;\">\n            </div>\n            </div>\n\n            <h3>\n                The artwork must be approved before it can be placed on orders. Please click on the link below to view the proof file and approve/reject the artwork. \n            </h3>\n\n            <h3><a href=\"http://thebrick.cpfulfillment.com/ConfirmAsset.php?ID=91a30f07f6c0b27acb015732d497b1c6\">http://thebrick.cpfulfillment.com/ConfirmAsset.php?ID=91a30f07f6c0b27acb015732d497b1c6</a></h3>\n\n        </div>\n    </body>\n</html>\n','a:0:{}','SENT','SENT','2021-04-30 10:28:52'),(220,'peggy@creativepath.com','','A new artwork has been approved in the MRM system.','<html>\n    <body>\n        <div style=\"font-family:Ubuntu,\'Lucida Grande\',Helvetica,Arial,sans-serif; font-size:11px; line-height:1.3; margin: 20px auto; padding: 20px; width:700px; min-height:900px; border-width:1px; border-style:solid; border-color:rgb(221,221,221);\">\n\n            <h5 style=\"font-size:22px;line-height:1.2;margin: 0px 0px 20px 0px;padding:15px 15px 15px 5px;color:rgb(0,0,0);font-weight:normal;text-align:left\">\n                A new artwork has been approved in the MRM system.\n            </h5>\n\n            <div style=\"text-align:center; margin:0 auto; width:500px;\">\n            <div style=\"border:1px solid #000; padding:3px;\">\n                <img src=\"http://thebrick.cpfulfillment.com/companyResources/BRICK/uploadFiles/BRK-4000715-RichmondHill-BCardQRFea_Brick-00001.jpg\" style=\"width:490px;\">\n            </div>\n            </div>\n\n            <h3>\n                The artwork has been approved. It can now be placed on orders. You can click on the link below to go to the artwork in the MRM system. \n            </h3>\n\n            <h3><a href=\"http://thebrick.cpfulfillment.com/product.php?itemid=4000715\">http://thebrick.cpfulfillment.com/product.php?itemid=4000715</a></h3>\n\n        </div>\n    </body>\n</html>\n','a:0:{}','SENT','SENT','2021-04-30 10:30:14'),(221,'orders@cpfulfillment.com','','A New order has been placed order#: BRK-10000','<html>\n\n<body>\n    <div\n        style=\"font-family:Ubuntu,\'Lucida Grande\',Helvetica,Arial,sans-serif; font-size:11px; line-height:1.3; margin: 20px auto; padding: 20px; width:700px; min-height:900px; border-width:1px; border-style:solid; border-color:rgb(221,221,221);\">\n\n        <h5\n            style=\"font-size:22px;line-height:1.2;margin: 0px 0px 20px 0px;padding:15px 15px 15px 5px;color:rgb(0,0,0);font-weight:normal;text-align:left\">\n            Print Order\n        </h5>\n\n        <h3>\n            Order BRK-10000 successfully entered.<br />\n            Payment Reference #: BHO<br/>\n            \n            Your order is now being processed. When your order ships you will receive a confirmation email with tracking information.\n        </h3>\n        <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n\n        <h3>  </h3>\n\n        <table width=\"100%\"\n            style=\"margin:10px 0px;background-color:rgb(255,255,255);padding:0px 0px;border-collapse:collapse;border-width:0px;\">\n            <tbody>\n                <tr style=\"background-color:rgb(241,241,241)\">\n                    <td valign=\"top\" align=\"left\" width=\"100%\" bgcolor=\"#ffffff\">\n\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin: 0px; padding:10px 0px; border-top-width:2pt;border-top-style:solid;border-top-color:rgb(221,221,221)\">\n                            Order details:\n                        </h4>\n\n                        <div style=\"font-size:11px;line-height:1.3\"> <br /> </div>\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:150px;clear:none;display:inline-block\">\n                            Order Number:\n                        </h5>\n                        BRK-10000\n                        <br>\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:150px;clear:none;display:inline-block\">\n                            Shipping Contact:\n                        </h5>\n                        Zoey Cui\n                        <br>\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:150px;clear:none;display:inline-block\">\n                            Order Date:\n                        </h5>\n                        2024-09-07\n\n                        \n\n                        \n\n                        <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n\n                    </td>\n                </tr>\n            </tbody>\n        </table>\n        <table width=\"100%\"\n            style=\"margin:10px 0px;background-color:rgb(255,255,255);padding:0px 0px;border-collapse:collapse;border-width:0px;\">\n            <tbody>\n                <tr style=\"background-color:rgb(241,241,241)\">\n                    <td valign=\"top\" align=\"left\" width=\"48%\" bgcolor=\"#ffffff\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin: 0px; padding:10px 0px; border-top-width:2pt;border-top-style:solid;border-top-color:rgb(221,221,221)\">\n                            Ship-to Information:\n                        </h4>\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Company:\n                        </h5>\n                        Creative Path Digital Imaging Inc.   (#CPDI)\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Address:\n                        </h5>\n                        1455-16th Avenue, Unit 1 & 2\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            City:\n                        </h5>\n                        Richmond Hill\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Province:\n                        </h5>\n                        ON\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Country:\n                        </h5>\n                        Canada\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Postal:\n                        </h5>\n                        L4B 4W5\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Phone:\n                        </h5>\n                        905.709.9609\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Fax:\n                        </h5>\n                        905.709.9610\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Email:\n                        </h5>\n                        zoeyc@cpfulfillment.com\n                        <br />\n\n                        <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n                        <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n                    </td>\n                    <td valign=\"top\" align=\"left\" width=\"4%\" bgcolor=\"#ffffff\">\n                    </td>\n                    <td valign=\"top\" align=\"left\" width=\"48%\" bgcolor=\"#ffffff\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin: 0px; padding:10px 0px; border-top-width:2pt;border-top-style:solid;border-top-color:rgb(221,221,221)\">\n                            Bill-To Information:\n                        </h4>\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Company:\n                        </h5>\n                        Creative Path Digital Imaging Inc. \n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Address:\n                        </h5>\n                        1455-16th Avenue, Unit 1 & 2\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            City:\n                        </h5>\n                        Richmond Hill\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Province:\n                        </h5>\n                        ON\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Country:\n                        </h5>\n                        Canada\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Postal:\n                        </h5>\n                        L4B 4W5\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Phone:\n                        </h5>\n                        905.709.9609\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Fax:\n                        </h5>\n                        905.709.9610\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Order Placed By:\n                        </h5>\n                        Zoey Cui\n                        <br />\n\n                        <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n                    </td>\n\n                    <td valign=\"top\" align=\"left\" width=\"10px\" bgcolor=\"#ffffff\">\n                    </td>\n\n                    <td valign=\"top\" align=\"left\" bgcolor=\"#ffffff\">\n                        <div style=\"display:none;\">\n                            <h4\n                                style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin: 0px 10px; padding:10px 0px; border-top-width:2pt;border-top-style:solid;border-top-color:rgb(221,221,221)\">\n                                ETA:\n                            </h4>\n\n                            <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n\n                            <h5\n                                style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                                <b>Seven Working Days</b>\n                            </h5>\n\n                            <br><br><br>\n\n                            <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n                        </div>\n                    </td>\n                </tr>\n            </tbody>\n        </table>\n\n        <table cellpadding=\"5\" cellspacing=\"1\" width=\"100%\"\n            style=\"margin-top:10px;margin-right:0px;margin-bottom:10px;margin-left:0px;background-color:rgb(255,255,255);border-top-width:2px;border-top-style:solid;border-top-color:rgb(221,221,221);border-bottom-width:2px;border-bottom-style:solid;border-bottom-color:rgb(221,221,221);border-collapse:collapse\">\n            <tbody>\n                <tr\n                    style=\"background-color:rgb(241,241,241);border-top-width:1px;border-top-style:solid;border-top-color:rgb(221,221,221)\">\n                    <td align=\"left\" width=\"140px\"\n                        style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n                            Item Code\n                        </h4>\n                    </td>\n\n                    <td align=\"left\"\n                        style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n                            Description\n                        </h4>\n                    </td>\n\n                    <td align=\"right\" width=\"100px\"\n                        style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n                            Qty\n                        </h4>\n                    </td>\n\n                    <td align=\"right\" width=\"130px\"\n                        style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n                            Ext. Price\n                        </h4>\n                    </td>\n                </tr>\n                <tr style=\"background-color:rgb(241,241,241);border-top-width:1px;border-top-style:solid;border-top-color:rgb(221,221,221)\">\r\n<td align=\"left\" style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">4000715</td>\r\n<td align=\"left\" style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">Business Card Template with QR Generator Features  (Demo Test Demo)</td>\r\n<td align=\"right\" style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">500</td>\r\n<td style=\"text-align:right; background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">$ 0.00</td>\r\n </tr>\r\n\n                <tr><td colspan=\"3\" style=\"text-align:right;\">Cannot Determine Shipping Cost (Will be added later):</td><td style=\"text-align:right;\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px;>N/A</td><td colspan=\"1\"></td></tr><tr><td colspan=\"3\" style=\"text-align:right;\">Grand Total:</td><td style=\"text-align:right;\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px;>$ 0.00</td><td colspan=\"1\"></td></tr>\n\n            </tbody>\n        </table>\n\n        <h4\n            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n            Special Instructions:\n        </h4>\n        test\n\n\n        <h4\n            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n            Note To Receiver:\n        </h4>\n        \n    </div>\n\n\n\n</body>\n\n</html><a href=\"http://brick.cpfulfillment.com/downloadOrderWorksheetRedirector.php?name=BRK-10000.xlsx&path=/var/www/PrintOS/companyResources/BRICK/generatedFiles/GEN66dc939075f404.50329113.xlsx\" style=\"text-decoration:none; padding:8px 16px; width:124px; height:43px; background-color:rgb(225,225,225); color:black; border: 1px solid rgb(173,173,173);\">BRK-10000.xlsx</a>&nbsp;&nbsp;&nbsp;&nbsp;','a:1:{i:0;a:2:{s:4:\"path\";s:86:\"/var/www/PrintOS/companyResources/BRICK/generatedFiles/GEN66dc939075f404.50329113.xlsx\";s:4:\"name\";s:14:\"BRK-10000.xlsx\";}}','SENT','SENT','2024-09-07 13:55:28'),(222,'zoeyc@cpfulfillment.com','','A New order has been placed order#: BRK-10000','<html>\n\n<body>\n    <div\n        style=\"font-family:Ubuntu,\'Lucida Grande\',Helvetica,Arial,sans-serif; font-size:11px; line-height:1.3; margin: 20px auto; padding: 20px; width:700px; min-height:900px; border-width:1px; border-style:solid; border-color:rgb(221,221,221);\">\n\n        <h5\n            style=\"font-size:22px;line-height:1.2;margin: 0px 0px 20px 0px;padding:15px 15px 15px 5px;color:rgb(0,0,0);font-weight:normal;text-align:left\">\n            Print Order\n        </h5>\n\n        <h3>\n            Order BRK-10000 successfully entered.<br />\n            Payment Reference #: BHO<br/>\n            \n            Your order is now being processed. When your order ships you will receive a confirmation email with tracking information.\n        </h3>\n        <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n\n        <h3>  </h3>\n\n        <table width=\"100%\"\n            style=\"margin:10px 0px;background-color:rgb(255,255,255);padding:0px 0px;border-collapse:collapse;border-width:0px;\">\n            <tbody>\n                <tr style=\"background-color:rgb(241,241,241)\">\n                    <td valign=\"top\" align=\"left\" width=\"100%\" bgcolor=\"#ffffff\">\n\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin: 0px; padding:10px 0px; border-top-width:2pt;border-top-style:solid;border-top-color:rgb(221,221,221)\">\n                            Order details:\n                        </h4>\n\n                        <div style=\"font-size:11px;line-height:1.3\"> <br /> </div>\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:150px;clear:none;display:inline-block\">\n                            Order Number:\n                        </h5>\n                        BRK-10000\n                        <br>\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:150px;clear:none;display:inline-block\">\n                            Shipping Contact:\n                        </h5>\n                        Zoey Cui\n                        <br>\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:150px;clear:none;display:inline-block\">\n                            Order Date:\n                        </h5>\n                        2024-09-07\n\n                        \n\n                        \n\n                        <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n\n                    </td>\n                </tr>\n            </tbody>\n        </table>\n        <table width=\"100%\"\n            style=\"margin:10px 0px;background-color:rgb(255,255,255);padding:0px 0px;border-collapse:collapse;border-width:0px;\">\n            <tbody>\n                <tr style=\"background-color:rgb(241,241,241)\">\n                    <td valign=\"top\" align=\"left\" width=\"48%\" bgcolor=\"#ffffff\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin: 0px; padding:10px 0px; border-top-width:2pt;border-top-style:solid;border-top-color:rgb(221,221,221)\">\n                            Ship-to Information:\n                        </h4>\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Company:\n                        </h5>\n                        Creative Path Digital Imaging Inc.   (#CPDI)\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Address:\n                        </h5>\n                        1455-16th Avenue, Unit 1 & 2\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            City:\n                        </h5>\n                        Richmond Hill\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Province:\n                        </h5>\n                        ON\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Country:\n                        </h5>\n                        Canada\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Postal:\n                        </h5>\n                        L4B 4W5\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Phone:\n                        </h5>\n                        905.709.9609\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Fax:\n                        </h5>\n                        905.709.9610\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Email:\n                        </h5>\n                        zoeyc@cpfulfillment.com\n                        <br />\n\n                        <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n                        <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n                    </td>\n                    <td valign=\"top\" align=\"left\" width=\"4%\" bgcolor=\"#ffffff\">\n                    </td>\n                    <td valign=\"top\" align=\"left\" width=\"48%\" bgcolor=\"#ffffff\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin: 0px; padding:10px 0px; border-top-width:2pt;border-top-style:solid;border-top-color:rgb(221,221,221)\">\n                            Bill-To Information:\n                        </h4>\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Company:\n                        </h5>\n                        Creative Path Digital Imaging Inc. \n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Address:\n                        </h5>\n                        1455-16th Avenue, Unit 1 & 2\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            City:\n                        </h5>\n                        Richmond Hill\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Province:\n                        </h5>\n                        ON\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Country:\n                        </h5>\n                        Canada\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Postal:\n                        </h5>\n                        L4B 4W5\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Phone:\n                        </h5>\n                        905.709.9609\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Fax:\n                        </h5>\n                        905.709.9610\n                        <br />\n\n                        <h5\n                            style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                            Order Placed By:\n                        </h5>\n                        Zoey Cui\n                        <br />\n\n                        <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n                    </td>\n\n                    <td valign=\"top\" align=\"left\" width=\"10px\" bgcolor=\"#ffffff\">\n                    </td>\n\n                    <td valign=\"top\" align=\"left\" bgcolor=\"#ffffff\">\n                        <div style=\"display:none;\">\n                            <h4\n                                style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin: 0px 10px; padding:10px 0px; border-top-width:2pt;border-top-style:solid;border-top-color:rgb(221,221,221)\">\n                                ETA:\n                            </h4>\n\n                            <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n\n                            <h5\n                                style=\"font-size:12px;line-height:1.3;margin:0px; padding:0px; color:#000;font-weight:normal;text-align:left;width:120px;clear:none;display:inline-block\">\n                                <b>Seven Working Days</b>\n                            </h5>\n\n                            <br><br><br>\n\n                            <div style=\"font-size:11px;line-height:1.3\"> <br> </div>\n                        </div>\n                    </td>\n                </tr>\n            </tbody>\n        </table>\n\n        <table cellpadding=\"5\" cellspacing=\"1\" width=\"100%\"\n            style=\"margin-top:10px;margin-right:0px;margin-bottom:10px;margin-left:0px;background-color:rgb(255,255,255);border-top-width:2px;border-top-style:solid;border-top-color:rgb(221,221,221);border-bottom-width:2px;border-bottom-style:solid;border-bottom-color:rgb(221,221,221);border-collapse:collapse\">\n            <tbody>\n                <tr\n                    style=\"background-color:rgb(241,241,241);border-top-width:1px;border-top-style:solid;border-top-color:rgb(221,221,221)\">\n                    <td align=\"left\" width=\"140px\"\n                        style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n                            Item Code\n                        </h4>\n                    </td>\n\n                    <td align=\"left\"\n                        style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n                            Description\n                        </h4>\n                    </td>\n\n                    <td align=\"right\" width=\"100px\"\n                        style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n                            Qty\n                        </h4>\n                    </td>\n\n                    <td align=\"right\" width=\"130px\"\n                        style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">\n                        <h4\n                            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n                            Ext. Price\n                        </h4>\n                    </td>\n                </tr>\n                <tr style=\"background-color:rgb(241,241,241);border-top-width:1px;border-top-style:solid;border-top-color:rgb(221,221,221)\">\r\n<td align=\"left\" style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">4000715</td>\r\n<td align=\"left\" style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">Business Card Template with QR Generator Features  (Demo Test Demo)</td>\r\n<td align=\"right\" style=\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">500</td>\r\n<td style=\"text-align:right; background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px\">$ 0.00</td>\r\n </tr>\r\n\n                <tr><td colspan=\"3\" style=\"text-align:right;\">Cannot Determine Shipping Cost (Will be added later):</td><td style=\"text-align:right;\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px;>N/A</td><td colspan=\"1\"></td></tr><tr><td colspan=\"3\" style=\"text-align:right;\">Grand Total:</td><td style=\"text-align:right;\"background-color:rgb(255,255,255);padding-top:3px;padding-right:0px;padding-bottom:3px;padding-left:0px;>$ 0.00</td><td colspan=\"1\"></td></tr>\n\n            </tbody>\n        </table>\n\n        <h4\n            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n            Special Instructions:\n        </h4>\n        test\n\n\n        <h4\n            style=\"font-size:13px;line-height:1.2;font-weight:bold;color:rgb(51,51,51);margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px\">\n            Note To Receiver:\n        </h4>\n        \n    </div>\n\n\n\n</body>\n\n</html>','a:0:{}','SENT','SENT','2024-09-07 13:55:28');

--
-- Table structure for table `faq`
--

CREATE TABLE `faq` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `MAINCATEGORY` int NOT NULL DEFAULT '0',
  `NAMEEN` varchar(100) NOT NULL DEFAULT '',
  `NAMEFR` varchar(100) NOT NULL DEFAULT '',
  `CONTENTEN` varchar(2000) NOT NULL DEFAULT '',
  `CONTENTFR` varchar(2000) NOT NULL DEFAULT '',
  `LINKS` varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `faq`
--

INSERT INTO `faq` VALUES (2,1,'Account','Account FRE','Account text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text text\nAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text text\n\nAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text text\n\nAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text text\n\nAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text text\nAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text text\nAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text text\n\nAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text textAccount text text','Account FRE text textAccount FRE text textAccount FRE text textAccount FRE text textAccount FRE text textAccount FRE text textAccount FRE text textAccount FRE text textAccount FRE text textAccount FRE text textAccount FRE text textAccount FRE text textAccount FRE text textAccount FRE text textAccount FRE text text',''),(3,1,'Demo 2','Demo 2','Demo texgteasfsdaf','Demo texgteasfsdaf','');

--
-- Table structure for table `itemPricing`
--

CREATE TABLE `itemPricing` (
  `ITEMID` int NOT NULL,
  `QTY` int NOT NULL,
  `PRICE` decimal(19,4) NOT NULL,
  `LENGTH` decimal(19,4) NOT NULL,
  `WIDTH` decimal(19,4) NOT NULL,
  `HEIGHT` decimal(19,4) NOT NULL,
  `WEIGHT` decimal(19,6) NOT NULL,
  `PIECES` int NOT NULL,
  `ITEMOPTION` varchar(30) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`ITEMID`,`QTY`,`ITEMOPTION`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `itemPricing`
--

INSERT INTO `itemPricing` VALUES (4000712,500,0.0000,0.0000,0.0000,0.0000,0.000000,1,''),(4000713,500,0.0000,0.0000,0.0000,0.0000,0.000000,1,''),(4000714,500,0.0000,0.0000,0.0000,0.0000,0.000000,1,''),(4000715,500,0.0000,0.0000,0.0000,0.0000,0.000000,1,'');

--
-- Table structure for table `items`
--

CREATE TABLE `items` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `TYPE` int NOT NULL DEFAULT '0',
  `CODE` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `DESCRIPTION` varchar(200) COLLATE utf8mb3_unicode_ci NOT NULL,
  `SIZE` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `NUMPAGES` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `STATUS` int NOT NULL DEFAULT '1',
  `MINLEVEL` int NOT NULL DEFAULT '0',
  `LEADTIME` int NOT NULL DEFAULT '0',
  `DISPLAYIMAGENAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `DISPLAYIMAGEPATH` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PROOFPDFNAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PROOFPDFPATH` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PREVIEWIMAGENAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PREVIEWIMAGEPATH` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PARENTITEM` int DEFAULT '0',
  `ARCHIVED` int DEFAULT '0',
  `GENERATEDBY` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ASSETAPPROVED` int DEFAULT '1',
  `PARAMETERSFILENAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PARAMETERSFILEPATH` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `APPROVALLINK` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PRODUCEDETAIL` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPBOXINSLEEVE` int NOT NULL DEFAULT '0',
  `SKIPPDFPERMISSIONCHECK` int NOT NULL DEFAULT '0',
  `DLSUGGESTIONS` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `CREATED` datetime DEFAULT CURRENT_TIMESTAMP,
  `MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `PRINTINGTYPE` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `STOCK` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=4000716 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `items`
--

INSERT INTO `items` VALUES (4000712,2,'BCard_Brick','Business Card Template','3.5\" x 2\"','1',1,0,0,'BCard_Brick.png','/companyResources/BRICK/uploadFiles/BCard_Brick.png','thebrick_bc_temp.pdf','/companyResources/BRICK/uploadFiles/thebrick_bc_temp.pdf','','',0,0,NULL,1,'4000712_genfile.txt','/companyResources/BRICK/uploadFiles/4000712_genfile.txt',NULL,'',0,0,'','2022-06-03 14:35:51','2022-06-03 18:35:51',NULL,NULL),(4000713,2,'BCardQR_Brick','Business Card Template with QR Code','3.5\" x 2\"','1',1,0,0,'thebrick_bc_qr.png','/companyResources/BRICK/uploadFiles/thebrick_bc_qr.png','thebrick_bc_temp.pdf','/companyResources/BRICK/uploadFiles/thebrick_bc_temp.pdf','','',0,0,NULL,1,'4000713_genfile.txt','/companyResources/BRICK/uploadFiles/4000713_genfile.txt',NULL,'',0,0,'','2022-06-03 14:35:51','2022-06-03 18:35:51',NULL,NULL),(4000714,2,'BCardQRFea_Brick','Business Card Template with QR Generator Features','3.5\" x 2\"','1',1,0,0,'BCardQRFea_Brick.png','/companyResources/BRICK/uploadFiles/BCardQRFea_Brick.png','thebrick_bc_temp.pdf','/companyResources/BRICK/uploadFiles/thebrick_bc_temp.pdf','','',0,0,NULL,1,'4000714_genfile.txt','/companyResources/BRICK/uploadFiles/4000714_genfile.txt',NULL,'',0,0,'','2022-06-03 14:35:51','2022-06-03 18:35:51',NULL,NULL),(4000715,3,'BCardQRFea_Brick-00001','Business Card Template with QR Generator Features  (Demo Test Demo)','3.5\" x 2\"','1',1,0,0,'BRK-4000715-RichmondHill-BCardQRFea_Brick-00001.jpg','/companyResources/BRICK/uploadFiles/BRK-4000715-RichmondHill-BCardQRFea_Brick-00001.jpg','BRK-4000715-RichmondHill-BCardQRFea_Brick-00001.pdf','/companyResources/BRICK/printAssets/BRK-4000715-RichmondHill-BCardQRFea_Brick-00001.pdf','BRK-4000715-RichmondHill-BCardQRFea_Brick-00001.pdf','/companyResources/BRICK/uploadFiles/BRK-4000715-RichmondHill-BCardQRFea_Brick-00001.pdf',4000714,0,'richmondhill',1,'','',NULL,'',0,0,'','2022-06-03 14:35:51','2022-06-03 18:35:51',NULL,NULL);

--
-- Table structure for table `itemsAdjustmentLog`
--

CREATE TABLE `itemsAdjustmentLog` (
  `ADJID` int NOT NULL AUTO_INCREMENT,
  `ITEMID` int NOT NULL,
  `QTY` int NOT NULL,
  `ADJDATE` datetime NOT NULL,
  `REASON` varchar(200) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`ADJID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `itemsAdjustmentLog`
--


--
-- Table structure for table `itemsBranchesLink`
--

CREATE TABLE `itemsBranchesLink` (
  `ITEMID` int NOT NULL,
  `BRANCHCODE` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`ITEMID`,`BRANCHCODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `itemsBranchesLink`
--

INSERT INTO `itemsBranchesLink` VALUES (4000712,'ALL_BRANCHES'),(4000713,'ALL_BRANCHES'),(4000714,'ALL_BRANCHES'),(4000715,'RichmondHill');

--
-- Table structure for table `itemsInventory`
--

CREATE TABLE `itemsInventory` (
  `ITEMID` int NOT NULL,
  `QTYONHAND` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`ITEMID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `itemsInventory`
--


--
-- Table structure for table `itemsPrintDefinition`
--

CREATE TABLE `itemsPrintDefinition` (
  `ID` int NOT NULL,
  `PRESS` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `NUMPAGES` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `BLEEDS` int DEFAULT NULL,
  `COLOURS` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `FLATSIZE` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `FINISHSIZE` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `STOCK` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PARENTSHEETSIZE` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PRESSSHEETSIZE` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `NUMUP` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `LAYOUTORIENTATION` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `COATING` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `CONTOURCUT` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `LAMINATION` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `FINISHING` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ACCESSORY` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SPECIALINSTRUCTIONS` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PACKAGELOCATION` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `OUT` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `FINISHED` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `OVERS` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `GROSS` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `MEMO` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `itemsPrintDefinitioncol` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `itemsPrintDefinition`
--


--
-- Table structure for table `itemsSubcategoryLink`
--

CREATE TABLE `itemsSubcategoryLink` (
  `ITEMID` int NOT NULL,
  `SUBCATID` int NOT NULL,
  PRIMARY KEY (`ITEMID`,`SUBCATID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `itemsSubcategoryLink`
--

INSERT INTO `itemsSubcategoryLink` VALUES (4000712,42),(4000713,42),(4000714,42),(4000715,42);

--
-- Table structure for table `newsItems`
--

CREATE TABLE `newsItems` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `STARTDATE` date NOT NULL,
  `ENDDATE` date NOT NULL,
  `LANGUAGE` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL,
  `TITLE` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL,
  `MESSAGE` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `newsItems`
--


--
-- Table structure for table `orderDetail`
--

CREATE TABLE `orderDetail` (
  `ITEMLINE` int NOT NULL AUTO_INCREMENT,
  `ORDERID` int NOT NULL,
  `ITEMID` int NOT NULL,
  `ITEMCODE` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ITEMDESC` varchar(200) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ITEMOPTION` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ORDERQTY` int NOT NULL,
  `SHIPTODATEQTY` int NOT NULL,
  `UNITPRICE` decimal(19,4) DEFAULT NULL,
  `EXTPRICE` decimal(19,4) DEFAULT NULL,
  `TAXAMT1` decimal(19,4) DEFAULT NULL,
  `TAXAMT2` decimal(19,4) DEFAULT NULL,
  `TAXAMT3` decimal(19,4) DEFAULT NULL,
  `TAXAMT4` decimal(19,4) DEFAULT NULL,
  `TAXAMT5` decimal(19,4) DEFAULT NULL,
  `ITEMLENGTH` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ITEMWIDTH` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ITEMHEIGHT` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ITEMWEIGHT` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ITEMPIECES` int DEFAULT NULL,
  `PROOFCONFIRMATION` varchar(200) COLLATE utf8mb3_unicode_ci NOT NULL,
  `DOWNLOADLINK` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`ITEMLINE`,`ORDERID`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `orderDetail`
--

INSERT INTO `orderDetail` VALUES (1,1,4000715,'BCardQRFea_Brick-00001','Business Card Template with QR Generator Features  (Demo Test Demo)','',500,0,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0.0000','0.0000','0.0000','0.000000',1,'zoey',NULL),(2,2,4000715,'BCardQRFea_Brick-00001','Business Card Template with QR Generator Features  (Demo Test Demo)','',500,0,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0.0000','0.0000','0.0000','0.000000',1,'Zoey Cui - Testing',NULL);

--
-- Table structure for table `orderHeader`
--

CREATE TABLE `orderHeader` (
  `ORDERID` int NOT NULL AUTO_INCREMENT,
  `USERNAME` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ORDERDATE` datetime NOT NULL,
  `ORDERMODIFIED` datetime NOT NULL,
  `PONUMBER` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPCONTACTFIRSTNAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPCONTACTLASTNAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPCONTACTPHONE` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPCONTACTFAX` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPCONTACTEMAIL` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPNAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPADDRESS` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPADDRESS2` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPCITY` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPPROVINCE` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPCOUNTRY` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPPOSTAL` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ORDERSTATUS` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `TAXNAME1` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `TAXNAME2` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `TAXNAME3` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `TAXNAME4` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `TAXNAME5` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `TAXRATE1` decimal(19,4) DEFAULT NULL,
  `TAXRATE2` decimal(19,4) DEFAULT NULL,
  `TAXRATE3` decimal(19,4) DEFAULT NULL,
  `TAXRATE4` decimal(19,4) DEFAULT NULL,
  `TAXRATE5` decimal(19,4) DEFAULT NULL,
  `SHIPPINGCOST` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `SPECIALINSTRUCTIONS` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `RECEIVERINSTRUCTIONS` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `APPROVALLINK` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `EXPDATE` datetime DEFAULT NULL,
  `SHIPTAXGROUP` varchar(6) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ORDERREF` int DEFAULT NULL,
  `PAYMENTREF` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPSTOREID` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `SHIPPINGCOSTTAXAMT1` decimal(19,4) DEFAULT '0.0000',
  `SHIPPINGCOSTTAXAMT2` decimal(19,4) DEFAULT '0.0000',
  `SHIPPINGCOSTTAXAMT3` decimal(19,4) DEFAULT '0.0000',
  `SHIPPINGCOSTTAXAMT4` decimal(19,4) DEFAULT '0.0000',
  `SHIPPINGCOSTTAXAMT5` decimal(19,4) DEFAULT '0.0000',
  `SHIPPINGMETHOD` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT 'N/A',
  `REQCONTACTFIRSTNAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `REQCONTACTLASTNAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `REQCONTACTPHONE` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `REQCONTACTFAX` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `REQNAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `REQADDRESS` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `REQADDRESS2` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `REQCITY` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `REQPROVINCE` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `REQCOUNTRY` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `REQPOSTAL` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `EXTRADATA1` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `APPROVALDATE` datetime DEFAULT NULL,
  `BILLINGCATEGORY` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`ORDERID`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `orderHeader`
--

INSERT INTO `orderHeader` VALUES (1,'zoeyc','2024-09-07 13:55:27','2024-09-07 13:55:27',NULL,'Zoey','Cui','905.709.9609','905.709.9610','zoeyc@cpfulfillment.com','Creative Path Digital Imaging Inc. ','1455-16th Avenue, Unit 1 & 2','','Richmond Hill','ON','Canada','L4B 4W5','ACTIVE','HST','','','','',0.1300,0.0000,0.0000,0.0000,0.0000,0.0000,'test','',NULL,'2024-09-15 13:55:27','ON',10000,'BHO','CPDI',0.0000,0.0000,0.0000,0.0000,0.0000,'N/A','Zoey','Cui','905.709.9609','905.709.9610','Creative Path Digital Imaging Inc. ','1455-16th Avenue, Unit 1 & 2','','Richmond Hill','ON','Canada','L4B 4W5',NULL,NULL,NULL),(2,'zoeyc','2025-02-05 20:31:30','2025-02-05 20:31:30','','Zoey','Cui','905.709.9609','905.709.9610','zoeyc@cpfulfillment.com','Creative Path Digital Imaging Inc. ','1455-16th Avenue, Unit 1 & 2','','Richmond Hill','ON','Canada','L4B 4W5','CART','HST','','','','',0.1300,0.0000,0.0000,0.0000,0.0000,0.0000,NULL,NULL,NULL,'2025-02-13 20:31:30','ON',NULL,NULL,'CPDI',0.0000,0.0000,0.0000,0.0000,0.0000,'N/A','Zoey','Cui','905.709.9609','905.709.9610','Creative Path Digital Imaging Inc. ','1455-16th Avenue, Unit 1 & 2','','Richmond Hill','ON','Canada','L4B 4W5',NULL,NULL,NULL);

--
-- Table structure for table `orderPromos`
--

CREATE TABLE `orderPromos` (
  `ORDERID` int NOT NULL,
  `PROMOCODE` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `PROMONAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `PROMOTYPE` varchar(12) COLLATE utf8mb3_unicode_ci NOT NULL,
  `SINGLEITEM` int NOT NULL DEFAULT '0',
  `PROMOVALUE` decimal(19,2) NOT NULL,
  `CALCDISCOUNT` decimal(19,2) NOT NULL,
  `TAXAMT1` decimal(19,2) NOT NULL,
  `TAXAMT2` decimal(19,2) NOT NULL,
  `TAXAMT3` decimal(19,2) NOT NULL,
  `TAXAMT4` decimal(19,2) NOT NULL,
  `TAXAMT5` decimal(19,2) NOT NULL,
  PRIMARY KEY (`ORDERID`,`PROMOCODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `orderPromos`
--


--
-- Table structure for table `preOrderDefinition`
--

CREATE TABLE `preOrderDefinition` (
  `CODE` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ITEMNAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `SHORTDESC` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `FULLDESC` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `COMPONENTINPUTS` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `DISPLAYIMAGEPATH` varchar(200) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `ACTIVE` int NOT NULL DEFAULT '1',
  `BRAND` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'ALL',
  `EMAILDESC` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `AVAILABLELANGS` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'English|Bilingual',
  PRIMARY KEY (`CODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `preOrderDefinition`
--


--
-- Table structure for table `preOrderDefinitionV2`
--

CREATE TABLE `preOrderDefinitionV2` (
  `ACTIVE` int NOT NULL DEFAULT '1',
  `CODE` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `BRAND` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'ALL',
  `ITEMNAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `INTRODESC` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `INTRODESC_EMAIL` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `ELIGIBLEQUESTION` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `ELIGIBLENO` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `AVAILABLELANGS` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'English|Bilingual',
  `SECTION1NAME` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION1INTRO` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION1INTRO_EMAIL` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION1COMPONENT` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION1FOOTER` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION2NAME` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION2INTRO` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION2INTRO_EMAIL` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION2COMPONENT` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION2FOOTER` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION3NAME` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION3INTRO` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION3INTRO_EMAIL` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION3COMPONENT` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SECTION3FOOTER` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `SUBMITMESSAGE` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `BANNERIMAGE` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT '',
  PRIMARY KEY (`CODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `preOrderDefinitionV2`
--


--
-- Table structure for table `preOrders`
--

CREATE TABLE `preOrders` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `CODE` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `USERNAME` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `BRANCH` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `SKIN` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `STORENAME` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ADDRESS` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ADDRESS2` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `CITY` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PROVINCE` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `COUNTRY` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `POSTALCODE` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `CONTACTNAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `CONTACTEMAIL` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `BASEQTY` int NOT NULL DEFAULT '1',
  `COMPONENTS` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `LANGUAGE` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `preOrders`
--


--
-- Table structure for table `preOrdersV2`
--

CREATE TABLE `preOrdersV2` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `CODE` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `USERNAME` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `BRANCH` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `SKIN` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `STORENAME` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ADDRESS` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ADDRESS2` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `CITY` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `PROVINCE` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `COUNTRY` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `POSTALCODE` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `CONTACTNAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `CONTACTEMAIL` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `CONTACTPHONE` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `COMPONENTS1` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `COMPONENTS2` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `COMPONENTS3` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `LANGUAGE` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `preOrdersV2`
--


--
-- Table structure for table `promos`
--

CREATE TABLE `promos` (
  `CODE` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `NAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `CODETYPE` varchar(12) COLLATE utf8mb3_unicode_ci NOT NULL,
  `STARTDATE` date NOT NULL,
  `ENDDATE` date NOT NULL,
  `SINGLEUSE` int NOT NULL DEFAULT '0',
  `REDEEMED` int NOT NULL DEFAULT '0',
  `PROMOVALUE` decimal(19,2) NOT NULL DEFAULT '0.00',
  `SINGLEITEM` int NOT NULL DEFAULT '0',
  `MAXQTY` int DEFAULT '0',
  `MINQTY` int DEFAULT '0',
  `EXACTQTY` int DEFAULT '0',
  `QTYTYPE` varchar(12) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`CODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `promos`
--


--
-- Table structure for table `promosCategories`
--

CREATE TABLE `promosCategories` (
  `CODE` varchar(50) NOT NULL,
  `CATID` int NOT NULL,
  PRIMARY KEY (`CODE`,`CATID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `promosCategories`
--


--
-- Table structure for table `promosItems`
--

CREATE TABLE `promosItems` (
  `CODE` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ITEMID` int NOT NULL,
  PRIMARY KEY (`CODE`,`ITEMID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `promosItems`
--


--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `key` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `value` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `settings`
--

INSERT INTO `settings` VALUES ('site_maint','0');

--
-- Table structure for table `shipToAddresses`
--

CREATE TABLE `shipToAddresses` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `STOREID` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `NAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ADDRESS` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ADDRESS2` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `CITY` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `PROVINCE` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `COUNTRY` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `POSTAL` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `PHONE` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `FAX` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `TAXGROUP` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL,
  `SHIPZONE` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `shipToAddresses`
--


--
-- Table structure for table `shipToAddressesUserList`
--

CREATE TABLE `shipToAddressesUserList` (
  `ID` int NOT NULL,
  `USERNAME` varchar(50) NOT NULL,
  PRIMARY KEY (`ID`,`USERNAME`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `shipToAddressesUserList`
--


--
-- Table structure for table `shipZoneCosts`
--

CREATE TABLE `shipZoneCosts` (
  `WEIGHT` int NOT NULL,
  `None` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone1` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone2` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone3` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone4` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone5` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone6` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone7` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone8` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone9` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone10` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone11` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone12` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone13` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone14` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone15` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone16` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone17` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone18` decimal(16,2) NOT NULL DEFAULT '0.00',
  `Zone19` decimal(16,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`WEIGHT`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `shipZoneCosts`
--

INSERT INTO `shipZoneCosts` VALUES (0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00);

--
-- Table structure for table `shipmentCostLog`
--

CREATE TABLE `shipmentCostLog` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `CARRIER` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `METHOD` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPFROM_NAME` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPFROM_STREETNUM` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPFROM_STREET` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPFROM_CITY` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPFROM_PROVINCE` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPFROM_COUNTRY` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPFROM_POSTAL` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `TOTALWEIGHT` decimal(19,4) DEFAULT NULL,
  `TOTALBOXES` int DEFAULT NULL,
  `SHIPTO_PROVINCE` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPTO_POSTAL` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `SHIPTO_CITY` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `TOTALPRICE` decimal(19,4) DEFAULT NULL,
  `OURMARKUP` decimal(19,4) DEFAULT NULL,
  `OURSLEEVECHARGE` decimal(19,4) DEFAULT NULL,
  `ORDERID` int DEFAULT NULL,
  `CREATEDATETIME` datetime DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `shipmentCostLog`
--


--
-- Table structure for table `shipmentDetail`
--

CREATE TABLE `shipmentDetail` (
  `SHIPID` int NOT NULL,
  `SHIPLINE` int NOT NULL AUTO_INCREMENT,
  `ORDERID` int NOT NULL,
  `ORDERLINE` int NOT NULL,
  `SHIPQTY` int NOT NULL,
  PRIMARY KEY (`SHIPLINE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `shipmentDetail`
--


--
-- Table structure for table `shipmentHeader`
--

CREATE TABLE `shipmentHeader` (
  `SHIPID` int NOT NULL AUTO_INCREMENT,
  `ORDERID` int NOT NULL,
  `TRACKNUM` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `SHIPDATE` datetime NOT NULL,
  `SHIPMETHOD` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `SHIPAMOUNT` decimal(16,2) NOT NULL,
  `SHIPWEIGHT` decimal(16,4) NOT NULL,
  `SHIPPIECES` int NOT NULL,
  `SHIPINSTRUCTIONS` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`SHIPID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `shipmentHeader`
--


--
-- Table structure for table `shippingGroup`
--

CREATE TABLE `shippingGroup` (
  `SGRPNAME` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `SGRPPIECES` int NOT NULL,
  `SGRPBOXTYPE` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `SGRPWEIGHTPIECE` decimal(19,4) NOT NULL,
  PRIMARY KEY (`SGRPNAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `shippingGroup`
--


--
-- Table structure for table `shippingGroupItems`
--

CREATE TABLE `shippingGroupItems` (
  `SGRPNAME` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `ITEMID` int NOT NULL,
  PRIMARY KEY (`ITEMID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `shippingGroupItems`
--


--
-- Table structure for table `subcategories`
--

CREATE TABLE `subcategories` (
  `SUBCATID` int NOT NULL AUTO_INCREMENT,
  `CATID` int NOT NULL,
  `NAME` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `DESCRIPTION` varchar(200) COLLATE utf8mb3_unicode_ci NOT NULL,
  `PARENTSUBCATID` int NOT NULL DEFAULT '-1',
  `ICONURL` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT '',
  `USERLEVEL` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`SUBCATID`)
) ENGINE=InnoDB AUTO_INCREMENT=63 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `subcategories`
--

INSERT INTO `subcategories` VALUES (42,25,'Business Card','Business Card',-1,'icon_businesscard.png',0),(43,27,'Abbyson',' ',-1,'icon_abbyson.png',0),(44,27,'Chateau d\'Ax',' ',-1,'icon_chateau_d\'ax.png',0),(45,27,'Cindy Crawford Home',' ',-1,'icon_cindy_crawford_home.png',0),(46,27,'Day N\' Night',' ',-1,'icon_day_n\'night.png',0),(47,27,'DeFehr',' ',-1,'icon_de_fehr.png',0),(48,27,'Designed2B',' ',-1,'icon_designed2b.png',0),(49,28,'Sealy',' ',-1,'icon_sealy.png',0),(50,28,'Serta',' ',-1,'icon_serta.png',0),(51,28,'Beautyrest',' ',-1,'icon_beautyrest.png',0),(52,28,'Stearns & Foster',' ',-1,'icon_stearns_foster.png',0),(53,28,'Springwall',' ',-1,'icon_springwall.png',0),(54,28,'Bedgear',' ',-1,'icon_bedgear.png',0),(55,29,'Samsung',' ',-1,'icon_samsung.png',0),(56,29,'LG',' ',-1,'icon_lg.png',0),(57,29,'KitchenAid',' ',-1,'icon_kitchenaid',0),(58,29,'Whirlpool',' ',-1,'icon_whirlpool.png',0),(59,30,'Sony',' ',-1,'icon_sony.png',0),(60,30,'Samsung',' ',-1,'icon_samsung.png',0),(61,30,'LG',' ',-1,'icon_lg.png',0),(62,30,'Hisense',' ',-1,'icon_hisense.png',0);

--
-- Table structure for table `taxes`
--

CREATE TABLE `taxes` (
  `TAXCODE` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL,
  `TAXGROUPNAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `TAXNAME1` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `TAXNAME2` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `TAXNAME3` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `TAXNAME4` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `TAXNAME5` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
  `TAXRATE1` decimal(19,5) NOT NULL DEFAULT '0.00000',
  `TAXRATE2` decimal(19,5) NOT NULL DEFAULT '0.00000',
  `TAXRATE3` decimal(19,5) NOT NULL DEFAULT '0.00000',
  `TAXRATE4` decimal(19,5) NOT NULL DEFAULT '0.00000',
  `TAXRATE5` decimal(19,5) NOT NULL DEFAULT '0.00000',
  PRIMARY KEY (`TAXCODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `taxes`
--

INSERT INTO `taxes` VALUES ('AB','AB','GST','','','','',0.05000,0.00000,0.00000,0.00000,0.00000),('BC','BC','GST','PST','','','',0.05000,0.07000,0.00000,0.00000,0.00000),('MB','MB','GST','PST','','','',0.05000,0.07000,0.00000,0.00000,0.00000),('NB','NB','HST','','','','',0.15000,0.00000,0.00000,0.00000,0.00000),('NL','NL','HST','','','','',0.15000,0.00000,0.00000,0.00000,0.00000),('NOTAX','NOTAX','','','','','',0.00000,0.00000,0.00000,0.00000,0.00000),('NS','NS','HST','','','','',0.14000,0.00000,0.00000,0.00000,0.00000),('NT','NT','GST','','','','',0.05000,0.00000,0.00000,0.00000,0.00000),('NU','NU','GST','','','','',0.05000,0.00000,0.00000,0.00000,0.00000),('ON','ON','HST','','','','',0.13000,0.00000,0.00000,0.00000,0.00000),('PE','PE','HST','','','','',0.15000,0.00000,0.00000,0.00000,0.00000),('QC','QC','GST','QST','','','',0.05000,0.09975,0.00000,0.00000,0.00000),('SK','SK','GST','PST','','','',0.05000,0.06000,0.00000,0.00000,0.00000),('YT','YT','GST','','','','',0.05000,0.00000,0.00000,0.00000,0.00000);

--
-- Table structure for table `ticketAttachment`
--

CREATE TABLE `ticketAttachment` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `TICKETID` int DEFAULT NULL,
  `MESSAGEID` int DEFAULT NULL,
  `STOREFILENAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `ORIGFILENAME` varchar(200) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `ticketAttachment`
--


--
-- Table structure for table `ticketDetail`
--

CREATE TABLE `ticketDetail` (
  `MESSAGEID` int NOT NULL AUTO_INCREMENT,
  `TICKETID` int NOT NULL,
  `DATEENTERED` datetime NOT NULL,
  `ENTEREDBY` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `CLIENTMESSAGE` int NOT NULL,
  `MESSAGE` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`MESSAGEID`,`TICKETID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `ticketDetail`
--


--
-- Table structure for table `ticketHeader`
--

CREATE TABLE `ticketHeader` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `ENTEREDBY` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `DATEENTERED` datetime NOT NULL,
  `STATUS` int NOT NULL,
  `TITLE` varchar(1000) COLLATE utf8mb3_unicode_ci NOT NULL,
  `DATECLOSED` datetime DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `ticketHeader`
--


--
-- Table structure for table `user`
--

CREATE TABLE `user` (
  `USERNAME` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `BRANCH` varchar(20) COLLATE utf8mb3_unicode_ci NOT NULL,
  `PASSWORD` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `PLAINPASSWORD` varchar(50) COLLATE utf8mb3_unicode_ci NOT NULL,
  `FIRSTNAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `LASTNAME` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `EMAIL` varchar(100) COLLATE utf8mb3_unicode_ci NOT NULL,
  `LANGUAGE` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'EN',
  `USERLEVEL` int NOT NULL DEFAULT '0',
  `CREATEDDATE` datetime DEFAULT NULL,
  `MODIFIEDDATE` datetime DEFAULT NULL,
  `STATUS` int NOT NULL,
  `COMMENTS` varchar(1000) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`USERNAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Dumping data for table `user`
--

INSERT INTO `user` VALUES ('11','11','*5DEA71CBE4F7F102D16633A13D114A51E0220D0B','1002','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('12','12','*77779BA2ACBD515A39A6C4F8D670AAA50FB2FAC8','1001','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('13','13','*1054022B32CEAFA48BA111859744C8E18BA67D58','1024','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('14','14','*AB748DC44BAB6810A40B6479A5D46083779C5625','1021','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('15','15','*DADE80B013728E7D2CA0CEC47B0925E48C186B84','1051','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('17','17','*5C0D571FE92A0B730185F9034BE60BD4B69581A5','1005','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('18','18','*A7EE5E0B124B4A01D7D59DE290A292EE0A8B7CED','1013','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1B','1B','*00B8678F8D194D55A1997A66FF23B351F526CFF8','1011','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1D','1D','*5B1F476D38710C6808EB3348CB87735E90901364','1012','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1E','1E','*8D1D4E553EE759661C155648F7F9583CCE7C9942','1006','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1G','1G','*7148BF452EC6C2AC332B6952265E9768D42FAA0D','1010','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1H','1H','*21B87B4F15E692E1F191D1963E3AD6987B297E63','1008','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1J','1J','*6794224C8719E2D944C7B3DD718EA981A8BF69A8','1007','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1M','1M','*00AED123C64BEB1C57C2CFD326D09B1BD8D27A6E','1009','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1P','1P','*16403E0509E15928ABABD77433427069B63D82EC','1020','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1Q','1Q','*128072DBFDAB474C9D60AD90B944010AA2B0C697','1015','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1U','1U','*045F2100769BB213D059CA0B2C346EFB4E1EE1BD','1014','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1V','1V','*06A8425BAC1BE986BBE1EC0AE34011A75E744D51','1016','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('1X','1X','*E3342C956365CA607A40EDAA70CB268466C7D35C','241','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('22','22','*96C7B6F55CE5AD81C3F330C90A4A19A1E8F0CF56','4001','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('26','26','*043058A700793474CDE327631872B4D234C48C9B','4006','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('2C','2C','*42C89E3C03AAB0B303CCBC8BF9F42D5583A0D491','4012','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('2D','2D','*F6FD8639F41C87CAC6DEBD9D353ED34411BE89D3','4011','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('2G','2G','*501919A81127C5BF6282AAB57C8B90925EA0234B','04010','NA','NA','NA@NA.com','EN',1,NULL,NULL,1,''),('2K','2K','*C25D93090F24B314F75DA4F6182D228E54C007DB','4009','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('2L','2L','*E1E88CACFAAE1A3278EC9B868BCFF02C6290BDF5','4013','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('2M','2M','*0471C30E8C061691E37E0982B6A0D33B76EDDF81','291','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('2N','2N','*F90B538BF403C6D6F47499BE6EDC7599C0599DE0','4007','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('2Q','2Q','*C8D3C11FECFC43B31A1E3237FC0EC7C35AFEBEF0','4002','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('2S','2S','*FA00B5AB48A104CEF394BA9B5BCECFAAC1DFD842','4004','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('2T','2T','*165D29C98F7019260DBC5DC9DB4C132ECA878581','298','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('2U','2U','*FB5304CE299D69F874CF13245B8D0229F0979654','4003','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('2V','2V','*6EB88D0B4CFB6B0A1B155F63E8C3D2DAED69320F','4008','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('2W','2W','*AD1D276A53812716B45DCC4D637757746E2441C3','4005','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('31','31','*7F0E03DD7AB47DB9422A0EE1E7F0262D3F79700A','5008','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('32','32','*23D0A0ECBAE4FBA8EEFDB20F7A4F6ED3CE9EEE40','5001','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('33','33','*E4F34203143DCEF8BB9D6190B34D2F73A5CA8595','5009','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('34','34','*F92B6DABEBF388BD51547E4013B72CFC9A0CF427','5010','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('35','35','*523D393113A7D457AAEA7F83063F2CB4B262F853','5005','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('36','36','*094AB40BF838D10DF44972D5BDFF225873674369','5004','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('37','37','*843FC3E62323630381C548C908B34AD88BE4AD43','5002','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('38','38','*BBBF7D72AA6A9D63762E783E9427AC3C8CE9AACD','5003','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('39','39','*DF318D597C1F56C95B02CF20CD825B988D542618','5006','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3A','3A','*EDB73E2AF4BDAFE576C1DA9D90D912A1B567B1AC','5007','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3C','3C','*44439842407C2EB14AE0012DFD9F23872291CC26','5012','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3E','3E','*66758A0DDCC03FADE0158FD2B15C81C95586FFA0','5036','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3F','3F','*7FEA9ACBFBA3FD55D8B830C56A091CB9F3D7699C','5035','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3G','3G','*19557FCF5C49107F268EE2F02F57742755807455','5011','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3H','3H','*9A2D2615C57799AACA30B56C874A9458D97BAC91','279','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3I','3I','*A90A71CB270E8948DCAE52509536646D3AE4A5D4','281','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3J','3J','*7E734EC2F82FE761C4919E7F24410C7363152193','282','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3K','3K','*F687EDC014C0CDC3C1E9AEDF6A18E3F6457EB2FD','296','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3L','3L','*855FF82E8D17A95B2E922EDF8B588F888382F6BC','5022','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3M','3M','*86AD7A36A0380D2E72633E6F251A377812FD83E6','358','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3N','3N','*6657996B72701BAD3B13A82FA623E7D11EA4CE3C','341','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3Q','3Q','*A7940F9BEE4A2F856EA04D62F9AA7ED1EB259290','348','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3S','3S','*19557FCF5C49107F268EE2F02F57742755807455','5011','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('3T','3T','*40CCDA3E7FACEC2A777D49EDCBEB1D7F41E7324A','344','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('42','42','*19FA46C811AEC3414707B9F5BBC0732807628F08','2002','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('44','44','*ED92C35CCE22FBE5B92D113109634BBB4D9D5BDF','2073','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('47','47','*25AE76C66D9817468BD074E861A5A8A2403F36C9','2021','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('48','48','*95A6A98065D080C7D23EDC9AB3890847995ECEF9','2019','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4A','4A','*7E0DF9456664813E30DA21D9255EC3E5CB9BFDB0','2004','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4B','4B','*601B8607D0081F84B036C977E2488D9A2492D050','2015','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4C','4C','*F30D27E52936E8898E50D4F8CBA0DB8676BC28FF','2006','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4D','4D','*0BAAC73C3E8A726A89A9C282B1444736CE2569C4','2009','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4E','4E','*E1C116F1F7DC6924DBEAE390CA40B5739D496975','2005','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4F','4F','*3C01C40DA4F8804ACCAA74D2B64BB3C356B1B2E8','2010','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4H','4H','*BAA8D65221E53482D7FCEE8EB244A1AD7DF0ADA8','2020','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4I','4I','*4FF0E4AF1AEBB25E70C692369FD5A3E3B87901CF','2017','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4J','4J','*9F6F2DC1B40B6DF5D2A5F762E1CF33782CA1AB29','2012','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4K','4K','*F506669DCB4683DC9F279C5E21A7A7ECF98C5825','2003','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4L','4L','*E0D47D5AF77B4680E6DF7DC079EA262C89E5AD80','2018','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4M','4M','*A48A76A3577C497D94037C52A3A483691E5DA5B2','2008','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4N','4N','*329266DA3709F5319434F29E63ECC69696FE1A51','2011','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4P','4P','*9CCA8F2C1AF19FF3924823F9BFB06B9A7CBC0FC9','2007','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4T','4T','*A71DB4274CD4CA94D0B5AA60C6FF3C55DE892E9D','2014','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4U','4U','*E8820BB0161312465DBB69D9E2A1A73841B63B62','2013','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('4W','4W','*885B539B64BD2C65AFEEA64CDC10B0DD4269E7F2','2016','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('52','52','*6CEA8B619C23342EAA2E9B528B9F698B76F870D7','7001','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('53','53','*D801869C7A5AB114A56F861E2E64E72A7A45B87E','2022','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('54','54','*7C1FCD04AA280DB2804C2B0A4B38CD0397D5A57F','2025','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('55','55','*8087E7B44A1B3BEFAAE2E8CC8FB31E6D21281A0F','2023','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('57','57','*238C441CA1719F47B45C39DA850589E557A7B800','217','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('58','58','*1724EC5B1FA3AD2B5F1C56DA474BDE26FDB2E7ED','220','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('59','59','*6B7529E42F46239FEEAE0211F96C1751AC6EA057','280','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('5A','5A','*3CF557C14BFB1F4124A4BD3CCC58FB0933EE84D6','292','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('5B','5B','*B6E05076867D88B144B37208FAB1789AF5982AE9','297','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('5C','5C','*5FB933E92637057696B9CB212D88730EBA664407','2150','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('5D','5D','*8C4CF451D598B0D2B492E8A0273306177FF9337E','2200','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6B','6B','*E3765DC5DEFC9E5E5E66A546FA1E539064CFB9AA','367','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6D','6D','*12F8820631AE6736A95F6CF2C64D407A3E81C883','2034','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6I','6I','*1B79FFCE98BB622B42356F0A54533D79C2334826','2039','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6K','6K','*01EFDCABF56A037260B06517D4A7A0DA4467223D','2041','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6P','6P','*F20A3B226A4AEFA22D54DF08B9FABAB6B52E92EB','2045','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6S','6S','*330B3E8A82C3CA7E57E7AF66E07FF6B744D34359','256','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6T','6T','*019218E6EF6D95AFE0530A22A1B5CD75C7B3BC6A','267','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6U','6U','*7437056A62D325ABC79E94EB9A8392A694D109C5','360','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6V','6V','*4EA1FDD296271F12049C4838A93F125BE4616379','269','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6W','6W','*C421A7F02B0D3692A2BAA856F2EC24FA732E86D9','356','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6X','6X','*B5B7B262347BAEEBA14BD006D7B0DF9E30426EFD','357','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('6Y','6Y','*32515082DC64523F855EAB5795CB27A1F492B494','294','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('72','72','*05C6DD34202F9FCCF6F0271D8FA2353B8555903D','3001','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('7A','7A','*2ECA924762CF92671797858D54E362A0D4A7557E','3002','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('7B','7B','*6922D34059D25EC039601C4345EBA18BF062B9BD','6017','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('7D','7D','*65C82756B8A50FD4D191C259A833F73CB478E290','3004','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('7E','7E','*88CC5F50CDD8DA4E3786404D2E381BCF5535D85D','3005','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('7F','7F','*5881FA1E1C4816EA98D6EEE98190CE0DDBA44CE0','284','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9A','9A','*671968D5D294A4753CF4A6D6637D24544BB03E56','1033','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9B','9B','*9A3D3006D8DFAD87EC6038EAC5CC1BCB3B2DD9B3','3010','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9C','9C','*944FFBC1DE67E0155BC6B3DBBBAEE4A37050DC50','1035','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9D','9D','*6E7B16F879F76750379669E9FDBF3F63AE0D0518','1034','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9E','9E','*4F4275A7FD4A256F0ACE9CDFE08C2C75ED28738E','1036','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9F','9F','*452CDCBAB50A27A549811BB31B610A5C50324854','1037','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9G','9G','*3A4B7E05EC7960E849BC480A1CC4C952A0CA95F6','1038','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9H','9H','*366AD9D5E9C6A08052D2A1ABACDAAF753D05A2D0','1039','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9K','9K','*1FA4EED152F64D53DEFA0565E8DF34ED6AB10BC8','204','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9L','9L','*4EDD6A0D941DA12183608D39E0B38E1B6B23199F','201','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9M','9M','*98EA3D81C4F6976045ED48967599E6551EF41154','208','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9N','9N','*77B3B354A22222A2D8C16C4677BC51DEBBE74A51','212','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('9Q','9Q','*08D1D903DAB2D3FD4FD9D4A628380E2BE730A018','235','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('A5','A5','*3CCBCA44AF4F84A6B33123BB60D2AB105ABD9927','254','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('AA','AA','*E9838911E4AE3DB4DE84FB9209DA887433DD944D','219','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('AE','AE','*7FD15121DEEAD8DB642AD1BE80C2C196D4E500F0','6019','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('AF','AF','*DADE80B013728E7D2CA0CEC47B0925E48C186B84','1051','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('AK','AK','*04DCE8A5FDF53A5CD9B52EA7ABC4DB4A06DB94EB','205','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('AQ','AQ','*93C4DD5D3082763943158A7CEA9D57C9A7535AE2','215','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('AR','AR','*9FF4C689B706A2398C6F54DE46FF125099EB8370','1047','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('AS','AS','*04DCE8A5FDF53A5CD9B52EA7ABC4DB4A06DB94EB','205','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('AT','AT','*D5BEBAED6FA499D6E3EAD7736309E809C15AD145','227','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('AW','AW','*258B29E1182AFB5B4869CA583B2B2A5F61E3351F','229','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('AX','AX','*06514050A69C71A34E911324DF6B1F8ED71FC196','323','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('B1','B1','*7C2AF76B124C4D2D34CF7D520DBC75EFC82281F7','4021','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('B2','B2','*F169F9EFFA5FE3D4AC2452A013CBB4DE730A224B','190','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('B3','B3','*CA6C60D52FFCCCECFC1A716109267B275DC656D6','203','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('B4','B4','*6182BA91CB189B63B3FBC242A0646C46AF89BE9D','4018','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('B6','B6','*E74A5696AC52C14876FCA0EB32F2600B44C8C8D1','4020','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('B8','B8','*E6A94F8ED18E7C8C2A9B695DE9E05F5B798AF3D0','253','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('BE','BE','*D7A47C4F3F1F3E3FAE3C0B5701B86B1A3EF1D5F5','4026','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('BI','BI','*74DD541781AC0BB9E4EB1E0B2BC46000C3F6172D','4022','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('BJ','BJ','*9E4537C7BD426E543AA8F051656287BC585FD950','1042','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('BM','BM','*531B6A217A2D17924DF426621DE15373B8D31A00','209','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('BS','BS','*CAC926C90985FC48783145FD428E3F0EBDCF43A5','221','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('BX','BX','*1A5B5C07BF8C8BB4F171A092234C6211C02897F5','4030','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('BY','BY','*641E60FA5078A1FE9FE887502E69972CA0DF8574','4028','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('C3','C3','*533E4956644139F62C789BC9C220532790B00EC6','233','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('CE','CE','*7CAAC25FBBF443C1CFBFD7714D6A939CFD4EB5BA','278','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('CF','CF','*D25F923B8B43E9E5E7F3D17C626A45E0B15E033D','258','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('CG','CG','*B792006A527B6917010BB3ED22D70B468E2BF460','270','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('CI','CI','*417C9D53B4B17B2BAF265D95189DED9BDF68F25F','313','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('CJ','CJ','*A90928B617EBDDFE1A1B4BB63CE65EACCC0F3E6C','272','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('CM','CM','*337A0C2315C57C3FD13CCB6D917A365BDE608BA6','312','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('CR','CR','*AA6E86DAA3833AE1733CB9229A2A0DDC128354E1','251','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('D2','D2','*F8629092D676582AA71D87C45741FD761C0F33E1','287','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('DA','DA','*D3335EE967BC5A49FBD02D4CEE19A0D33E507497','285','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('DB','DB','*E37A4F533DA1CED9F0E0CBABB4556C65E578CFE3','286','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('DD','DD','*FD5D03E46659D7643CE31831FFE4450E22FC1867','289','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('DE','DE','*F8F178A40F7F52911C35067D315706162EB628EB','288','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('Demo','CPDI','*8BD0E6CAD9A037FB3C25A839E49A934A7A404E01','Demo1234','Demo','Demo','peggy@creativepath.com','EN',50,NULL,NULL,1,''),('DG','DG','*A8F18C5A46B3D5E5B804A0D7472B8DABDEB9717F','290','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('DH','DH','*5F1AED28463B1859915E6E8EDCE4051A0CF67C54','301','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('DI','DI','*F0E8F98B0316F0D420677CF83C8A4CF63DE1EF5D','314','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('DJ','DJ','*8AA5159A34CA3558A25ED8C24EF382750B223DCA','304','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('DK','DK','*3E335A728AB1F3C7C73D42DF051A2D9698E72E05','305','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('DL','DL','*7684AF4FFD22124630C06F15BD2FC864416B1361','307','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('EA','EA','*4BFAB161C6F3E92B3A2F354ADB858DB2E767528E','2059','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('EF','EF','*4A6E1F66ACC4803AB097E16EA0752DEE892A1818','2065','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('EG','EG','*2A5458E92FABE8470ABC3A9DB65B0AF03C3BEC9D','2061','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('eric','CPDI','*C5EC559C0EA7C49430B0006B94ACD3B9DD1D4F9D','E6359S','Eric','SIn','eric@creativepath.com','EN',81,'2020-03-26 16:06:46','2021-04-21 15:41:01',1,'CPDI'),('EW','EW','*F3597F32AC9118EDC93B29EBD092B1A463A42B88','2064','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('FA','FA','*5B488B9ACEC7DBA63D46A7CEBFED876EFF627186','2049','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('FB','FB','*E0895ED62CC15FF1042517496AC554F40AD17693','2050','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('FE','FE','*385135788B9E2DB9CA315E9D57D40B017FBEF7F7','2068','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('FH','FH','*C9C8C4D676D8E83C7404C703F6B3C58671587097','237','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('FK','FK','*0274DC48FC2E07D2167D5C5992DB39900AB2AAA1','274','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('GA','GA','*2953139362530220377F3341EB4E78831AE2F389','5020','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('GB','GB','*2670309F802338555C21BF62665F7FA286027A56','5021','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('GF','GF','*4727D46911B1DCC5DF1B050ED9DF4080932F2E16','5025','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('GG','GG','*B7C411DAE38F2628DD32F469ABE37AC9290B5199','264','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('GH','GH','*A09512DA7695341165537F7954D2502C3B7EE064','2053','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('GJ','GJ','*D41F0944AB1E977D6AC19140D2ACE0296B26E769','265','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('GK','GK','*C6DCBC36600A4D7BFDE2A28C322B4D9966AF55D8','276','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('H1','H1','*6A4E4C86F5ABEE7C22B92F39060F211D1F78BD28','2026','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('H2','H2','*43AE2D35BF87AEB7F174F8EF84DE78C3CE335DC9','2027','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('H3','H3','*DBE82F8EAF4D3FF645268ED27FF55D2AFD90E4FE','2028','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('JA','JA','*668380F9836CDCB182E74B06AFBA6588EA8386C4','326','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('JC','JC','*3FF97D1668A6A90C1C6275A173D5F2885BD2768B','232','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('JD','JD','*9DEFD298C3E0F030F959234740F59256D89B2070','196','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('JF','JF','*897CBF5ED5F9943DCC642A7571C5B42407E73F3C','193','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('JG','JG','*1AC838E1E24BCBCE6CBDC5F0B46C14DB174F1B6F','192','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('JH','JH','*E5218FB40C1F28086258774875AC3938E28E05E1','218','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('JI','JI','*1C889F571A8609E426B3CE2F406586FE45A1437C','300','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('JJ','JJ','*C7A912A354CA7DC67BD49E3263D10666D3029BB2','2076','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('JL','JL','*3AD5B03FFA399487AFEF8AF40FA9A59153B832AD','338','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('JP','JP','*82733D651586910A4D94B935024F1C529697A567','236','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('KA','KA','*74D04AE6E56A11C35C44143B6E1542C9E102E31B','194','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('KB','KB','*E94AA0FA1022559177E478B7468BE2803724DAD2','310','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('KC','KC','*E9338EFF1FFF16E7C0F3DD5A3F7D8E83604B8BF4','311','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('KG','KG','*6204998CF9A6FB7473F0B6B84DE8E50671C2B0B1','315','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('KK','KK','*A0AC22DB9B1FA87743760F3077DDEAF1910D3D44','371','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('KM','KM','*E9E92292BEE8ECC1BB596B5F7FC968E141E76DF4','271','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('KN','KN','*265F5F0F61E93ECCB4A0C6E1B0982257883BB155','2052','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('KP','KP','*565B1B47FD7BC0488435D2B707071F5EF873197B','234','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('KS','KS','*327BC9C7A51026D91C63F06FB4385BE981FFCCBF','299','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('M2','M2','*49A54A67D401D87C604C7C65E38ADEA1AE0309C4','369','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('M3','M3','*FDA5B7854F7D58168E5A7D50521C994E787CE181','370','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('M4','M4','*7ABD2274D1013C2EE7913D349E0B299A0743803B','372','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('M5','M5','*A38A7FFF95E8B96B1C3FE22BB69F0912BE86701F','2029','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('markham','Markham','*A4B6157319038724E3560894F7F932C8886EBFCF','1234','Demo','Demo','peggy@creativepath.com','EN',1,'2021-04-26 10:28:57','2021-04-26 10:29:00',1,''),('MJ','MJ','*2E1006C3F132F51CB568BF3369EBD309C403F915','1046','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('NA','NA','*778E5F8468A30DB9BB318099CCFC64D99FEB2712','340','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('NB','NB','*DDAE666E16AE6A40D995C5EF42F7F8EA27EEAB50','368','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('northyork','NorthYork','*A4B6157319038724E3560894F7F932C8886EBFCF','1234','Demo','Demo','peggy@creativepath.com','EN',1,'2021-04-26 10:28:45','2021-04-26 10:28:49',1,''),('patrick','CPDI','*04AE7ABE88B8C7F153AD654C1410AFFC6072339B','cpdi905711','Patrick','Sinn','patrick@creativepath.com','EN',99,'2017-01-21 20:14:11','2021-04-21 15:40:38',1,'CPDI'),('peggy','CPDI','*A45967DAC55BE870539FA0BA1B8AF799AD65EBB8','momo73449','Peggy','Cheng','peggy@creativepath.com','EN',99,'2017-01-21 20:14:11','2024-05-27 13:47:11',1,'CPDI'),('PR','PR','*3E9FEA9A673179BFC73F9E1357E81FE84FDE72B6','4050','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:22','2021-05-27 18:16:22',1,''),('richmondhill','RichmondHill','*A4B6157319038724E3560894F7F932C8886EBFCF','1234','Demo','Demo','peggy@creativepath.com','EN',1,'2021-04-26 10:29:27','2021-04-26 10:29:32',1,''),('Sam','CPDI','*48910925EF9C280FA11348D3968E9F9B2E98E539','sam8500','Sam','Stratigeas','sam@samstratigeas.ca','EN',99,'2022-04-18 14:42:22','2022-04-18 14:44:46',1,'CPDI'),('SE','SE','*1978A88B837EC43DAE29D0129AEA79D5A555C68C','283','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('SH','SH','*134477A85EA31F75B64BD342220E59F0F5435314','252','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('SS','SS','*2694FC491200958B2E88CD1BC0D31BF6F15C09A4','6023','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('SY','SY','*BFAD253A4C2ACF9B62246087D5765BA545EE25D4','1048','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('UR','UR','*70040571A0205204568EF54BD0FCB542F988EE05','6015','NA','NA','NA@NA.com','EN',1,'2021-05-27 18:16:23','2021-05-27 18:16:23',1,''),('zoeyc','CPDI','*C7C2E49F12068D26F3FB0709B11EBB4516B3BE98','zc5689','Zoey','Cui','zoeyc@cpfulfillment.com','EN',99,'2023-06-26 13:26:36','2023-06-26 13:26:54',1,'');

--
-- Dumping routines for database 'cpfulfillment_PrintOS_Brick'
--
/*!50003 DROP PROCEDURE IF EXISTS `AddDownloadLogEntry` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `AddDownloadLogEntry`(__USERNAME VARCHAR(50), __ITEMID INT)
BEGIN
	INSERT INTO 
		downloadLog
        (USERNAME,BRANCHCODE,ITEMID,LOGTIME)
	SELECT
		USERNAME,
        BRANCH,
        __ITEMID,
        CURRENT_TIMESTAMP
	FROM
		user
	WHERE
		USERNAME = __USERNAME;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `AddItemToCart` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `AddItemToCart`(__USERNAME VARCHAR(50), __ITEMID INT, __PROOF VARCHAR(200), __QTY INT, __ITEMOPTION VARCHAR(30), __ADDCOST DECIMAL)
BEGIN



SELECT @ORDERNUM := COUNT(*) FROM orderHeader WHERE USERNAME = __USERNAME AND ORDERSTATUS = 'CART';


SELECT @LOTPRICE := COUNT(*) FROM itemPricing WHERE ITEMID = __ITEMID AND QTY = __QTY AND ITEMOPTION = __ITEMOPTION;
SELECT @VARPRICE := COUNT(*) FROM itemPricing WHERE ITEMID = __ITEMID AND QTY = -1 AND ITEMOPTION = __ITEMOPTION;


IF @ORDERNUM = 0 THEN
 INSERT INTO
 orderHeader
 (USERNAME,ORDERDATE,ORDERMODIFIED,PONUMBER,SHIPCONTACTFIRSTNAME,SHIPCONTACTLASTNAME,SHIPCONTACTPHONE,SHIPCONTACTFAX,SHIPCONTACTEMAIL,
 SHIPNAME,SHIPADDRESS,SHIPADDRESS2,SHIPCITY,SHIPPROVINCE,SHIPCOUNTRY,SHIPPOSTAL,SHIPTAXGROUP,ORDERSTATUS,SHIPSTOREID,
 REQCONTACTFIRSTNAME,REQCONTACTLASTNAME,REQCONTACTPHONE,REQCONTACTFAX,
 REQNAME,REQADDRESS,REQADDRESS2,REQCITY,REQPROVINCE,REQCOUNTRY,REQPOSTAL)
 SELECT
 __USERNAME AS USERNAME ,
 CURRENT_TIMESTAMP AS ORDERDATE,
 CURRENT_TIMESTAMP AS ORDERMODIFIED,
 '' AS PONUMBER,
 USER.FIRSTNAME AS SHIPCONTACTFIRSTNAME,
 USER.LASTNAME AS SHIPCONTACTLASTNAME,
 BADDR.PHONE AS SHIPCONTACTPHONE,
 BADDR.FAX AS SHIPCONTACTFAX,
 USER.EMAIL AS SHIPCONTACTEMAIL,
 BINFO.NAME AS SHIPNAME,
 BADDR.ADDRESS AS SHIPADDRESS,
 BADDR.ADDRESS2 AS SHIPADDRESS2,
 BADDR.CITY AS SHIPCITY,
 BADDR.PROVINCE AS SHIPPROVINCE,
 BADDR.COUNTRY AS SHIPCOUNTRY,
 BADDR.POSTALCODE AS SHIPPOSTAL,
 BINFO.TAXGROUP AS SHIPTAXGROUP,
        'CART' AS ORDERSTATUS,
        BINFO.CODE AS SHIPSTOREID,
		USER.FIRSTNAME AS REQCONTACTFIRSTNAME,
        USER.LASTNAME AS REQCONTACTLASTNAME,
        BADDR.PHONE AS REQCONTACTPHONE,
        BADDR.FAX AS REQCONTACTFAX,
		BINFO.NAME AS REQNAME,
        BADDR.ADDRESS AS REQADDRESS,
        BADDR.ADDRESS2 AS REQADDRESS2,
        BADDR.CITY AS REQCITY,
        BADDR.PROVINCE AS REQPROVINCE,
        BADDR.COUNTRY AS REQCOUNTRY,
        BADDR.POSTALCODE AS REQPOSTAL        
	FROM
		user USER
	INNER JOIN
		branches BINFO ON 
			USER.BRANCH = BINFO.CODE
	INNER JOIN
		branchesAddresses BADDR ON 
			USER.BRANCH = BADDR.CODE 
	WHERE
		USER.USERNAME  = __USERNAME AND
        BADDR.ISMAIN = 1
    ;
END IF;


SELECT @ORDERID := ORDERID FROM orderHeader WHERE USERNAME = __USERNAME AND ORDERSTATUS = 'CART';


IF @LOTPRICE > 0 THEN

	INSERT INTO
		orderDetail
			(ORDERID,ITEMID,ITEMCODE,ITEMDESC,ORDERQTY,SHIPTODATEQTY,UNITPRICE,EXTPRICE,
             TAXAMT1,TAXAMT2,TAXAMT3,TAXAMT4,TAXAMT5,ITEMLENGTH,ITEMWIDTH,ITEMHEIGHT,ITEMWEIGHT,ITEMPIECES,PROOFCONFIRMATION,ITEMOPTION)
	SELECT
		@ORDERID AS ORDERID,
        ITEM.ID AS ITEMID,
        ITEM.CODE AS ITEMCODE,
        ITEM.DESCRIPTION AS ITEMDESC,
        ITEMPRICE.QTY AS ORDERQTY,
        0 AS SHIPTODATEQTY,
        (ITEMPRICE.PRICE / ITEMPRICE.QTY) + (__ADDCOST / ITEMPRICE.QTY) AS UNITPRICE,
        ITEMPRICE.PRICE + __ADDCOST AS EXTPRICE,
		0 AS TAXAMT1,
        0 AS TAXAMT2,
        0 AS TAXAMT3,
        0 AS TAXAMT4,
        0 AS TAXAMT5,
        ITEMPRICE.LENGTH AS ITEMLENGTH,
        ITEMPRICE.WIDTH AS ITEMWIDTH,
        ITEMPRICE.HEIGHT AS ITEMHEIGHT,
        ITEMPRICE.WEIGHT AS ITEMWEIGHT,
        ITEMPRICE.PIECES AS ITEMPIECES,
        __PROOF AS PROOFCONFIRMATION,
        ITEMPRICE.ITEMOPTION AS ITEMOPTION
	FROM
		items ITEM
	INNER JOIN
		itemPricing ITEMPRICE ON 
			ITEM.ID = ITEMPRICE.ITEMID
	WHERE
		ITEM.ID = __ITEMID AND
        ITEMPRICE.QTY = __QTY AND
        ITEMPRICE.ITEMOPTION = __ITEMOPTION;
        
ELSEIF @VARPRICE > 0 AND @LOTPRICE = 0 THEN

INSERT INTO
		orderDetail
			(ORDERID,ITEMID,ITEMCODE,ITEMDESC,ORDERQTY,SHIPTODATEQTY,UNITPRICE,EXTPRICE,
             TAXAMT1,TAXAMT2,TAXAMT3,TAXAMT4,TAXAMT5,ITEMLENGTH,ITEMWIDTH,ITEMHEIGHT,ITEMWEIGHT,ITEMPIECES,PROOFCONFIRMATION,ITEMOPTION)
	SELECT
		@ORDERID AS ORDERID,
        ITEM.ID AS ITEMID,
        ITEM.CODE AS ITEMCODE,
        ITEM.DESCRIPTION AS ITEMDESC,
        __QTY AS ORDERQTY,
        0 AS SHIPTODATEQTY,
        ITEMPRICE.PRICE + __ADDCOST AS UNITPRICE,
        (ITEMPRICE.PRICE + __ADDCOST) * __QTY AS EXTPRICE,
		0 AS TAXAMT1,
        0 AS TAXAMT2,
        0 AS TAXAMT3,
        0 AS TAXAMT4,
        0 AS TAXAMT5,
        ITEMPRICE.LENGTH AS ITEMLENGTH,
        ITEMPRICE.WIDTH AS ITEMWIDTH,
        ITEMPRICE.HEIGHT AS ITEMHEIGHT,
        ITEMPRICE.WEIGHT * __QTY AS ITEMWEIGHT,
        ITEMPRICE.PIECES AS ITEMPIECES,
        __PROOF AS PROOFCONFIRMATION,
        ITEMPRICE.ITEMOPTION AS ITEMOPTION
	FROM
		items ITEM
	INNER JOIN
		itemPricing ITEMPRICE ON 
			ITEM.ID = ITEMPRICE.ITEMID
	WHERE
		ITEM.ID = __ITEMID AND
        ITEMPRICE.QTY = -1 AND 
        ITEMPRICE.ITEMOPTION = __ITEMOPTION;

ELSE 
	SIGNAL SQLSTATE '45000'
		SET MESSAGE_TEXT = 'Invalid Pricing Found For Item';
END IF;  

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `AddReportingExtraData` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `AddReportingExtraData`(__USERNAME VARCHAR(20), __EXTRADATA VARCHAR(100))
BEGIN

SET SQL_SAFE_UPDATES = 0;

UPDATE
	orderHeader
SET
	EXTRADATA1 = __EXTRADATA
WHERE 
	USERNAME  = __USERNAME AND 
    ORDERSTATUS = 'CART';

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `AddShipmentCostEntry` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `AddShipmentCostEntry`(__CARRIER VARCHAR(100), __METHOD VARCHAR(100),
__SHIPFROM_NAME VARCHAR(100), __SHIPFROM_STREETNUM VARCHAR(100), __SHIPFROM_STREET VARCHAR(100),
__SHIPFROM_CITY VARCHAR(100), __SHIPFROM_PROVINCE VARCHAR(100), __SHIPFROM_COUNTRY VARCHAR(100),
__SHIPFROM_POSTAL VARCHAR(100), __TOTALWEIGHT DECIMAL(19,4), __TOTALBOXES DECIMAL(19,4),
__SHIPTO_PROVINCE VARCHAR(100), __SHIPTO_POSTAL VARCHAR(100), __SHIPTO_CITY VARCHAR(100),
__TOTALPRICE DECIMAL(19,4), __OURMARUP DECIMAL(19,4), __OURSLEEVECHARGE DECIMAL(19,4),
__ORDERID INT)
BEGIN
INSERT INTO `shipmentCostLog`
(
`CARRIER`,
`METHOD`,
`SHIPFROM_NAME`,
`SHIPFROM_STREETNUM`,
`SHIPFROM_STREET`,
`SHIPFROM_CITY`,
`SHIPFROM_PROVINCE`,
`SHIPFROM_COUNTRY`,
`SHIPFROM_POSTAL`,
`TOTALWEIGHT`,
`TOTALBOXES`,
`SHIPTO_PROVINCE`,
`SHIPTO_POSTAL`,
`SHIPTO_CITY`,
`TOTALPRICE`,
`OURMARKUP`,
`OURSLEEVECHARGE`,
`ORDERID`,
`CREATEDATETIME`)
VALUES
(
__CARRIER,
__METHOD,
__SHIPFROM_NAME,
__SHIPFROM_STREETNUM,
__SHIPFROM_STREET,
__SHIPFROM_CITY,
__SHIPFROM_PROVINCE,
__SHIPFROM_COUNTRY,
__SHIPFROM_POSTAL,
__TOTALWEIGHT,
__TOTALBOXES,
__SHIPTO_PROVINCE,
__SHIPTO_POSTAL,
__SHIPTO_CITY,
__TOTALPRICE,
__OURMARUP,
__OURSLEEVECHARGE,
__ORDERID,
CURRENT_TIMESTAMP);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `AdjustItemQty` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `AdjustItemQty`(__ITEMID INT, __QTY INT, __REASON VARCHAR(200))
BEGIN
	UPDATE 
		itemsInventory
	SET
		QTYONHAND = QTYONHAND + __QTY
	WHERE
		ITEMID = __ITEMID;
            
	INSERT INTO 
		itemsAdjustmentLog
       (ITEMID,QTY,ADJDATE,REASON)
	VALUES 
		(__ITEMID,__QTY,CURRENT_TIMESTAMP,__REASON);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `ApplyPromoCode` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `ApplyPromoCode`(__USERNAME VARCHAR(50), __PROMO VARCHAR(50))
BEGIN
 SET @RESULT = '';
 
 SET @ORDERID = (SELECT ORDERID FROM orderHeader WHERE ORDERSTATUS = 'CART' AND USERNAME = __USERNAME);
 SET @PROMOTYPE= (SELECT CODETYPE FROM promos WHERE CODE = __PROMO);
 SET @CHKCOUNT= (SELECT COUNT(*) FROM promos WHERE CODE = __PROMO);
 SET @CHKREDEEMED= (SELECT COUNT(*) FROM promos WHERE CODE = __PROMO AND REDEEMED = 0);
 SET @CHKDATES= (SELECT COUNT(*) FROM promos WHERE CODE = __PROMO AND STARTDATE <= CURRENT_TIMESTAMP AND ENDDATE >= CURRENT_TIMESTAMP);
 SET @CHKPROMOCOUNT= (SELECT COUNT(*) FROM orderPromos WHERE ORDERID = @ORDERID);
 SET @CHKITEMCOUNT= (SELECT COUNT(*) 
 FROM orderDetail D 
 INNER JOIN items I ON D.ITEMID = I.ID 
 INNER JOIN promosItems PI ON (PI.ITEMID = I.ID OR PI.ITEMID = I.PARENTITEM) 
 INNER JOIN promos PIHDR ON PI.CODE = PIHDR.CODE
 WHERE 
 ORDERID = @ORDERID AND 
 PI.CODE = __PROMO AND
 ((PIHDR.QTYTYPE = '' AND (PIHDR.MAXQTY = 0 OR ORDERQTY <= PIHDR.MAXQTY)) OR PIHDR.QTYTYPE = 'NOLIMIT' OR (PIHDR.QTYTYPE = 'EXACT' AND ORDERQTY = PIHDR.EXACTQTY) OR (PIHDR.QTYTYPE = 'RANGE' AND PIHDR.MINQTY <= ORDERQTY AND ORDERQTY <= PIHDR.MAXQTY))
 ); 
SET @CHKALLCATCOUNT= (SELECT
COUNT(*)
FROM orderDetail D 
INNER JOIN items I ON D.ITEMID = I.ID 
INNER JOIN itemsSubcategoryLink ISL ON I.ID = ISL.ITEMID
INNER JOIN subcategories SUBCATS ON ISL.SUBCATID = SUBCATS.SUBCATID
CROSS JOIN (SELECT * FROM promos WHERE CODE = __PROMO) PROMO 
WHERE
D.ORDERID = @ORDERID AND 
SUBCATS.CATID NOT IN (SELECT CATID FROM promos PIHDR INNER JOIN promosCategories PC ON PC.CODE = PIHDR.CODE WHERE PC.CODE = __PROMO) AND
((PROMO.QTYTYPE = '' AND (PROMO.MAXQTY = 0 OR ORDERQTY <= PROMO.MAXQTY)) OR PROMO.QTYTYPE = 'NOLIMIT' OR (PROMO.QTYTYPE = 'EXACT' AND ORDERQTY = PROMO.EXACTQTY) OR (PROMO.QTYTYPE = 'RANGE' AND PROMO.MINQTY <= ORDERQTY AND ORDERQTY <= PROMO.MAXQTY))
);
SET @CHKNOTITEMCOUNT= (SELECT COUNT(*)
 FROM orderDetail D 
 INNER JOIN items I ON D.ITEMID = I.ID 
 INNER JOIN promos PIHDR ON PIHDR.CODE = __PROMO
 LEFT OUTER JOIN promosItems PI ON (PI.ITEMID = I.ID OR PI.ITEMID = I.PARENTITEM) 
 WHERE 
 ORDERID = @ORDERID AND 
 PI.ITEMID IS NULL AND 
 ((PIHDR.QTYTYPE = '' AND (PIHDR.MAXQTY = 0 OR ORDERQTY <= PIHDR.MAXQTY)) OR PIHDR.QTYTYPE = 'NOLIMIT' OR (PIHDR.QTYTYPE = 'EXACT' AND ORDERQTY = PIHDR.EXACTQTY) OR (PIHDR.QTYTYPE = 'RANGE' AND PIHDR.MINQTY <= ORDERQTY AND ORDERQTY <= PIHDR.MAXQTY))
 ); 

  IF @CHKCOUNT=0 THEN
    SET @RESULT = 'NOEXIST';
  ELSEIF @CHKDATES = 0 THEN 
    SET @RESULT = 'NOTACTIVEDATE';
  ELSEIF @CHKREDEEMED = 0 THEN 
    SET @RESULT = 'ALREADYREDEEMED';        
  ELSEIF @CHKPROMOCOUNT > 0 THEN 
    SET @RESULT = 'ALREADYPROMO';   
  ELSEIF @CHKITEMCOUNT = 0 AND (@PROMOTYPE = 'ITM$DISC' OR @PROMOTYPE = 'ITM%DISC') THEN
    SET @RESULT = 'NOVALIDITEMS';
  ELSEIF @CHKALLCATCOUNT = 0 AND (@PROMOTYPE = 'ALLCAT$DISC' OR @PROMOTYPE = 'ALLCAT%DISC') THEN
    SET @RESULT = 'NOVALIDITEMS'; 
  ELSEIF @CHKNOTITEMCOUNT = 0 AND (@PROMOTYPE = 'ALLITM$DISC' OR @PROMOTYPE = 'ALLITM%DISC') THEN
    SET @RESULT = 'NOVALIDITEMS';
  ELSE
    SET @RESULT = 'OK';
        INSERT INTO orderPromos
        (ORDERID,PROMOCODE,PROMONAME,SINGLEITEM,PROMOTYPE,PROMOVALUE,CALCDISCOUNT,
         TAXAMT1,TAXAMT2,TAXAMT3,TAXAMT4,TAXAMT5)
    SELECT
      @ORDERID,CODE,NAME,SINGLEITEM,CODETYPE,PROMOVALUE,0.00,0.00,0.00,0.00,0.00,0.00
    FROM
      promos
    WHERE 
      CODE = __PROMO;
        
        UPDATE promos SET REDEEMED = 1 WHERE CODE = __PROMO AND SINGLEUSE = 1;
        
  END IF;

  SELECT @RESULT AS RESULT;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `ApproveItem` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ApproveItem`(__CODE VARCHAR(200))
BEGIN

	SELECT
		ITEM.ID AS ITEMID,
        USERS.EMAIL AS USEREMAIL,
        ITEM.DISPLAYIMAGEPATH
	FROM
		items ITEM 
	INNER JOIN
		user USERS ON 
			USERS.USERNAME = ITEM.GENERATEDBY
	WHERE 
		APPROVALLINK = __CODE;

	UPDATE
		items
	SET
		ASSETAPPROVED = 1,
        APPROVALLINK = NULL
	WHERE
		APPROVALLINK = __CODE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `ApproveOrder` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `ApproveOrder`(__APPROVALLINK NVARCHAR(100))
BEGIN

SET @ORDERREF = IFNULL((SELECT MAX(ORDERREF)+1 FROM orderHeader),10000);
UPDATE orderDetail
    SET 
        SHIPTODATEQTY = ORDERQTY,
        DOWNLOADLINK = CONCAT(ORDERID,'-',ITEMLINE,'-',MD5(MD5(MD5(NOW())+ORDERID)+ITEMLINE))
  WHERE
    ORDERQTY = -2 AND
        ORDERID IN (SELECT ORDERID FROM orderHeader WHERE APPROVALLINK  COLLATE utf8_unicode_ci = __APPROVALLINK AND APPROVALLINK IS NOT NULL);    

UPDATE
  orderHeader
SET
  ORDERREF = @ORDERREF
WHERE
  APPROVALLINK  COLLATE utf8_unicode_ci = __APPROVALLINK AND
    APPROVALLINK IS NOT NULL;


SELECT
  HDR.*,
    DTL.*,
    ITEM.TYPE,
    USER.FIRSTNAME AS USER_FIRSTNAME,
    USER.LASTNAME AS USER_LASTNAME,
    USER.EMAIL AS USER_EMAIL,
    USER.LANGUAGE AS USER_LANGUAGE,
    BRANCH.NAME AS BRANCH_NAME,
    BRANCH.MANAGEMENTEMAIL AS BRANCH_MANAGEMENTEMAIL,
    COALESCE(BRANCHADDRESS.LANGUAGE,'EN') AS BRANCH_LANGUAGE,
    'ACTIVE' AS REALSTATUS,
    COALESCE(ITEM.DLSUGGESTIONS,'') AS DLSUGGESTIONS
FROM
  orderHeader HDR
INNER JOIN
  orderDetail DTL ON 
    HDR.ORDERID = DTL.ORDERID
INNER JOIN
  items ITEM ON 
    DTL.ITEMID = ITEM.ID        
INNER JOIN
  user USER ON 
    HDR.USERNAME = USER.USERNAME
INNER JOIN
  branches BRANCH ON 
    USER.BRANCH = BRANCH.CODE
LEFT OUTER JOIN
  (SELECT * FROM branchesAddresses WHERE ISMAIN = 1) BRANCHADDRESS ON 
    BRANCH.CODE = BRANCHADDRESS.CODE
WHERE
  HDR.APPROVALLINK  COLLATE utf8_unicode_ci = __APPROVALLINK AND
    HDR.APPROVALLINK IS NOT NULL;
      
SELECT @SHIPLINECOUNT := COUNT(*) FROM orderDetail 
    WHERE ORDERQTY <> -2 AND
        ORDERID IN (SELECT ORDERID FROM orderHeader WHERE APPROVALLINK  COLLATE utf8_unicode_ci = __APPROVALLINK AND APPROVALLINK IS NOT NULL);
      
      
UPDATE
  orderHeader
SET
  APPROVALLINK = NULL,
    ORDERSTATUS = CASE WHEN @SHIPLINECOUNT = 0 THEN 'SHIPPED' ELSE 'ACTIVE' END,
    ORDERMODIFIED = CURRENT_TIMESTAMP,
    APPROVALDATE = CURRENT_TIMESTAMP
WHERE
  APPROVALLINK  COLLATE utf8_unicode_ci = __APPROVALLINK AND
    APPROVALLINK IS NOT NULL; 

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `ArchiveItem` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ArchiveItem`(__ITEMID INT, __USERNAME VARCHAR(50))
BEGIN

	UPDATE
		items
	SET
		ARCHIVED = 1
	WHERE
		ID = __ITEMID AND
        ID IN (SELECT ITEMID FROM itemsBranchesLink LINK INNER JOIN user USR ON LINK.BRANCHCODE = USR.BRANCH WHERE USR.USERNAME = __USERNAME);

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CancelRemaindingOrder` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CancelRemaindingOrder`(__ORDERID INT)
BEGIN

UPDATE
	orderHeader
SET
	ORDERSTATUS = 'CANCELLED',
    SPECIALINSTRUCTIONS = 'Order Cancelled on ' + CURRENT_TIMESTAMP
    
WHERE
	ORDERID = __ORDERID;

UPDATE
	orderDetail
SET
	ORDERQTY = SHIPTODATEQTY
WHERE
	ORDERID = __ORDERID;
    
SELECT * FROM orderHeader WHERE ORDERID = __ORDERID;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `ChangeAccountTicketStatus` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ChangeAccountTicketStatus`(__TICKETID INT, __STATUS INT)
BEGIN

	UPDATE
		accountMgrHeader
	SET
		STATUS = __STATUS,
        DATECLOSED = CURRENT_TIMESTAMP
	WHERE
		ID = __TICKETID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `ChangeOrderShipToAddress` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ChangeOrderShipToAddress`(__USERNAME VARCHAR(50), __ID VARCHAR(50))
BEGIN


SET SQL_SAFE_UPDATES = 0;

UPDATE
	orderHeader
SET
	SHIPNAME = ( SELECT NAME FROM ( SELECT 'S' AS RC, ID,NAME FROM shipToAddresses UNION ALL SELECT 'B' AS RC,B.CODE,NAME FROM branches B INNER JOIN branchesAddresses BB ON B.CODE = BB.CODE WHERE ISMAIN = 1) ADDR WHERE CONCAT(ADDR.RC,'-',ADDR.ID) = __ID ),
    SHIPADDRESS = ( SELECT ADDRESS FROM ( SELECT 'S' AS RC, ID,ADDRESS FROM shipToAddresses UNION ALL SELECT 'B' AS RC,CODE,ADDRESS FROM branchesAddresses WHERE ISMAIN = 1) ADDR WHERE CONCAT(ADDR.RC,'-',ADDR.ID) = __ID ),
    SHIPADDRESS2 = ( SELECT ADDRESS2 FROM ( SELECT 'S' AS RC, ID,ADDRESS2 FROM shipToAddresses UNION ALL SELECT 'B' AS RC,CODE,ADDRESS2 FROM branchesAddresses WHERE ISMAIN = 1) ADDR WHERE CONCAT(ADDR.RC,'-',ADDR.ID) = __ID ),
    SHIPCITY = ( SELECT CITY FROM ( SELECT 'S' AS RC, ID,CITY FROM shipToAddresses UNION ALL SELECT 'B' AS RC,CODE,CITY FROM branchesAddresses WHERE ISMAIN = 1) ADDR WHERE CONCAT(ADDR.RC,'-',ADDR.ID) = __ID ),
	SHIPPROVINCE = ( SELECT PROVINCE FROM ( SELECT 'S' AS RC, ID,PROVINCE FROM shipToAddresses UNION ALL SELECT 'B' AS RC,CODE,PROVINCE FROM branchesAddresses WHERE ISMAIN = 1) ADDR WHERE CONCAT(ADDR.RC,'-',ADDR.ID) = __ID ),
    SHIPCOUNTRY = ( SELECT COUNTRY FROM ( SELECT 'S' AS RC, ID,COUNTRY FROM shipToAddresses UNION ALL SELECT 'B' AS RC,CODE,COUNTRY FROM branchesAddresses WHERE ISMAIN = 1) ADDR WHERE CONCAT(ADDR.RC,'-',ADDR.ID) = __ID ),
    SHIPPOSTAL = ( SELECT POSTAL FROM ( SELECT 'S' AS RC, ID,POSTAL FROM shipToAddresses UNION ALL SELECT 'B' AS RC,CODE,POSTALCODE FROM branchesAddresses WHERE ISMAIN = 1) ADDR WHERE CONCAT(ADDR.RC,'-',ADDR.ID) = __ID ),
	SHIPCONTACTPHONE = ( SELECT PHONE FROM ( SELECT 'S' AS RC, ID,PHONE FROM shipToAddresses UNION ALL SELECT 'B' AS RC,CODE,PHONE FROM branchesAddresses WHERE ISMAIN = 1) ADDR WHERE CONCAT(ADDR.RC,'-',ADDR.ID) = __ID ),
    SHIPCONTACTFAX = ( SELECT FAX FROM ( SELECT 'S' AS RC, ID,FAX FROM shipToAddresses UNION ALL SELECT 'B' AS RC,CODE,FAX FROM branchesAddresses WHERE ISMAIN = 1) ADDR WHERE CONCAT(ADDR.RC,'-',ADDR.ID) = __ID ),
    SHIPTAXGROUP = ( SELECT TAXGROUP FROM ( SELECT 'S' AS RC, ID,TAXGROUP FROM shipToAddresses UNION ALL SELECT 'B' AS RC,B.CODE,TAXGROUP FROM branches B INNER JOIN branchesAddresses BB ON B.CODE = BB.CODE WHERE ISMAIN = 1) ADDR WHERE CONCAT(ADDR.RC,'-',ADDR.ID) = __ID ),
    SHIPSTOREID = ( SELECT STOREID FROM ( SELECT 'S' AS RC, ID,STOREID FROM shipToAddresses UNION ALL SELECT 'B' AS RC,B.CODE,B.CODE AS STOREID FROM branches B INNER JOIN branchesAddresses BB ON B.CODE = BB.CODE WHERE ISMAIN = 1) ADDR WHERE CONCAT(ADDR.RC,'-',ADDR.ID) = __ID )
WHERE 
	USERNAME  = __USERNAME AND 
    ORDERSTATUS = 'CART';


END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `ChangeTicketStatus` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ChangeTicketStatus`(__TICKETID INT, __STATUS INT)
BEGIN

	UPDATE
		ticketHeader
	SET
		STATUS = __STATUS,
        DATECLOSED = CURRENT_TIMESTAMP
	WHERE
		ID = __TICKETID;

	
    SELECT 
		HDR.*,
        USR.EMAIL,
        USR.LANGUAGE
	FROM 
		ticketHeader HDR 
	LEFT OUTER JOIN
		user USR ON 
			HDR.ENTEREDBY = USR.USERNAME
	WHERE 
    ID = __TICKETID; 

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckCartItemDuplicates` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CheckCartItemDuplicates`(__USERNAME VARCHAR(50), __ITEMID INT)
BEGIN

SET @RECCNT := (SELECT 
					COUNT(*) 
				FROM 
					orderHeader HDR 
				INNER JOIN 
					orderDetail DTL ON 
						HDR.ORDERID = DTL.ORDERID 
				WHERE 
					HDR.USERNAME = __USERNAME AND
                    HDR.ORDERSTATUS = 'CART' AND
                    DTL.ITEMID = __ITEMID
				);

IF @RECCNT > 0 THEN
	SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Cannot add the same item to the cart.';
END IF;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckCartItemLowInventory` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CheckCartItemLowInventory`(__USERNAME VARCHAR(50), __ITEMID INT, __QTY INT)
BEGIN

	SELECT
		ITM.ID,
        IFNULL(ITMINV.QTYONHAND,0) AS INVQTY,
        IFNULL(ONORDER.ONORDER,0) AS ALLOCATEDQTY,
        CASE 
			WHEN 
				ITM.TYPE <> 0 THEN 1
			ELSE
				CASE WHEN __QTY <= IFNULL(ITMINV.QTYONHAND,0) - IFNULL(ONORDER.ONORDER,0) THEN 1 ELSE 0 END
		END AS ENOUGHQTY
	FROM
		items ITM
	LEFT OUTER JOIN
		itemsInventory ITMINV ON 
			ITM.ID = ITMINV.ITEMID
	LEFT OUTER JOIN
		( SELECT ITEMID,SUM(ORDERQTY-SHIPTODATEQTY) AS ONORDER FROM orderDetail
		  WHERE ORDERID IN (SELECT ORDERID FROM orderHeader WHERE ORDERSTATUS IN ('ACTIVE'))
          GROUP BY ITEMID) ONORDER ON
			ITM.ID = ONORDER.ITEMID
	WHERE
		ITM.ID = __ITEMID;


END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckForLowLevelItems` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CheckForLowLevelItems`(__ORDERID INT)
BEGIN
	SELECT
		THISORDER.ORDERID,
        THISORDER.ORDERREF,
		ITEM.ID,
		ITEM.CODE,
        ITEM.DESCRIPTION,
        THISORDER.REMQTY AS ORDERQTY,
        COALESCE(OTHORDER.REMQTY,0) AS OTHQTY,
        ITEM.TYPE,
        COALESCE(ITEM.MINLEVEL,0) AS MINLEVEL,
        COALESCE(INV.QTYONHAND,0) AS QTYONHAND
	FROM
		( SELECT H.ORDERID, H.ORDERREF, ITEMID,SUM(ORDERQTY-SHIPTODATEQTY) AS REMQTY FROM orderHeader H INNER JOIN orderDetail D ON H.ORDERID = D.ORDERID WHERE  H.ORDERID = __ORDERID GROUP BY H.ORDERID, H.ORDERREF, D.ITEMID) THISORDER  
	INNER JOIN
		items ITEM ON 
			THISORDER.ITEMID = ITEM.ID
	LEFT OUTER JOIN
		itemsInventory INV ON 
			THISORDER.ITEMID = INV.ITEMID
	LEFT OUTER JOIN
		( SELECT ITEMID,SUM(ORDERQTY-SHIPTODATEQTY) AS REMQTY FROM orderHeader H INNER JOIN orderDetail D ON H.ORDERID = D.ORDERID WHERE ORDERSTATUS = 'ACTIVE' AND H.ORDERID <> __ORDERID GROUP BY D.ITEMID) OTHORDER ON 
			OTHORDER.ITEMID = THISORDER.ITEMID
	WHERE
		COALESCE(INV.QTYONHAND,0) - COALESCE(ITEM.MINLEVEL,0) - COALESCE(OTHORDER.REMQTY,0) - THISORDER.REMQTY <= 0
	ORDER BY
		ITEM.TYPE,
		ITEM.CODE;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckIfItemAppliesPromo` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CheckIfItemAppliesPromo`(__ORDERID INT, __PROMO VARCHAR(50), __ITEMID INT)
BEGIN

SELECT 
 PI.* 
FROM 
 orderDetail D 
INNER JOIN 
 items I ON D.ITEMID = I.ID 
INNER JOIN 
 promosItems PI ON (PI.ITEMID = I.ID OR PI.ITEMID = I.PARENTITEM)
INNER JOIN 
	promos PIHDR ON PI.CODE = PIHDR.CODE AND (PIHDR.MAXQTY = 0 OR D.ORDERQTY <= PIHDR.MAXQTY)
WHERE 
	ORDERID = __ORDERID AND PI.CODE = __PROMO AND D.ITEMID = __ITEMID;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckIfItemAppliesPromoCat` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `CheckIfItemAppliesPromoCat`(__ORDERID INT, __PROMO VARCHAR(50), __ITEMID INT)
BEGIN

SELECT
 D.*
FROM orderDetail D 
INNER JOIN items I ON D.ITEMID = I.ID 
INNER JOIN itemsSubcategoryLink ISL ON I.ID = ISL.ITEMID
INNER JOIN subcategories SUBCATS ON ISL.SUBCATID = SUBCATS.SUBCATID
CROSS JOIN (SELECT * FROM promos WHERE CODE = __PROMO) PROMO 
WHERE
D.ORDERID = __ORDERID AND 
D.ITEMID = __ITEMID AND
SUBCATS.CATID NOT IN (SELECT CATID FROM promos PIHDR INNER JOIN promosCategories PC ON PC.CODE = PIHDR.CODE WHERE PC.CODE = __PROMO) AND
(PROMO.MAXQTY = 0 OR ORDERQTY <= PROMO.MAXQTY);


END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckIfItemAppliesPromoExceptionList` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `CheckIfItemAppliesPromoExceptionList`(__ORDERID INT, __PROMO VARCHAR(50), __ITEMID INT)
BEGIN

SELECT 
 PIHDR.* 
FROM 
 orderDetail D 
INNER JOIN 
 items I ON D.ITEMID = I.ID 
INNER JOIN 
  promos PIHDR ON PIHDR.CODE = __PROMO AND (PIHDR.MAXQTY = 0 OR D.ORDERQTY <= PIHDR.MAXQTY)
LEFT OUTER JOIN 
  promosItems PI ON (PI.ITEMID = I.ID OR PI.ITEMID = I.PARENTITEM)
WHERE 
  ORDERID = __ORDERID AND D.ITEMID = __ITEMID AND PI.ITEMID IS NULL;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckUserAccount` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CheckUserAccount`(UNAME VARCHAR(50), PASS VARCHAR(50))
BEGIN
	SELECT 
		USERS.*,
        COALESCE(SKINDEF.STYLEFILENAME,'DEFAULT') AS SKIN,
        COALESCE(BRANCH.SKIN,'DEFAULT') AS BANNER
	FROM 
		user USERS
	LEFT OUTER JOIN
		branches BRANCH ON 
			USERS.BRANCH = BRANCH.CODE
	LEFT OUTER JOIN
		branchSkinDefinition SKINDEF ON 
			BRANCH.SKIN = SKINDEF.SKINNAME
	WHERE USERNAME=UNAME AND PASSWORD=CONCAT('*', UPPER(SHA1(UNHEX(SHA1(PASS))))) AND USERS.STATUS=1;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckUserAccount_ByIdBranch` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CheckUserAccount_ByIdBranch`(__USERNAME VARCHAR(50), __BRANCHNAME VARCHAR(100))
BEGIN

	SELECT 
		USERS.*,
        COALESCE(SKINDEF.STYLEFILENAME,'DEFAULT') AS SKIN,
        COALESCE(BRANCH.SKIN,'DEFAULT') AS BANNER
	FROM 
		user USERS
	LEFT OUTER JOIN
		branches BRANCH ON 
			USERS.BRANCH = BRANCH.CODE
	LEFT OUTER JOIN
		branchSkinDefinition SKINDEF ON 
			BRANCH.SKIN = SKINDEF.SKINNAME
	WHERE 
        USERNAME=__USERNAME AND 
        USERS.STATUS=1 AND 
        USERS.USERLEVEL < 90;
    
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `ClearAllAdBrandLink` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ClearAllAdBrandLink`(__ID INT)
BEGIN
	DELETE FROM AdItemsBrand WHERE ID = __ID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `ClearAllCategoryBrandLink` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ClearAllCategoryBrandLink`(__CATID INT)
BEGIN
	DELETE FROM categoriesBrand WHERE CATID = __CATID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateAccountTicket` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateAccountTicket`(__ENTEREDBY VARCHAR(50), __LANGUAGE VARCHAR(20), __ACCOUNT VARCHAR(20), __BANNER VARCHAR(20),
__BRANCHNUMBER VARCHAR(20), __BRANCHNAME VARCHAR(100), __ADDRESS VARCHAR(1000), __CITY VARCHAR(100), __PROVINCE VARCHAR(100),
__POSTAL VARCHAR(100), __COUNTRY VARCHAR(100), __PHONE VARCHAR(100), __FAX VARCHAR(100), __APPOINTMENTPHONE VARCHAR(100),
__CONTACTFIRST VARCHAR(100), __CONTACTLAST VARCHAR(100), __EMAIL VARCHAR(100), __NOTE VARCHAR(1000),
__BOUTIQUEFIRST VARCHAR(100), __BOUTIQUELAST VARCHAR(100), __TAGLINENAME VARCHAR(100), __AFFILIATEDNAME VARCHAR(100),
__PHARMLEGALNAME VARCHAR(100), __PHARMPHOTONAME VARCHAR(100))
BEGIN

DECLARE __TICKETID INT;

INSERT INTO accountMgrHeader
(ENTEREDBY,DATEENTERED,STATUS,TITLE,DATECLOSED,LANGUAGE,ACCOUNT,BANNER,BRANCHNUMBER,ADDRESS,CITY,PROVINCE,COUNTRY,POSTAL,
PHONE,FAX,APPOINTMENTPHONE,CONTACTFIRST,CONTACTLAST,EMAIL,NOTE,BOUTIQUEFIRST,BOUTIQUELAST,TAGLINENAME,AFFILIATEDNAME,PHARMLEGALNAME,PHARMPHOTONAME)
VALUES
(__ENTEREDBY,CURRENT_TIMESTAMP,1,__BRANCHNAME,NULL,__LANGUAGE,__ACCOUNT,__BANNER,__BRANCHNUMBER,
__ADDRESS,__CITY,__PROVINCE,__COUNTRY,__POSTAL,__PHONE,__FAX,__APPOINTMENTPHONE,__CONTACTFIRST,__CONTACTLAST,__EMAIL,__NOTE,
__BOUTIQUEFIRST,__BOUTIQUELAST,__TAGLINENAME,__AFFILIATEDNAME, __PHARMLEGALNAME, __PHARMPHOTONAME);

SET __TICKETID = LAST_INSERT_ID();

SELECT *,UNIX_TIMESTAMP(DATEENTERED) AS UNIX_DATEENTERED FROM accountMgrHeader WHERE ID = __TICKETID;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateAccountTicketReply` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateAccountTicketReply`(__TICKETID INT, __MESSAGE VARCHAR(1000), __ENTEREDBY VARCHAR(50))
BEGIN

 DECLARE __TICCHECK INT;
 SELECT COUNT(*) INTO __TICCHECK FROM accountMgrHeader WHERE ( ENTEREDBY = __ENTEREDBY OR __ENTEREDBY IN (SELECT USERNAME FROM user WHERE USERLEVEL >= 99)) AND ID = __TICKETID;
 
 IF __TICCHECK > 0 THEN

 INSERT INTO
 accountMgrMessages
 (TICKETID,DATEENTERED,ENTEREDBY,CLIENTMESSAGE,MESSAGE)
 VALUES
 (
 __TICKETID,
 CURRENT_TIMESTAMP,
 __ENTEREDBY,
 CASE WHEN __ENTEREDBY IN (SELECT USERNAME FROM user WHERE USERLEVEL >= 99) THEN 0 ELSE 1 END,
 __MESSAGE
 );
 
 SELECT 
 HDR.*,
 DTL.MESSAGE,
 DTL.DATEENTERED AS RDATEENTERED,
 USR.FIRSTNAME,
 USR.LASTNAME,
 USR.EMAIL,
 USR.LANGUAGE,
 USR2.FIRSTNAME AS RFIRSTNAME, 
 USR2.LASTNAME AS RLASTNAME,
 USR2.EMAIL AS REMAIL 
 FROM 
 accountMgrHeader HDR 
 LEFT OUTER JOIN
 accountMgrMessages DTL ON 
 HDR.ID = DTL.TICKETID
 LEFT OUTER JOIN
 user USR ON 
 HDR.ENTEREDBY = USR.USERNAME
 LEFT OUTER JOIN
 user USR2 ON 
 DTL.ENTEREDBY = USR2.USERNAME                
		WHERE 
		ID = __TICKETID AND
        DTL.MESSAGEID = LAST_INSERT_ID();
        
	END IF;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateAdBrandLink` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateAdBrandLink`(__ADID INT, __BRANDNAME VARCHAR(20))
BEGIN
	INSERT INTO AdItemsBrand (ID,BRANDNAME)
    VALUES (__ADID,__BRANDNAME);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateCategoryBrandLink` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateCategoryBrandLink`(__CATID INT, __BRANDNAME VARCHAR(20))
BEGIN
	INSERT INTO categoriesBrand (CATID,BRANDNAME)
    VALUES (__CATID,__BRANDNAME);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateItemBranchLink` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateItemBranchLink`(__ITEMID INT, __BRANCHCODE VARCHAR(20))
BEGIN
	INSERT INTO
		itemsBranchesLink
		(ITEMID,BRANCHCODE)
	VALUES
		(__ITEMID,__BRANCHCODE);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateItemCategoryLink` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateItemCategoryLink`(__ITEMID INT, __SUBCATID INT)
BEGIN
	INSERT INTO 
		itemsSubcategoryLink
		(ITEMID,SUBCATID)
	VALUES
		(__ITEMID,__SUBCATID);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateItemPricing` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateItemPricing`(__ITEMID INT, __QTY INT, __ITEMOPTION VARCHAR(30), __PRICE DECIMAL(19,4), __LENGTH DECIMAL(19,4), __WIDTH DECIMAL(19,4), __HEIGHT DECIMAL(19,4), __WEIGHT DECIMAL(19,4), __PIECES INT)
BEGIN
	INSERT INTO
		itemPricing
		(ITEMID,QTY,PRICE,LENGTH,WIDTH,HEIGHT,WEIGHT,PIECES,ITEMOPTION)
	VALUES
		(__ITEMID,__QTY,__PRICE,__LENGTH,__WIDTH,__HEIGHT,__WEIGHT,__PIECES,__ITEMOPTION);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateNewAd` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateNewAd`(__NAME VARCHAR(1000), __STARTDATE DATE, __ENDDATE DATE, __LANGUAGE VARCHAR(2), __SORTORDER INT, __URL VARCHAR(500), __ADPATH VARCHAR(200))
BEGIN

	INSERT INTO 
		AdItems
        (`NAME`,STARTDATE,ENDDATE,`LANGUAGE`,SORTORDER,IMAGEPATH,URL)
	VALUES
		(__NAME,__STARTDATE,__ENDDATE,__LANGUAGE,__SORTORDER,__ADPATH,__URL);

	SELECT LAST_INSERT_ID() AS ADID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateNewBranch` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateNewBranch`(__CODE VARCHAR(20), __NAME VARCHAR(100), __MGREMAIL VARCHAR(100), __TREEMAIL VARCHAR(100), __TAXGROUP VARCHAR(6), __SKIN VARCHAR(20), __STATUS INTEGER, __COMMENTS VARCHAR(1000), __SHIPZONE VARCHAR(20))
BEGIN
INSERT INTO
	branches (CODE,NAME,MANAGEMENTEMAIL,TREASUREREMAIL,TAXGROUP,SKIN,STATUS,COMMENTS,SHIPZONE)
VALUES
	(__CODE, __NAME, __MGREMAIL, __TREEMAIL,__TAXGROUP,__SKIN, __STATUS, __COMMENTS, __SHIPZONE);

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateNewBranchAddress` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateNewBranchAddress`(__CODE VARCHAR(20), __LANG VARCHAR(2), __ISMAIN INTEGER, __ADDRESS VARCHAR(1000), __ADDRESS2 VARCHAR(1000), __CITY VARCHAR(100), __PROVINCE VARCHAR(100), __COUNTRY VARCHAR(100), __POSTALCODE VARCHAR(20), __PHONE VARCHAR(20), __FAX VARCHAR(20))
BEGIN

INSERT INTO
	branchesAddresses
		(CODE, LANGUAGE, ISMAIN, ADDRESS, ADDRESS2, CITY, PROVINCE, COUNTRY, POSTALCODE, PHONE, FAX)
VALUES
	(__CODE, __LANG, __ISMAIN, __ADDRESS, __ADDRESS2, __CITY, __PROVINCE, __COUNTRY, __POSTALCODE, __PHONE, __FAX);

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateNewCategory` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateNewCategory`(__NAME VARCHAR(50), __DESCRIPTION VARCHAR(200), __LANGUAGE VARCHAR(2), __ICON VARCHAR(200), __USERLEVEL INTEGER, __COMMENTS VARCHAR(1000))
BEGIN

	INSERT	INTO
		categories
        (NAME,DESCRIPTION,ICONURL,LANGUAGE,USERLEVEL,COMMENTS,CREATEDDATE,MODIFIEDDATE)
	VALUES
		(__NAME,__DESCRIPTION,__ICON,__LANGUAGE,__USERLEVEL,__COMMENTS,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP);

	SELECT LAST_INSERT_ID() AS CATID;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateNewItem` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `CreateNewItem`(IN `__TYPE` INT, IN `__CODE` VARCHAR(50), IN `__DESCRIPTION` VARCHAR(200), IN `__PRODUCEDETAIL` VARCHAR(1000), IN `__SIZE` VARCHAR(50), IN `__NUMPAGES` VARCHAR(50), IN `__PRINTINGTYPE` VARCHAR(50), IN `__STOCK` VARCHAR(50), IN `__STATUS` INT, IN `__MINLEVEL` INT, IN `__LEADTIME` INT, IN `__INITIALQTY` INT, IN `__DISPLAYNAME` VARCHAR(1000), IN `__PROOFNAME` VARCHAR(1000), IN `__PARAMETERSNAME` VARCHAR(1000), IN `__UPLOADDIR` VARCHAR(1000), IN `__PREVIEWNAME` VARCHAR(1000), IN `__SHIPBOXINSLEEVE` INT, IN `__SKIPPDFPERMISSIONCHECK` INT, IN `__DLSUGGESTIONS` VARCHAR(1000))
BEGIN
        INSERT INTO 
                items
                (TYPE,CODE,DESCRIPTION,PRODUCEDETAIL,SIZE,NUMPAGES,PRINTINGTYPE,STOCK,STATUS,MINLEVEL,LEADTIME,DISPLAYIMAGENAME,PROOFPDFNAME,PARAMETERSFILENAME,PREVIEWIMAGENAME,DISPLAYIMAGEPATH,PROOFPDFPATH,PARAMETERSFILEPATH,PREVIEWIMAGEPATH,SHIPBOXINSLEEVE,SKIPPDFPERMISSIONCHECK,DLSUGGESTIONS)
        VALUES
                (__TYPE,__CODE,__DESCRIPTION,__PRODUCEDETAIL,__SIZE,__NUMPAGES,__PRINTINGTYPE,__STOCK,__STATUS,__MINLEVEL,__LEADTIME,__DISPLAYNAME,__PROOFNAME,__PARAMETERSNAME,__PREVIEWNAME,
         CASE WHEN LENGTH(__DISPLAYNAME) > 0 THEN CONCAT(__UPLOADDIR,__DISPLAYNAME) ELSE '' END,
         CASE WHEN LENGTH(__PROOFNAME) > 0 THEN CONCAT(__UPLOADDIR,__PROOFNAME) ELSE '' END,
         CASE WHEN LENGTH(__PARAMETERSNAME) > 0 THEN CONCAT(__UPLOADDIR,__PARAMETERSNAME) ELSE '' END,
         CASE WHEN LENGTH(__PREVIEWNAME) > 0 THEN CONCAT(__UPLOADDIR,__PREVIEWNAME) ELSE '' END,
         __SHIPBOXINSLEEVE,
         __SKIPPDFPERMISSIONCHECK,
         __DLSUGGESTIONS
                );
 
        SELECT LAST_INSERT_ID() AS ITEMID;
           
        IF __TYPE = 0 THEN
                INSERT INTO 
                        itemsInventory
                        (ITEMID,QTYONHAND)
                VALUES (LAST_INSERT_ID(),0);
        END IF;
 
        IF __INITIALQTY > 0 THEN
                UPDATE 
                        itemsInventory
                SET
                        QTYONHAND = __INITIALQTY
                WHERE
                        ITEMID = LAST_INSERT_ID();
            
                INSERT INTO 
                        itemsAdjustmentLog
            (ITEMID,QTY,ADJDATE,REASON)
                VALUES (LAST_INSERT_ID(),__INITIALQTY,CURRENT_TIMESTAMP,'Initial Inventory');
    END IF;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateNewNewsItem` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateNewNewsItem`(__STARTDATE DATE, __ENDDATE DATE, __LANGUAGE VARCHAR(2), __TITLE VARCHAR(1000), __MESSAGE VARCHAR(1000))
BEGIN
	INSERT INTO 
		newsItems
		(STARTDATE,ENDDATE,LANGUAGE,TITLE,MESSAGE)
	VALUES
		(__STARTDATE,__ENDDATE,__LANGUAGE,__TITLE,__MESSAGE);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateNewPromo` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `CreateNewPromo`(__NAME VARCHAR(100), __CODE VARCHAR(50), __CODETYPE VARCHAR(12), __PROMOVALUE DECIMAL(19,2), __QTYTYPE VARCHAR(12), __MAXQTY INT, __MINQTY INT, __EXACTQTY INT, __STARTDATE DATE, __ENDDATE DATE, __SINGLEUSE INT, __REDEEMED INT, __SINGLEITEM INT)
BEGIN

 INSERT INTO 
 promos
 (NAME,CODE,CODETYPE,PROMOVALUE,QTYTYPE,MAXQTY,MINQTY,EXACTQTY,STARTDATE,ENDDATE,SINGLEUSE,REDEEMED,SINGLEITEM)
 VALUES
 (__NAME,__CODE,__CODETYPE,__PROMOVALUE,__QTYTYPE,__MAXQTY,__MINQTY,__EXACTQTY,__STARTDATE,__ENDDATE,__SINGLEUSE,__REDEEMED,__SINGLEITEM);

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateNewShipToAddress` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `CreateNewShipToAddress`(__NAME VARCHAR(100), __STOREID VARCHAR(20), __ADDRESS VARCHAR(1000), __ADDRESS2 VARCHAR(1000), __CITY VARCHAR(100),
__PROVINCE VARCHAR(100), __COUNTRY VARCHAR(100), __POSTAL VARCHAR(20), __PHONE VARCHAR(20), __FAX VARCHAR(20),
__TAXGROUP VARCHAR(6), __SHIPZONE VARCHAR(6))
BEGIN

INSERT INTO
	shipToAddresses
    (NAME,STOREID,ADDRESS,ADDRESS2,CITY,PROVINCE,COUNTRY,POSTAL,PHONE,FAX,TAXGROUP,SHIPZONE)
VALUES
	(__NAME,__STOREID,__ADDRESS,__ADDRESS2,__CITY,__PROVINCE,__COUNTRY,__POSTAL,__PHONE,__FAX,__TAXGROUP,__SHIPZONE);

SELECT LAST_INSERT_ID() AS SHIPID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateNewSubCategory` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `CreateNewSubCategory`(__CATID INTEGER, __PARENTSUBCATID INTEGER, __NAME VARCHAR(50), __DESCRIPTION VARCHAR(200), __ICONURL VARCHAR(200), __USERLEVEL INT)
BEGIN
    INSERT INTO subcategories (CATID,PARENTSUBCATID,NAME,DESCRIPTION,ICONURL,USERLEVEL)
    VALUES (__CATID,__PARENTSUBCATID,__NAME,__DESCRIPTION, __ICONURL, __USERLEVEL);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateNewUser` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateNewUser`(UNAME VARCHAR(50), __BRANCH VARCHAR(20), PASS VARCHAR(50), FNAME VARCHAR(50), LNAME VARCHAR(50), LANG VARCHAR(2), STAT INTEGER, USERLVL INTEGER, COMMENTS VARCHAR(1000), EMAIL VARCHAR(100))
BEGIN

INSERT INTO 
	`user` (`USERNAME`,`BRANCH`,`PASSWORD`,`PLAINPASSWORD`,`FIRSTNAME`,`LASTNAME`,`LANGUAGE`,`STATUS`,`USERLEVEL`,`COMMENTS`,`EMAIL`) 
VALUES 
  (UNAME,__BRANCH,CONCAT('*', UPPER(SHA1(UNHEX(SHA1(PASS))))),PASS,FNAME,LNAME,LANG,STAT,USERLVL,COMMENTS,EMAIL);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateShipmentHeader` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateShipmentHeader`(__ORDERID INT, __TRACKNUM VARCHAR(100), __METHOD VARCHAR(100), __AMOUNT DECIMAL(16,2), __WEIGHT DECIMAL(16,2), __PIECES INT, __INSTRUCTIONS VARCHAR(1000))
BEGIN

	INSERT INTO 
		shipmentHeader
        (ORDERID,TRACKNUM,SHIPDATE,SHIPMETHOD,SHIPAMOUNT,SHIPWEIGHT,SHIPPIECES,SHIPINSTRUCTIONS)
	VALUES
		(__ORDERID,__TRACKNUM,CURRENT_TIMESTAMP,__METHOD,__AMOUNT,__WEIGHT,__PIECES,__INSTRUCTIONS);
    
    SELECT
		SHIPID,
        ORDERID
	FROM
		shipmentHeader
	WHERE
		SHIPID = LAST_INSERT_ID();
    
    
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateShipmentLine` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateShipmentLine`(__SHIPID INT, __ORDERID INT, __ORDERLINE INT, __SHIPQTY INT)
BEGIN

	INSERT INTO
		shipmentDetail
		(SHIPID,ORDERID,ORDERLINE,SHIPQTY)
	VALUES
		(__SHIPID,__ORDERID,__ORDERLINE,__SHIPQTY);
        
	UPDATE
		orderDetail
	SET
		SHIPTODATEQTY = SHIPTODATEQTY + __SHIPQTY
	WHERE
		ORDERID = __ORDERID AND
        ITEMLINE = __ORDERLINE;
        
	UPDATE
		itemsInventory
	SET
		QTYONHAND = QTYONHAND - __SHIPQTY
	WHERE
		ITEMID IN (SELECT ITEMID FROM orderDetail WHERE ORDERID = __ORDERID AND ITEMLINE = __ORDERLINE);
        
	INSERT INTO 
		itemsAdjustmentLog
			(ITEMID,QTY,ADJDATE,REASON)
	SELECT
		ITEMID,
        __SHIPQTY * -1 AS QTY,
        CURRENT_TIMESTAMP AS ADJDATE,
        CONCAT('Shipment for Order# ', ORDERID, ' Ship# ', __SHIPID) AS REASON
	FROM
		orderDetail
	WHERE
		ORDERID = __ORDERID AND
        ITEMLINE = __ORDERLINE;  
        
	UPDATE
		orderHeader
	SET
		ORDERSTATUS = 'SHIPPED'
	WHERE
		ORDERID = __ORDERID AND
        ORDERID IN (SELECT ORDERID FROM orderDetail WHERE ORDERID = __ORDERID GROUP BY ORDERID HAVING SUM(ORDERQTY) = SUM(SHIPTODATEQTY));

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateShipToAddressUserLink` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `CreateShipToAddressUserLink`(__shipid INT, __username VARCHAR(30))
BEGIN

	INSERT INTO shipToAddressesUserList (ID,USERNAME) VALUES (__shipid, __username); 

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateSupportTicket` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateSupportTicket`(__TITLE VARCHAR(1000), __MESSAGE VARCHAR(1000), __ENTEREDBY VARCHAR(50))
BEGIN
 
 DECLARE __TICKETID INT;

 
 INSERT INTO ticketHeader
 (ENTEREDBY,DATEENTERED,STATUS,TITLE,DATECLOSED)
 VALUES
 (__ENTEREDBY,CURRENT_TIMESTAMP,1,__TITLE,NULL);
 
 
 SET __TICKETID = LAST_INSERT_ID();
 
 
 INSERT INTO ticketDetail
 (TICKETID,DATEENTERED,ENTEREDBY,CLIENTMESSAGE,MESSAGE)
 VALUES
 (__TICKETID,CURRENT_TIMESTAMP,__ENTEREDBY,1,__MESSAGE);
 
 
 SELECT 
 HDR.*,
 DTL.MESSAGEID,
 DTL.MESSAGE,
 USR.FIRSTNAME,
 USR.LASTNAME,
 USR.EMAIL,
 USR.LANGUAGE,
 UNIX_TIMESTAMP(DTL.DATEENTERED) AS UNIX_DATEENTERED
 FROM 
 ticketHeader HDR 
 LEFT OUTER JOIN
 ticketDetail DTL ON 
 HDR.ID = DTL.TICKETID
 LEFT OUTER JOIN
 user USR ON 
 HDR.ENTEREDBY = USR.USERNAME
 WHERE 
 ID = __TICKETID;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateSupportTicketAttachment` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateSupportTicketAttachment`(__TICKETID INT, __MESSAGEID INT, __STORENAME VARCHAR(200), __FILENAME VARCHAR(200))
BEGIN

INSERT INTO ticketAttachment (TICKETID,MESSAGEID, STOREFILENAME,ORIGFILENAME)
VALUES (__TICKETID, __MESSAGEID, __STORENAME,__FILENAME);
	

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CreateSupportTicketReply` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `CreateSupportTicketReply`(__TICKETID INT, __MESSAGE VARCHAR(1000), __ENTEREDBY VARCHAR(50))
BEGIN

DECLARE __TICCHECK INT;
 SELECT COUNT(*) INTO __TICCHECK FROM ticketHeader WHERE ( ENTEREDBY = __ENTEREDBY OR __ENTEREDBY IN (SELECT USERNAME FROM user WHERE USERLEVEL >= 81)) AND ID = __TICKETID;
 
 IF __TICCHECK > 0 THEN

		INSERT INTO
			ticketDetail
			(TICKETID,DATEENTERED,ENTEREDBY,CLIENTMESSAGE,MESSAGE)
		VALUES
			(
				__TICKETID,
				CURRENT_TIMESTAMP,
				__ENTEREDBY,
				CASE WHEN __ENTEREDBY IN (SELECT USERNAME FROM user WHERE USERLEVEL >= 81) THEN 0 ELSE 1 END,
				__MESSAGE
			);
            
		SELECT 
			HDR.*,
			DTL.MESSAGE,
			DTL.DATEENTERED AS RDATEENTERED,
			USR.FIRSTNAME,
			USR.LASTNAME,
			USR.EMAIL,
            USR.LANGUAGE,
			USR2.FIRSTNAME AS RFIRSTNAME, 
			USR2.LASTNAME AS RLASTNAME,
			USR2.EMAIL AS REMAIL            
		FROM 
			ticketHeader HDR 
		LEFT OUTER JOIN
			ticketDetail DTL ON 
				HDR.ID = DTL.TICKETID
		LEFT OUTER JOIN
			user USR ON 
				HDR.ENTEREDBY = USR.USERNAME
		LEFT OUTER JOIN
			user USR2 ON 
				DTL.ENTEREDBY = USR2.USERNAME                
		WHERE 
		ID = __TICKETID AND
        DTL.MESSAGEID = LAST_INSERT_ID();
        
	END IF;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteAdItem` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteAdItem`(__ID INT)
BEGIN
	DELETE FROM AdItems WHERE ID = __ID;
    DELETE FROM AdItemsBrand WHERE ID = __ID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteAllBranchLinks` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteAllBranchLinks`(__ITEMID INT)
BEGIN
	DELETE FROM itemsBranchesLink WHERE ITEMID = __ITEMID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteAllItemCategoryLinks` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteAllItemCategoryLinks`(__ITEMID INT)
BEGIN
	DELETE FROM itemsSubcategoryLink WHERE ITEMID = __ITEMID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteAllPricingLinks` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteAllPricingLinks`(__ITEMID INT)
BEGIN
	DELETE FROM itemPricing WHERE ITEMID = __ITEMID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteAllShipToAddressUserLinks` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `DeleteAllShipToAddressUserLinks`(__shipid INT)
BEGIN
	DELETE FROM shipToAddressesUserList WHERE ID = __shipid; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteBranchAddress` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteBranchAddress`(__CODE VARCHAR(20), __LANG VARCHAR(2))
BEGIN
	DELETE FROM branchesAddresses WHERE CODE = __CODE AND LANGUAGE = __LANG;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteBranchProfile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteBranchProfile`(__CODE VARCHAR(20))
BEGIN
	DELETE FROM branches WHERE CODE = __CODE;
    DELETE FROM branchesAddresses WHERE CODE = __CODE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteCategoryProfile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteCategoryProfile`(__CATID INTEGER)
BEGIN
	DELETE FROM categories WHERE CATID = __CATID;
    DELETE FROM subcategories WHERE CATID = __CATID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteItem` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteItem`(__ITEMID INT)
BEGIN
  DELETE FROM items WHERE ID = __ITEMID;
    DELETE FROM itemPricing WHERE ITEMID = __ITEMID;
    DELETE FROM itemsBranchesLink WHERE ITEMID = __ITEMID;
    DELETE FROM itemsSubcategoryLink WHERE ITEMID = __ITEMID;
    DELETE FROM itemsInventory WHERE ITEMID = __ITEMID;
    DELETE FROM itemsPrintDefinition WHERE ID = __ITEMID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteNewsItem` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteNewsItem`(__ID INTEGER)
BEGIN
	DELETE FROM newsItems WHERE ID = __ID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeletePromoCategories` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `DeletePromoCategories`(__CODE VARCHAR(50))
BEGIN
  DELETE FROM promosCategories WHERE CODE = __CODE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeletePromoItems` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeletePromoItems`(__CODE VARCHAR(50))
BEGIN
	DELETE FROM promosItems WHERE CODE = __CODE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeletePromoProfile` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `DeletePromoProfile`(__CODE VARCHAR(50))
BEGIN
  DELETE FROM promosCategories WHERE CODE = __CODE;
    DELETE FROM promosItems WHERE CODE = __CODE;
  DELETE FROM promos WHERE CODE = __CODE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteShipToAddress` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `DeleteShipToAddress`(__ID INT)
BEGIN

DELETE FROM shipToAddressesUserList WHERE ID = __ID;
DELETE FROM shipToAddresses WHERE ID = __ID;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteSubCategoryProfile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteSubCategoryProfile`(__SUBCATID INTEGER)
BEGIN
	DELETE FROM subcategories WHERE SUBCATID = __SUBCATID;
    DELETE FROM subcategories WHERE PARENTSUBCATID = __SUBCATID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DeleteUserProfile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteUserProfile`(UNAME VARCHAR(100))
BEGIN

DELETE FROM user WHERE USERNAME = UNAME;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DuplicateBranchProfile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DuplicateBranchProfile`(__CODE VARCHAR(20), __NEWCODE VARCHAR(20))
BEGIN

	INSERT INTO
		branches
        (CODE,NAME,MANAGEMENTEMAIL,TREASUREREMAIL,TAXGROUP,STATUS,COMMENTS,CREATEDDATE,MODIFIEDDATE,SHIPZONE)
	SELECT
		__NEWCODE AS CODE,
        NAME,
        MANAGEMENTEMAIL,
        TREASUREREMAIL,
        TAXGROUP,
        STATUS,
        COMMENTS,
        CURRENT_TIMESTAMP AS CREATEDDATE,
        CURRENT_TIMESTAMP AS MODIFIEDDATE,
        SHIPZONE
	FROM
		branches
	WHERE
		CODE = __CODE;
        
	INSERT INTO
		branchesAddresses
        (CODE,LANGUAGE,ISMAIN,ADDRESS,CITY,PROVINCE,COUNTRY,POSTALCODE,PHONE,FAX)
	SELECT
		__NEWCODE AS CODE,
        LANGUAGE,
        ISMAIN,
        ADDRESS,
        CITY,
        PROVINCE,
        COUNTRY,
        POSTALCODE,
        PHONE,
        FAX
	FROM
		branchesAddresses
	WHERE
		CODE = __CODE;

	INSERT INTO
		branchesAssetData
        (BRANCHCODE,TAG,VALUE)
    SELECT
		__NEWCODE AS BRANCHCODE,
        TAG,
        VALUE
	FROM
		branchesAssetData
	WHERE
		BRANCHCODE = __CODE;

	INSERT INTO
		itemsBranchesLink
        (ITEMID,BRANCHCODE)
	SELECT
		ITEMID,
        __NEWCODE AS BRANCHCODE
	FROM
		itemsBranchesLink
	WHERE
		BRANCHCODE = __CODE;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DuplicateCategoryProfile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DuplicateCategoryProfile`(__CATID INT)
BEGIN

INSERT INTO
	categories
	(NAME,DESCRIPTION,ICONURL,LANGUAGE,USERLEVEL,COMMENTS,CREATEDDATE,MODIFIEDDATE)
SELECT
	CONCAT(NAME,' **DUP**') AS NAME,
    DESCRIPTION,
    ICONURL,
    LANGUAGE,
    USERLEVEL,
    COMMENTS,
    CURRENT_TIMESTAMP AS CREATEDDATE,
    CURRENT_TIMESTAMP AS MODIFIEDDATE
FROM
	categories
WHERE
	CATID = __CATID;
    
SET @CATID = LAST_INSERT_ID();    
   
INSERT INTO categoriesBrand (CATID,BRANDNAME)
SELECT @CATID,BRANDNAME FROM categoriesBrand WHERE CATID = __CATID;
    
SELECT @CATID AS CATID;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DuplicateItem` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DuplicateItem`(__ITEMID INT)
BEGIN

  INSERT INTO
    items 
        (TYPE,CODE,DESCRIPTION,SIZE,NUMPAGES,STATUS,MINLEVEL,LEADTIME,PARENTITEM,
         ARCHIVED,GENERATEDBY,ASSETAPPROVED,SHIPBOXINSLEEVE,PRINTINGTYPE,STOCK) 
  SELECT
    TYPE,
        CONCAT(CODE,' **DUP**'),
        DESCRIPTION,
        SIZE,
        NUMPAGES,
        STATUS,
        MINLEVEL,
        LEADTIME,
        PARENTITEM,
        ARCHIVED,
        GENERATEDBY,
        ASSETAPPROVED,
        SHIPBOXINSLEEVE,
        PRINTINGTYPE,
        STOCK
  FROM
    items
  WHERE
    ID = __ITEMID;
        
  SET @ITEMID = LAST_INSERT_ID();
 
  INSERT INTO
    itemPricing
        (ITEMID,QTY,PRICE,LENGTH,WIDTH,HEIGHT,WEIGHT,PIECES,ITEMOPTION)
  SELECT
    @ITEMID AS ITEMID,
        QTY,
        PRICE,
        LENGTH,
        WIDTH,
        HEIGHT,
        WEIGHT,
        PIECES,
        ITEMOPTION
  FROM
    itemPricing
  WHERE
    ITEMID = __ITEMID;
 
  INSERT INTO
    itemsBranchesLink
        (ITEMID,BRANCHCODE)
  SELECT
    @ITEMID AS ITEMID,
        BRANCHCODE
  FROM
    itemsBranchesLink
  WHERE
    ITEMID = __ITEMID;
        
  INSERT INTO
    itemsInventory
        (ITEMID,QTYONHAND)
  SELECT
    @ITEMID AS ITEMID,
        0 AS QTYONHAND
  FROM
    itemsInventory
  WHERE
    ITEMID = __ITEMID;
        
  INSERT INTO
    itemsSubcategoryLink
        (ITEMID,SUBCATID)
  SELECT
    @ITEMID AS ITEMID,
        SUBCATID
  FROM
    itemsSubcategoryLink
  WHERE
    ITEMID = __ITEMID;
        
  INSERT INTO
    itemsPrintDefinition
        (ID,PRESS,NUMPAGES,BLEEDS,COLOURS,FLATSIZE,FINISHSIZE,STOCK,PARENTSHEETSIZE,
         PRESSSHEETSIZE,NUMUP,LAYOUTORIENTATION,COATING,CONTOURCUT,LAMINATION,FINISHING,
         ACCESSORY,SPECIALINSTRUCTIONS,PACKAGELOCATION)
  SELECT
    @ITEMID AS ID,
        PRESS,NUMPAGES,BLEEDS,COLOURS,FLATSIZE,FINISHSIZE,STOCK,PARENTSHEETSIZE,
    PRESSSHEETSIZE,NUMUP,LAYOUTORIENTATION,COATING,CONTOURCUT,LAMINATION,FINISHING,
    ACCESSORY,SPECIALINSTRUCTIONS,PACKAGELOCATION
  FROM
    itemsPrintDefinition
  WHERE
    ID = __ITEMID;        
  
        
  SELECT @ITEMID AS ID;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DuplicateShipToAddress` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `DuplicateShipToAddress`(__ID INT)
BEGIN

	INSERT INTO
		shipToAddresses
		(NAME,ADDRESS,CITY,PROVINCE,COUNTRY,POSTAL,PHONE,FAX,TAXGROUP,SHIPZONE)
	SELECT
		NAME,
        ADDRESS,
        CITY,
        PROVINCE,
        COUNTRY,
        POSTAL,
        PHONE,
        FAX,
        TAXGROUP,
        SHIPZONE
	FROM
		shipToAddresses
	WHERE
		ID = __ID;
        
	SELECT @SHIPID := LAST_INSERT_ID() AS ID;
    
    INSERT INTO 
		shipToAddressesUserList
        (ID,USERNAME)
	SELECT
		@SHIPID,
        USERNAME
	FROM
		shipToAddressesUserList
	WHERE
		ID = __ID;
    

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `DuplicateUserProfile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DuplicateUserProfile`(__USERNAME VARCHAR(50), __NEWUSERNAME VARCHAR(50))
BEGIN

	INSERT INTO
		user
        (USERNAME,BRANCH,PASSWORD,PLAINPASSWORD,FIRSTNAME,LASTNAME,EMAIL,LANGUAGE,USERLEVEL,CREATEDDATE,MODIFIEDDATE,STATUS,COMMENTS)
	SELECT
		__NEWUSERNAME AS USERNAME,
        BRANCH,
        PASSWORD,
        PLAINPASSWORD,
        FIRSTNAME,
        LASTNAME,
        EMAIL,
        LANGUAGE,
        USERLEVEL,
        CURRENT_TIMESTAMP AS CREATEDDATE,
        CURRENT_TIMESTAMP AS MODIFIEDDATE,
        STATUS,
        COMMENTS
	FROM
		user
	WHERE
		USERNAME = __USERNAME;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `ExpireDownloadLinks` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ExpireDownloadLinks`()
BEGIN

UPDATE
	orderDetail
SET
	DOWNLOADLINK = NULL
WHERE
	DOWNLOADLINK IS NOT NULL AND
    ORDERID IN (SELECT ORDERID FROM orderHeader WHERE ORDERDATE < DATE_ADD(CURRENT_TIMESTAMP,INTERVAL -30 DAY));



END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_branchAssetDefinition` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_branchAssetDefinition`()
BEGIN
	SELECT * FROM branchAssetDefinition;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_branches` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_branches`()
BEGIN
	SELECT
		*
	FROM
		branches;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_branchesAddresses` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_branchesAddresses`()
BEGIN
	SELECT
		*
	FROM
		branchesAddresses;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_branchesAssetData` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_branchesAssetData`()
BEGIN
	SELECT
		*
	FROM
		branchesAssetData;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_branchesFixtures` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `extractTableData_branchesFixtures`()
BEGIN
	SELECT * FROM branchesFixtures ORDER BY BRANCHCODE,FIXTURECODE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_branchSkinDefinition` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_branchSkinDefinition`()
BEGIN

	SELECT
		*
	FROM
		branchSkinDefinition;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_campaign_fixtures` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `extractTableData_campaign_fixtures`()
BEGIN
	SELECT * FROM campaign_fixtures;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_categories` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_categories`()
BEGIN
	SELECT
		*
	FROM
		categories;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_itemPricing` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_itemPricing`()
BEGIN
SELECT * FROM itemPricing left outer join items on itemPricing.ITEMID = items.ID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_items` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_items`()
BEGIN
SELECT
		*
	FROM
		items;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_itemsBranchesLink` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_itemsBranchesLink`()
BEGIN
SELECT
		*
	FROM
		itemsBranchesLink;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_itemsInventory` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_itemsInventory`()
BEGIN
SELECT
		*
	FROM
		itemsInventory;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_itemsPrintDefinition` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_itemsPrintDefinition`()
BEGIN 
  SELECT items.CODE, items.DESCRIPTION, itemsPrintDefinition.* from itemsPrintDefinition left join items on itemsPrintDefinition.ID = items.ID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_itemsSubcategoryLink` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_itemsSubcategoryLink`()
BEGIN
SELECT
		*
	FROM
		itemsSubcategoryLink;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_newsItems` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_newsItems`()
BEGIN
SELECT
		*
	FROM
		newsItems;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_promos` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_promos`()
BEGIN
	SELECT * FROM promos;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_promosCategories` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `extractTableData_promosCategories`()
BEGIN
SELECT * FROM promosCategories;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_promosItems` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_promosItems`()
BEGIN
	SELECT * FROM promosItems;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_shipToAddresses` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_shipToAddresses`()
BEGIN
	SELECT
		*
	FROM
		shipToAddresses;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_shipToAddressesUserList` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `extractTableData_shipToAddressesUserList`()
BEGIN
SELECT * FROM shipToAddressesUserList;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_shipZoneCosts` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_shipZoneCosts`()
BEGIN
SELECT
		*
	FROM
		shipZoneCosts;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_subcategories` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_subcategories`()
BEGIN
SELECT
		*
	FROM
		subcategories;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_taxes` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_taxes`()
BEGIN
SELECT
		*
	FROM
		taxes;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extractTableData_user` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extractTableData_user`()
BEGIN
SELECT
		*
	FROM
		user;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `extract_TableData_branchAssetDefinition` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `extract_TableData_branchAssetDefinition`()
BEGIN
	SELECT * FROM branchAssetDefinition;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetAccountTicket` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetAccountTicket`(__TICKETID INT)
BEGIN

SELECT 
 HDR.*,
 DTL.*,
 USR.FIRSTNAME,
 USR.LASTNAME,
 UNIX_TIMESTAMP(DTL.DATEENTERED) AS UNIX_DATEENTERED 
FROM 
 accountMgrHeader HDR
LEFT OUTER JOIN
 accountMgrMessages DTL ON 
 HDR.ID = DTL.TICKETID
LEFT OUTER JOIN
user USR ON 
 DTL.ENTEREDBY = USR.USERNAME 
WHERE 
 ID = __TICKETID
ORDER BY
 DTL.DATEENTERED DESC;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetAccountTicketList` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetAccountTicketList`(__USERNAME VARCHAR(50))
BEGIN

	SELECT
		*,
        UNIX_TIMESTAMP(HDR.DATEENTERED) AS UNIX_DATEENTERED
	FROM
		accountMgrHeader HDR
	WHERE
		( HDR.STATUS = 1 OR (HDR.STATUS = 0 AND DATECLOSED >= DATE_ADD(NOW(), INTERVAL -14 DAY)) ) AND
        ( HDR.ENTEREDBY = __USERNAME OR __USERNAME IN (SELECT USERNAME FROM user WHERE USERLEVEL >= 99))
	ORDER BY
		HDR.STATUS DESC,
		HDR.DATEENTERED DESC;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetActiveAdItems` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetActiveAdItems`(__LANGUAGE VARCHAR(2), __SKIN VARCHAR(20))
BEGIN
	SELECT DISTINCT
		ADS.*
	FROM
		AdItems ADS
	INNER JOIN
		AdItemsBrand ADSBRAND ON 
			ADS.ID = ADSBRAND.ID
	WHERE
		(LANGUAGE = '--' OR LANGUAGE = __LANGUAGE) AND
        (ADSBRAND.BRANDNAME = 'ALL' OR ADSBRAND.BRANDNAME = __SKIN) AND
        CURRENT_TIMESTAMP >= STARTDATE AND CURRENT_TIMESTAMP <= ENDDATE
	ORDER BY
		COALESCE(SORTORDER,999);        
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetActiveNewsItems` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetActiveNewsItems`(__LANGUAGE VARCHAR(2))
BEGIN
	SELECT
		*
	FROM
		newsItems
	WHERE
		(LANGUAGE = '--' OR LANGUAGE = __LANGUAGE) AND
        CURRENT_TIMESTAMP >= STARTDATE AND CURRENT_TIMESTAMP <= ENDDATE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetAdBrandInformation` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetAdBrandInformation`(__ID INT)
BEGIN

SELECT 
	BSD.SKINNAME AS BRANDNAME,
    CASE WHEN ADB.BRANDNAME IS NOT NULL THEN 1 ELSE 0 END AS SELECTED
FROM
	(
		SELECT SKINNAME FROM branchSkinDefinition UNION ALL
        SELECT 'ALL' UNION ALL
        SELECT ''
	) BSD
LEFT OUTER JOIN
	(SELECT * FROM AdItemsBrand WHERE ID = __ID ) ADB ON 
		BSD.SKINNAME = ADB.BRANDNAME
ORDER BY 
	BSD.SKINNAME;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetAdItem` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetAdItem`(__ID INT)
BEGIN
	SELECT * FROM AdItems WHERE ID = __ID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetAllAdItems` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetAllAdItems`()
BEGIN
	SELECT 
		*
	FROM	
		AdItems;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetAllNewsItems` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetAllNewsItems`()
BEGIN
	SELECT
		*
	FROM
		newsItems;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetAllShipToAddresses` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetAllShipToAddresses`(__USEBRANCHES BOOLEAN, __USERNAME VARCHAR(30))
BEGIN

  SELECT
    RECTYPE,ID,NAME,ADDRESS,STOREID
  FROM
    (
  SELECT
    'S' AS RECTYPE,SADDR.ID, SADDR.NAME,SADDR.ADDRESS,CASE WHEN IFNULL(SADDR.STOREID,'') = '' THEN 'NA' ELSE STOREID END AS STOREID
  FROM
    shipToAddresses SADDR
  WHERE
    SADDR.ID IN (SELECT ID FROM shipToAddressesUserList WHERE USERNAME = '**ALL**' OR USERNAME = 'ALL' OR USERNAME = __USERNAME) 
        
  UNION ALL
    
    SELECT
    'B' AS RECTYPE,BRANCH.CODE,BRANCH.NAME,BADDR.ADDRESS,BRANCH.CODE AS STOREID
    FROM
    branches BRANCH
  INNER JOIN
    branchesAddresses BADDR ON 
      BRANCH.CODE = BADDR.CODE
  WHERE
    __USEBRANCHES = 1 AND
        BRANCH.STATUS = 1 AND
        BADDR.ISMAIN = 1
    ) ADDR
    ORDER BY
    NAME;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetAvailableShippingZones` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetAvailableShippingZones`()
BEGIN
	SELECT  * FROM shipZoneCosts LIMIT 1;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetBranchAddressInformation` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetBranchAddressInformation`(__CODE VARCHAR(20))
BEGIN
	SELECT
		*
	FROM
		branchesAddresses
	WHERE
		CODE = __CODE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetBranchAssets` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetBranchAssets`(__CODE VARCHAR(20))
BEGIN

	SELECT
		BAD.TAG,
        BAD.TYPE,
        BAD.NAME,
	IFNULL(BAD.VALIDATEPATTERN,'') AS VALIDATEPATTERN,
	IFNULL(BAD.VALIDATEERRORMSG,'') AS VALIDATEERRORMSG,
        IFNULL(BDATA.VALUE,'') AS VALUE
	FROM
		branchAssetDefinition BAD
	LEFT OUTER JOIN
		(SELECT * FROM branchesAssetData WHERE BRANCHCODE = __CODE) BDATA ON 
			BAD.TAG = BDATA.TAG
	ORDER BY
		BAD.DISPLAYORDER;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetBranchDropDown` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetBranchDropDown`()
BEGIN
	SELECT CODE,NAME FROM branches WHERE STATUS = 1 ORDER BY NAME;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetBranchInformation` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetBranchInformation`(__CODE VARCHAR(20))
BEGIN
	SELECT * FROM branches WHERE CODE = __CODE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetBranchProfile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetBranchProfile`(IN `__USERNAME` VARCHAR(50))
    NO SQL
SELECT
		BRANCH.NAME,
		BADDR.*
	FROM
		branches BRANCH
	INNER JOIN
		branchesAddresses BADDR ON 
			BRANCH.CODE = BADDR.CODE
	WHERE
		ISMAIN = 1 AND
		BRANCH.CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetCartCheckoutInformation` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetCartCheckoutInformation`(__USERNAME VARCHAR(20))
BEGIN

SET SQL_SAFE_UPDATES = 0;

UPDATE
	orderHeader
SET
	ORDERDATE = CURRENT_TIMESTAMP,
    ORDERMODIFIED = CURRENT_TIMESTAMP,
    EXPDATE = DATE_ADD(CURRENT_TIMESTAMP,INTERVAL 8 DAY),
    TAXNAME1 = (SELECT TAXNAME1 FROM taxes TAXES  WHERE SHIPTAXGROUP = TAXES.TAXCODE),
    TAXNAME2 = (SELECT TAXNAME2 FROM taxes TAXES  WHERE SHIPTAXGROUP = TAXES.TAXCODE),
    TAXNAME3 = (SELECT TAXNAME3 FROM taxes TAXES  WHERE SHIPTAXGROUP = TAXES.TAXCODE),
    TAXNAME4 = (SELECT TAXNAME4 FROM taxes TAXES  WHERE SHIPTAXGROUP = TAXES.TAXCODE),
    TAXNAME5 = (SELECT TAXNAME5 FROM taxes TAXES  WHERE SHIPTAXGROUP = TAXES.TAXCODE),
    TAXRATE1 = (SELECT TAXRATE1 FROM taxes TAXES  WHERE SHIPTAXGROUP = TAXES.TAXCODE),
    TAXRATE2 = (SELECT TAXRATE2 FROM taxes TAXES  WHERE SHIPTAXGROUP = TAXES.TAXCODE),
    TAXRATE3 = (SELECT TAXRATE3 FROM taxes TAXES  WHERE SHIPTAXGROUP = TAXES.TAXCODE),
    TAXRATE4 = (SELECT TAXRATE4 FROM taxes TAXES  WHERE SHIPTAXGROUP = TAXES.TAXCODE),
    TAXRATE5 = (SELECT TAXRATE5 FROM taxes TAXES  WHERE SHIPTAXGROUP = TAXES.TAXCODE)
WHERE 
	USERNAME  = __USERNAME AND 
    ORDERSTATUS = 'CART';

UPDATE 
	orderDetail I 
INNER JOIN 
(
	SELECT
		DTL.ITEMLINE,
        DTL.EXTPRICE * HDR.TAXRATE1 AS TAXAMT1,
        DTL.EXTPRICE * HDR.TAXRATE2 AS TAXAMT2,
        DTL.EXTPRICE * HDR.TAXRATE3 AS TAXAMT3,
        DTL.EXTPRICE * HDR.TAXRATE4 AS TAXAMT4,
        DTL.EXTPRICE * HDR.TAXRATE5 AS TAXAMT5
	FROM
		orderHeader HDR
	INNER JOIN
		orderDetail DTL ON
			HDR.ORDERID = DTL.ORDERID
	WHERE
		USERNAME = __USERNAME AND 
		ORDERSTATUS = 'CART'		
) II ON 
	I.ITEMLINE = II.ITEMLINE
SET
	I.TAXAMT1 = II.TAXAMT1,
    I.TAXAMT2 = II.TAXAMT2,
    I.TAXAMT3 = II.TAXAMT3,
    I.TAXAMT4 = II.TAXAMT4,
    I.TAXAMT5 = II.TAXAMT5
;

SELECT
	HDR.*,
    DTL.*,
    ITEM.*,
    COALESCE(SGROUP.SGRPNAME,'') AS SGRPNAME,
    COALESCE(SGROUP.SGRPPIECES,1) AS SGRPPIECES,
    COALESCE(SGROUP.SGRPBOXTYPE,'') AS SGRPBOXTYPE,
    COALESCE(SGROUP.SGRPWEIGHTPIECE,1.0) AS SGRPWEIGHTPIECE
FROM
	orderHeader HDR
INNER JOIN
	orderDetail DTL ON 
		HDR.ORDERID = DTL.ORDERID
INNER JOIN
	items ITEM ON 
		DTL.ITEMID = ITEM.ID
LEFT OUTER JOIN
	shippingGroupItems SGROUPITEMS ON 
		ITEM.ID = SGROUPITEMS.ITEMID
LEFT OUTER JOIN 
	shippingGroup SGROUP ON 
		SGROUPITEMS.SGRPNAME = SGROUP.SGRPNAME
WHERE 
	USERNAME  = __USERNAME AND 
    ORDERSTATUS = 'CART';
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetCartDiscountCodes` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetCartDiscountCodes`(__ORDERID INT)
BEGIN
	SELECT * FROM orderPromos WHERE ORDERID = __ORDERID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetCartItems` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetCartItems`(__USERNAME NVARCHAR(20))
BEGIN

SELECT 
	DTL.*
FROM 
	orderHeader HDR
INNER JOIN
	orderDetail DTL ON 
		HDR.ORDERID = DTL.ORDERID
WHERE 
	USERNAME COLLATE utf8_unicode_ci = __USERNAME AND 
    ORDERSTATUS = 'CART';


END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetCategoriesBySearchTerm` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetCategoriesBySearchTerm`(__TERM VARCHAR(50))
BEGIN

SELECT
  CATID,
    CONCAT(NAME, ' - ', DESCRIPTION) AS CATNAME
FROM
  categories
WHERE
  (
  NAME LIKE CONCAT('%',__TERM,'%') OR 
    DESCRIPTION LIKE CONCAT('%',__TERM,'%')
    ) 
ORDER BY 
  NAME,DESCRIPTION
LIMIT 20;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetCategoriesListByUsername` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetCategoriesListByUsername`(__USERNAME VARCHAR(50))
BEGIN
	SELECT
		CATS.*
	FROM
		categories CATS
	CROSS JOIN
		( SELECT * FROM user WHERE USERNAME = __USERNAME) USERS
	WHERE
		USERS.USERLEVEL >= CATS.USERLEVEL AND
        CATS.LANGUAGE IN (SELECT BADDR.LANGUAGE FROM user USERS INNER JOIN branchesAddresses BADDR ON USERS.BRANCH = BADDR.CODE  WHERE USERS.USERNAME = __USERNAME) AND
        CATS.CATID IN (
						SELECT CC.CATID 
						FROM categories CC 
                        INNER JOIN categoriesBrand CCC ON CC.CATID = CCC.CATID
                        INNER JOIN ( SELECT SKIN FROM branches BB INNER JOIN user UU ON BB.CODE = UU.BRANCH WHERE USERNAME = __USERNAME) UBS ON 
							(UBS.SKIN = CCC.BRANDNAME OR CCC.BRANDNAME = 'ALL')
                            )
	ORDER BY
		CATS.NAME
	;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetCategoryAndSubCatDropDown` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetCategoryAndSubCatDropDown`()
BEGIN
	SELECT
		SUBCATS.SUBCATID,
		CASE 
			WHEN SUBCATS_2.SUBCATID IS NOT NULL THEN CONCAT(CATS.NAME," - ", SUBCATS_2.NAME," - ",SUBCATS.NAME)
            ELSE CONCAT(CATS.NAME," - ",SUBCATS.NAME) 
		END AS  NAME
	FROM
		categories CATS
	INNER JOIN
		subcategories SUBCATS ON 
			CATS.CATID = SUBCATS.CATID
	LEFT OUTER JOIN
		subcategories SUBCATS_2 ON 
			SUBCATS.PARENTSUBCATID = SUBCATS_2.SUBCATID
	WHERE
		SUBCATS.SUBCATID NOT IN (SELECT DISTINCT PARENTSUBCATID FROM subcategories)
	ORDER BY
		CATS.NAME,
		SUBCATS_2.NAME,
        SUBCATS.NAME
	;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetCategoryBrandInformation` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetCategoryBrandInformation`(__CATID INT)
BEGIN

SELECT 
	BSD.SKINNAME AS BRANDNAME,
    CASE WHEN CB.BRANDNAME IS NOT NULL THEN 1 ELSE 0 END AS SELECTED
FROM
	(
		SELECT SKINNAME FROM branchSkinDefinition UNION ALL
        SELECT 'ALL' UNION ALL
        SELECT ''
	) BSD
LEFT OUTER JOIN
	(SELECT * FROM categoriesBrand WHERE CATID = __CATID ) CB ON 
		BSD.SKINNAME = CB.BRANDNAME
ORDER BY 
	BSD.SKINNAME;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetCategoryInformation` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetCategoryInformation`(__CATID INTEGER)
BEGIN
	SELECT * FROM categories WHERE CATID = __CATID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetCategoryItems` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetCategoryItems`(__USERNAME VARCHAR(50), __CATID INT, __SUBCATID INT)
BEGIN
    SELECT 
        CATS.NAME AS CATNAME,
        CATS.DESCRIPTION AS CATDESC,
        CASE WHEN ITEMS.TYPE = 2 THEN -99 ELSE SUBCATS.SUBCATID END AS SUBCATID,
        CASE WHEN ITEMS.TYPE = 2 THEN '{{!GENERATE!}}' ELSE SUBCATS.NAME END AS SUBCATNAME,
        CASE WHEN ITEMS.TYPE = 2 THEN CONCAT('{{!CUST_ART!}} ',SUBCATS.NAME) ELSE SUBCATS.DESCRIPTION END AS SUBCATDESC,
      SUBCATS.SUBCATID AS REALSUBCATID,
        ITEMS.ID AS ITEMID,
        ITEMS.CODE AS ITEMCODE,
        ITEMS.DESCRIPTION AS ITEMDESC,
        ITEMS.DISPLAYIMAGEPATH,
        ITEMS.PROOFPDFNAME,
        ITEMS.SIZE,
        ITEMS.NUMPAGES,
        ITEMS.MINLEVEL,
        ITEMS.STATUS,
        ITEMS.TYPE AS ITEMTYPE,
        COALESCE(ONORDERSTAT.TOTORDERQTY,0) AS ONORDER, 
        COALESCE(DATE(ONORDERSTAT.ORDERDATE),'') AS LASTORDERED,
        CASE WHEN ITEMS.TYPE = 3 THEN 1 WHEN BRANCHLINK.ITEMID IS NULL THEN 0 ELSE 1 END AS PARTOFBRANCH,
        COALESCE(ITEMINV.QTYONHAND,0) AS INSTOCK,
        ITEMS.ASSETAPPROVED
    FROM
        categories CATS
    LEFT OUTER JOIN
        subcategories SUBCATS ON 
            CATS.CATID = SUBCATS.CATID
    LEFT OUTER JOIN
        itemsSubcategoryLink SCTOI ON
            SCTOI.SUBCATID = SUBCATS.SUBCATID
    LEFT OUTER JOIN
        items ITEMS ON 
            ITEMS.ID = SCTOI.ITEMID
    LEFT OUTER JOIN
    
    (SELECT DISTINCT 
        ITEMID 
     FROM
        (
            SELECT 
                ITOB.ITEMID 
            FROM 
                user USERS 
            INNER JOIN 
                itemsBranchesLink ITOB ON USERS.BRANCH = ITOB.BRANCHCODE 
            WHERE 
                USERS.USERNAME = __USERNAME
                
            UNION ALL 
            SELECT ITOB.ITEMID FROM itemsBranchesLink ITOB WHERE ITOB.BRANCHCODE = 'ALL_BRANCHES'
            
            UNION ALL
            SELECT ITOB.ITEMID FROM user UU INNER JOIN branches BB ON UU.BRANCH = BB.CODE
            INNER JOIN itemsBranchesLink ITOB ON CONCAT('BRN_',BB.SKIN) = ITOB.BRANCHCODE 
            WHERE UU.USERNAME = __USERNAME
        ) LINKS
    )  BRANCHLINK ON 
            BRANCHLINK.ITEMID = ITEMS.ID
    LEFT OUTER JOIN
        (SELECT ITEMID, SUM(CASE WHEN ORDERQTY-SHIPTODATEQTY < 0 THEN 0 ELSE ORDERQTY-SHIPTODATEQTY END) AS TOTORDERQTY, MAX(ORDERDATE) AS ORDERDATE FROM orderHeader HDR INNER JOIN orderDetail DTL ON HDR.ORDERID = DTL.ORDERID WHERE ORDERSTATUS NOT IN ('WAITMA','CART', 'CANCELLED') GROUP BY ITEMID) ONORDERSTAT ON
            ONORDERSTAT.ITEMID = SCTOI.ITEMID  
    LEFT OUTER JOIN
        itemsInventory ITEMINV ON 
            ITEMS.ID = ITEMINV.ITEMID
    CROSS JOIN
        ( SELECT * FROM user WHERE USERNAME = __USERNAME) USERS                
    WHERE
        (__SUBCATID = -1 OR __SUBCATID = SUBCATS.SUBCATID OR __SUBCATID = SUBCATS.PARENTSUBCATID) AND
        CATS.CATID = __CATID AND
        IFNULL(ITEMS.ARCHIVED,0) = 0 AND
        (BRANCHLINK.ITEMID IS NOT NULL OR (ITEMS.TYPE = 3 AND __USERNAME IN (SELECT USERNAME FROM user WHERE USERLEVEL >= 99))) AND
        USERS.USERLEVEL >= CATS.USERLEVEL AND
        USERS.USERLEVEL >= SUBCATS.USERLEVEL 
    ORDER BY
        CASE WHEN ITEMS.TYPE = 2 THEN 1 ELSE 99 END, 
        SUBCATS.NAME,
        CASE WHEN PARENTITEM = 0 THEN 1 ELSE 99 END, 
        ITEMS.CODE
    ;
    



END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetCategorySubcategoryTiles` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetCategorySubcategoryTiles`(__USERNAME VARCHAR(50), __CATID INT)
BEGIN

    SELECT
        CATS.CATID,
        CATS.NAME AS CATNAME,
        CATS.DESCRIPTION AS CATDESC,
        SUBCATS.SUBCATID  AS SUBCATID,
        SUBCATS.NAME  AS SUBCATNAME,
        SUBCATS.DESCRIPTION  AS SUBCATDESC,
        SUBCATS.ICONURL AS SUBCATICONURL
    FROM
        categories CATS
    LEFT OUTER JOIN
        subcategories SUBCATS ON 
            CATS.CATID = SUBCATS.CATID  
    CROSS JOIN
        ( SELECT * FROM user WHERE USERNAME = __USERNAME) USERS            
    WHERE
        CATS.CATID = __CATID AND
        SUBCATS.PARENTSUBCATID = -1 AND
        USERS.USERLEVEL >= CATS.USERLEVEL AND
        USERS.USERLEVEL >= SUBCATS.USERLEVEL
    ORDER BY
        SUBCATS.NAME
    ;            

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetDownloadFileData` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetDownloadFileData`(__ID VARCHAR(200))
BEGIN
	SELECT * FROM ticketAttachment WHERE STOREFILENAME = __ID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetDownloadItem` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetDownloadItem`(__DOWNLOADLINK VARCHAR(100))
BEGIN

SELECT
  ITEM.*,
    OH.USERNAME
FROM
  orderDetail OD
INNER JOIN
  items ITEM ON 
    ITEM.ID = OD.ITEMID
INNER JOIN 
  orderHeader OH ON OD.ORDERID = OH.ORDERID
WHERE
  OD.DOWNLOADLINK = __DOWNLOADLINK;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetDownloadLog` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetDownloadLog`()
BEGIN
	SELECT 
		LOG.*,
        ITEM.CODE AS ITEMCODE,
        ITEM.DESCRIPTION AS ITEMDESCRIPTION
	FROM
		downloadLog LOG
	INNER JOIN
		items ITEM ON 
			LOG.ITEMID = ITEM.ID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetFaqBySearchTerm` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetFaqBySearchTerm`(__TERM VARCHAR(50),__LANG VARCHAR(2))
BEGIN

  SELECT 
    ID,
        CASE WHEN __LANG = 'EN' THEN NAMEEN ELSE NAMEFR END AS NAME 
  FROM
    faq 
  WHERE
    (
    ID = __TERM OR 
        ( __LANG = 'EN' AND NAMEEN LIKE CONCAT('%',__TERM,'%')) OR 
        ( __LANG = 'FR' AND NAMEFR LIKE CONCAT('%',__TERM,'%')) OR 
        ( __LANG = 'EN' AND CONTENTEN LIKE CONCAT('%',__TERM,'%')) OR 
        ( __LANG = 'FR' AND CONTENTFR LIKE CONCAT('%',__TERM,'%'))
    )
  ORDER BY 
    NAMEEN
  LIMIT 20;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetGeneratorBranchVariables` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetGeneratorBranchVariables`(__USERNAME VARCHAR(50))
BEGIN

SELECT
	'Param-BranchName' AS TAG,
    NAME AS TAGVALUE
FROM
	branches
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) 

UNION ALL

SELECT
	'Param-Address1' AS TAG,
    ADDRESS AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1
    
UNION ALL

SELECT
	'Param-Address1Ext' AS TAG,
    ADDRESS2 AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1    

UNION ALL

SELECT
	'Param-Address2' AS TAG,
    CONCAT(CITY,', ',PROVINCE,', ', COUNTRY, '  ', POSTALCODE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1

UNION ALL

SELECT
	'Param-City' AS TAG,
    CITY AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1
   
UNION ALL
   
SELECT
	'Param-Prov' AS TAG,
    PROVINCE AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1   
    
UNION ALL
   
SELECT
	'Param-Country' AS TAG,
    COUNTRY AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1      

UNION ALL

SELECT
	'Param-CityProvPostal' AS TAG,
    CONCAT(CITY,', ',PROVINCE,' ', POSTALCODE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1
    
UNION ALL

SELECT
	'Param-CityProv' AS TAG,
    CONCAT(CITY,', ',PROVINCE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1 
    
UNION ALL

SELECT
	'Param-Postal' AS TAG,
    POSTALCODE AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1      

UNION ALL

SELECT
	'Param-AddressAll' AS TAG,
    CONCAT(ADDRESS, ', ', CITY,', ',PROVINCE, '  ', POSTALCODE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1

UNION ALL

SELECT
	'Param-BranchPhone' AS TAG,
    PHONE AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1
    
UNION ALL

SELECT
	'Param-BranchFax' AS TAG,
    FAX AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    ISMAIN = 1    

UNION ALL
   
SELECT
	'Param-Address1EN' AS TAG,
    ADDRESS AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN'
    
UNION ALL
   
SELECT
	'Param-Address1ExtEN' AS TAG,
    ADDRESS2 AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN'    

UNION ALL

SELECT
	'Param-Address2EN' AS TAG,
    CONCAT(CITY,', ',PROVINCE,', ', COUNTRY, '  ', POSTALCODE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN' 
    
UNION ALL

SELECT
	'Param-AddressAllEN' AS TAG,
    CONCAT(ADDRESS, ', ', CITY,', ',PROVINCE, '  ', POSTALCODE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN' 

UNION ALL

SELECT
	'Param-CityEN' AS TAG,
    CITY AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN' 

UNION ALL
   
SELECT
	'Param-ProvEN' AS TAG,
    PROVINCE AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN'   
    
UNION ALL
   
SELECT
	'Param-CountryEN' AS TAG,
    COUNTRY AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN'   

UNION ALL

SELECT
	'Param-CityProvPostalEN' AS TAG,
    CONCAT(CITY,', ',PROVINCE,' ', POSTALCODE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN' 
    
UNION ALL

SELECT
	'Param-CityProvEN' AS TAG,
    CONCAT(CITY,', ',PROVINCE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN'   
    
UNION ALL

SELECT
	'Param-PostalEN' AS TAG,
    POSTALCODE AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN'      

UNION ALL

SELECT
	'Param-BranchPhoneEN' AS TAG,
    PHONE AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN'
    
UNION ALL

SELECT
	'Param-BranchFaxEN' AS TAG,
    FAX AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'EN'    

UNION ALL
   
SELECT
	'Param-Address1FR' AS TAG,
    ADDRESS AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR'
    
UNION ALL
   
SELECT
	'Param-Address1ExtFR' AS TAG,
    ADDRESS2 AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR'    

UNION ALL

SELECT
	'Param-Address2FR' AS TAG,
    CONCAT(CITY,', ',PROVINCE,', ', COUNTRY, '  ', POSTALCODE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR'    
    
UNION ALL

SELECT
	'Param-AddressAllFR' AS TAG,
    CONCAT(ADDRESS, ', ', CITY,', ',PROVINCE, '  ', POSTALCODE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR'     
 
UNION ALL

SELECT
	'Param-CityFR' AS TAG,
    CITY AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR'  

UNION ALL
   
SELECT
	'Param-ProvFR' AS TAG,
    PROVINCE AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR'   
    
UNION ALL
   
SELECT
	'Param-CountryFR' AS TAG,
    COUNTRY AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR'   
 
UNION ALL

SELECT
	'Param-CityProvPostalFR' AS TAG,
    CONCAT(CITY,', ',PROVINCE,' ', POSTALCODE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR' 
    
UNION ALL

SELECT
	'Param-CityProvFR' AS TAG,
    CONCAT(CITY,', ',PROVINCE) AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR'  
    
UNION ALL

SELECT
	'Param-PostalFR' AS TAG,
    POSTALCODE AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR'       
    
UNION ALL

SELECT
	'Param-BranchPhoneFR' AS TAG,
    PHONE AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR'
    
UNION ALL

SELECT
	'Param-BranchFaxFR' AS TAG,
    FAX AS TAGVALUE
FROM
	branchesAddresses
WHERE
	CODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME) AND
    LANGUAGE = 'FR'    

UNION ALL

SELECT
	CONCAT('Param-',TAG) AS TAG,
	VALUE
FROM
	branchesAssetData
WHERE
	BRANCHCODE IN (SELECT BRANCH FROM user WHERE USERNAME = __USERNAME);


END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetInventoryData` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetInventoryData`(__INVTYPE INT)
BEGIN

IF __INVTYPE = 1 THEN
	
	SELECT
		ITEMS.ID,
        ITEMS.CODE,
        ITEMS.DESCRIPTION,
        COALESCE(INV.QTYONHAND,0) AS STOCK,
        COALESCE(ONORDERSTAT.TOTORDERQTY,0) AS ONORDER, 
        ITEMS.MINLEVEL,
        COALESCE(DATE(ONORDERSTAT.ORDERDATE),'') AS LASTORDERED,
        COALESCE(DATE(SHIPSTAT.SHIPDATE),'') AS LASTSHIPPED,
        COALESCE(SUBCATNAME.NAME,'') AS L2CAT,
		COALESCE(SUBCATNAME1.NAME,'') AS L1CAT,
		COALESCE(CAT1.NAME,'') AS L0CAT        
	FROM
		items ITEMS
	LEFT OUTER JOIN
		itemsInventory INV ON 
			ITEMS.ID = INV.ITEMID
	LEFT OUTER JOIN
		(SELECT ITEMID, SUM(ORDERQTY-SHIPTODATEQTY) AS TOTORDERQTY, MAX(ORDERDATE) AS ORDERDATE FROM orderHeader HDR INNER JOIN orderDetail DTL ON HDR.ORDERID = DTL.ORDERID WHERE ORDERSTATUS NOT IN ('WAITMA','CART') GROUP BY ITEMID) ONORDERSTAT ON
			ONORDERSTAT.ITEMID = ITEMS.ID
	LEFT OUTER JOIN
		(SELECT ITEMID, MAX(SHIPDATE) AS SHIPDATE FROM orderHeader HDR INNER JOIN orderDetail DTL ON HDR.ORDERID = DTL.ORDERID INNER JOIN shipmentDetail SDTL ON DTL.ORDERID = SDTL.ORDERID AND DTL.ITEMLINE = SDTL.ORDERLINE INNER JOIN shipmentHeader SHDR ON SDTL.SHIPID = SHDR.SHIPID WHERE ORDERSTATUS NOT IN ('WAITMA','CART') GROUP BY ITEMID) SHIPSTAT ON
			SHIPSTAT.ITEMID = ITEMS.ID   
	LEFT OUTER JOIN 
		(SELECT ITEMID,MIN(SUBCATID) AS SUBCATID FROM itemsSubcategoryLink GROUP BY ITEMID) SUBCAT ON 
			ITEMS.ID = SUBCAT.ITEMID
	LEFT OUTER JOIN 
		subcategories SUBCATNAME ON 
			SUBCAT.SUBCATID = SUBCATNAME.SUBCATID
	LEFT OUTER JOIN 
		subcategories SUBCATNAME1 ON 
			SUBCATNAME.PARENTSUBCATID = SUBCATNAME1.SUBCATID            
	LEFT OUTER JOIN 
		categories CAT1 ON 
			SUBCATNAME.CATID = CAT1.CATID 
	;
	
ELSEIF __INVTYPE = 2 THEN 
	
	SELECT
		ITEMS.ID,
        ITEMS.CODE,
        ITEMS.DESCRIPTION,
        COALESCE(INV.QTYONHAND,0) AS STOCK,
        COALESCE(ONORDERSTAT.TOTORDERQTY,0) AS ONORDER, 
        ITEMS.MINLEVEL,
        COALESCE(DATE(ONORDERSTAT.ORDERDATE),'') AS LASTORDERED,
        COALESCE(DATE(SHIPSTAT.SHIPDATE),'') AS LASTSHIPPED,
        COALESCE(SUBCATNAME.NAME,'') AS L2CAT,
		COALESCE(SUBCATNAME1.NAME,'') AS L1CAT,
		COALESCE(CAT1.NAME,'') AS L0CAT        
	FROM
		items ITEMS
	INNER JOIN
		itemsInventory INV ON 
			ITEMS.ID = INV.ITEMID
	LEFT OUTER JOIN
		(SELECT ITEMID, SUM(ORDERQTY-SHIPTODATEQTY) AS TOTORDERQTY, MAX(ORDERDATE) AS ORDERDATE FROM orderHeader HDR INNER JOIN orderDetail DTL ON HDR.ORDERID = DTL.ORDERID WHERE ORDERSTATUS NOT IN ('WAITMA','CART') GROUP BY ITEMID) ONORDERSTAT ON
			ONORDERSTAT.ITEMID = ITEMS.ID 
	LEFT OUTER JOIN
		(SELECT ITEMID, MAX(SHIPDATE) AS SHIPDATE FROM orderHeader HDR INNER JOIN orderDetail DTL ON HDR.ORDERID = DTL.ORDERID INNER JOIN shipmentDetail SDTL ON DTL.ORDERID = SDTL.ORDERID AND DTL.ITEMLINE = SDTL.ORDERLINE INNER JOIN shipmentHeader SHDR ON SDTL.SHIPID = SHDR.SHIPID WHERE ORDERSTATUS NOT IN ('WAITMA','CART') GROUP BY ITEMID) SHIPSTAT ON
			SHIPSTAT.ITEMID = ITEMS.ID
	LEFT OUTER JOIN 
		(SELECT ITEMID,MIN(SUBCATID) AS SUBCATID FROM itemsSubcategoryLink GROUP BY ITEMID) SUBCAT ON 
			ITEMS.ID = SUBCAT.ITEMID
	LEFT OUTER JOIN 
		subcategories SUBCATNAME ON 
			SUBCAT.SUBCATID = SUBCATNAME.SUBCATID
	LEFT OUTER JOIN 
		subcategories SUBCATNAME1 ON 
			SUBCATNAME.PARENTSUBCATID = SUBCATNAME1.SUBCATID            
	LEFT OUTER JOIN 
		categories CAT1 ON 
			SUBCATNAME.CATID = CAT1.CATID             
	WHERE 
		INV.QTYONHAND > 0;
        
        
ELSEIF __INVTYPE = 3 THEN
	
	SELECT
		ITEMS.ID,
        ITEMS.CODE,
        ITEMS.DESCRIPTION,
        COALESCE(INV.QTYONHAND,0) AS STOCK,
        COALESCE(ONORDERSTAT.TOTORDERQTY,0) AS ONORDER, 
        ITEMS.MINLEVEL,
        COALESCE(DATE(ONORDERSTAT.ORDERDATE),'') AS LASTORDERED,
        COALESCE(DATE(SHIPSTAT.SHIPDATE),'') AS LASTSHIPPED,
        COALESCE(SUBCATNAME.NAME,'') AS L2CAT,
		COALESCE(SUBCATNAME1.NAME,'') AS L1CAT,
		COALESCE(CAT1.NAME,'') AS L0CAT        
	FROM
		items ITEMS
	INNER JOIN
		itemsInventory INV ON 
			ITEMS.ID = INV.ITEMID
	LEFT OUTER JOIN
		(SELECT ITEMID, SUM(ORDERQTY-SHIPTODATEQTY) AS TOTORDERQTY, MAX(ORDERDATE) AS ORDERDATE FROM orderHeader HDR INNER JOIN orderDetail DTL ON HDR.ORDERID = DTL.ORDERID WHERE ORDERSTATUS NOT IN ('WAITMA','CART') GROUP BY ITEMID) ONORDERSTAT ON
			ONORDERSTAT.ITEMID = ITEMS.ID  
	LEFT OUTER JOIN
		(SELECT ITEMID, MAX(SHIPDATE) AS SHIPDATE FROM orderHeader HDR INNER JOIN orderDetail DTL ON HDR.ORDERID = DTL.ORDERID INNER JOIN shipmentDetail SDTL ON DTL.ORDERID = SDTL.ORDERID AND DTL.ITEMLINE = SDTL.ORDERLINE INNER JOIN shipmentHeader SHDR ON SDTL.SHIPID = SHDR.SHIPID WHERE ORDERSTATUS NOT IN ('WAITMA','CART') GROUP BY ITEMID) SHIPSTAT ON
			SHIPSTAT.ITEMID = ITEMS.ID
	LEFT OUTER JOIN 
		(SELECT ITEMID,MIN(SUBCATID) AS SUBCATID FROM itemsSubcategoryLink GROUP BY ITEMID) SUBCAT ON 
			ITEMS.ID = SUBCAT.ITEMID
	LEFT OUTER JOIN 
		subcategories SUBCATNAME ON 
			SUBCAT.SUBCATID = SUBCATNAME.SUBCATID
	LEFT OUTER JOIN 
		subcategories SUBCATNAME1 ON 
			SUBCATNAME.PARENTSUBCATID = SUBCATNAME1.SUBCATID            
	LEFT OUTER JOIN 
		categories CAT1 ON 
			SUBCATNAME.CATID = CAT1.CATID             
	WHERE 
		INV.QTYONHAND <= 0;

ELSE

	
	SELECT
		ITEMS.ID,
        ITEMS.CODE,
        ITEMS.DESCRIPTION,
        COALESCE(INV.QTYONHAND,0) AS STOCK,
        COALESCE(ONORDERSTAT.TOTORDERQTY,0) AS ONORDER, 
        ITEMS.MINLEVEL,
        COALESCE(DATE(ONORDERSTAT.ORDERDATE),'') AS LASTORDERED,
        COALESCE(DATE(SHIPSTAT.SHIPDATE),'') AS LASTSHIPPED,
        COALESCE(SUBCATNAME.NAME,'') AS L2CAT,
		COALESCE(SUBCATNAME1.NAME,'') AS L1CAT,
		COALESCE(CAT1.NAME,'') AS L0CAT        
	FROM
		items ITEMS
	INNER JOIN
		itemsInventory INV ON 
			ITEMS.ID = INV.ITEMID
	LEFT OUTER JOIN
		(SELECT ITEMID, SUM(ORDERQTY-SHIPTODATEQTY) AS TOTORDERQTY, MAX(ORDERDATE) AS ORDERDATE FROM orderHeader HDR INNER JOIN orderDetail DTL ON HDR.ORDERID = DTL.ORDERID WHERE ORDERSTATUS NOT IN ('WAITMA','CART') GROUP BY ITEMID) ONORDERSTAT ON
			ONORDERSTAT.ITEMID = ITEMS.ID   
	LEFT OUTER JOIN
		(SELECT ITEMID, MAX(SHIPDATE) AS SHIPDATE FROM orderHeader HDR INNER JOIN orderDetail DTL ON HDR.ORDERID = DTL.ORDERID INNER JOIN shipmentDetail SDTL ON DTL.ORDERID = SDTL.ORDERID AND DTL.ITEMLINE = SDTL.ORDERLINE INNER JOIN shipmentHeader SHDR ON SDTL.SHIPID = SHDR.SHIPID WHERE ORDERSTATUS NOT IN ('WAITMA','CART') GROUP BY ITEMID) SHIPSTAT ON
			SHIPSTAT.ITEMID = ITEMS.ID 
	LEFT OUTER JOIN 
		(SELECT ITEMID,MIN(SUBCATID) AS SUBCATID FROM itemsSubcategoryLink GROUP BY ITEMID) SUBCAT ON 
			ITEMS.ID = SUBCAT.ITEMID
	LEFT OUTER JOIN 
		subcategories SUBCATNAME ON 
			SUBCAT.SUBCATID = SUBCATNAME.SUBCATID
	LEFT OUTER JOIN 
		subcategories SUBCATNAME1 ON 
			SUBCATNAME.PARENTSUBCATID = SUBCATNAME1.SUBCATID            
	LEFT OUTER JOIN 
		categories CAT1 ON 
			SUBCATNAME.CATID = CAT1.CATID             
	WHERE 
		INV.QTYONHAND < ITEMS.MINLEVEL;

END IF;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetInventoryMovementHistory` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetInventoryMovementHistory`(IN `__STARTDATE` DATE, IN `__ENDDATE` DATE)
BEGIN
	SELECT
		ITEM.ID,
        ITEM.CODE,
        ITEM.DESCRIPTION,
        LOG.ADJID,
        LOG.QTY,
        CAST(LOG.ADJDATE AS DATE) AS ADJDATE,
        LOG.REASON
	FROM
		items ITEM
	INNER JOIN
		itemsAdjustmentLog LOG ON 
			ITEM.ID = LOG.ITEMID
	WHERE
		LOG.ADJDATE BETWEEN __STARTDATE AND DATE_ADD(__ENDDATE,INTERVAL 1 DAY) AND
            ITEM.TYPE = 0
	ORDER BY
		ITEM.ID,
        LOG.ADJDATE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetItemBranches` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetItemBranches`(__ITEMID INT)
BEGIN
	SELECT
		*
	FROM
		itemsBranchesLink
	WHERE
		ITEMID = __ITEMID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetItemCategories` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetItemCategories`(__ITEMID INT)
BEGIN
	SELECT
		*
	FROM
		itemsSubcategoryLink
	WHERE
		ITEMID = __ITEMID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetItemData` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetItemData`(__ITEMID INT)
BEGIN
	SELECT * FROM items WHERE ID = __ITEMID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetItemDataByConfirmCode` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetItemDataByConfirmCode`(__CODE VARCHAR(200))
BEGIN
	SELECT * FROM items WHERE APPROVALLINK = __CODE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetItemPricing` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetItemPricing`(__ITEMID INT)
BEGIN


	SELECT
		*,
        ROUND((LENGTH*WIDTH*HEIGHT)/172 * PIECES,0) AS DIMWEIGHT
	FROM
		itemPricing
	WHERE
		ITEMID = __ITEMID
	ORDER BY 
		CASE WHEN QTY = -2 THEN 9999 ELSE QTY END;  
        
        
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetItemsBySearchTerm` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetItemsBySearchTerm`(__TERM VARCHAR(50))
BEGIN

SELECT
	ID,
    CONCAT(CODE, ' - ', DESCRIPTION) AS ITEMNAME
FROM
	items
WHERE
	(
	CODE LIKE CONCAT('%',__TERM,'%') OR 
    DESCRIPTION LIKE CONCAT('%',__TERM,'%')
    ) AND
    TYPE NOT IN (3)
ORDER BY 
	CODE,DESCRIPTION
LIMIT 20;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetItemZonePricing` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetItemZonePricing`(__ITEMID INT, __QTY INT, __BRANCH VARCHAR(20), __ITEMOPTION VARCHAR(30))
BEGIN

 SET @BRANCHZONE := (SELECT SHIPZONE FROM branches WHERE CODE = __BRANCH);
 SET @ITEMWEIGHT := (SELECT CASE WHEN ROUND((LENGTH*WIDTH*HEIGHT)/172 * PIECES,0) > WEIGHT THEN ROUND((LENGTH*WIDTH*HEIGHT)/172 * PIECES,0) ELSE WEIGHT END AS WEIGHT FROM itemPricing WHERE ITEMID = __ITEMID AND (QTY = __QTY OR QTY = -1 OR QTY = -2) AND ITEMOPTION = __ITEMOPTION ORDER BY QTY DESC LIMIT 1);

 SELECT
 @BRANCHZONE AS BRANCHZONE,
		ZONECOSTS.*
	FROM
		shipZoneCosts ZONECOSTS
	WHERE
		ZONECOSTS.WEIGHT <= @ITEMWEIGHT
	ORDER BY
		WEIGHT DESC;	

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetNewsItem` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetNewsItem`(__ID INTEGER)
BEGIN
	SELECT * FROM newsItems WHERE ID = __ID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetOrderDataForShipment` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetOrderDataForShipment`(__ORDERID INT)
BEGIN
	SELECT
		HDR.*,
        DTL.*,
        ITEM.*,
        DATE(ORDERDATE) AS FMTORDERDATE,
        DATE(EXPDATE) AS FMTEXPDATE,
		USER.FIRSTNAME AS USER_FIRSTNAME,
		USER.LASTNAME AS USER_LASTNAME,
		USER.EMAIL AS USER_EMAIL,
		USER.LANGUAGE AS USER_LANGUAGE
	FROM
		orderHeader HDR
	INNER JOIN
		orderDetail DTL ON 
			HDR.ORDERID = DTL.ORDERID
	LEFT OUTER JOIN
		items ITEM ON 
			DTL.ITEMID = ITEM.ID
	INNER JOIN
		user USER ON 
			HDR.USERNAME = USER.USERNAME            
	WHERE 
		HDR.ORDERID = __ORDERID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetOrderInformationForEmail` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetOrderInformationForEmail`(__USERNAME VARCHAR(100), __ORDERID INT)
BEGIN

SELECT
	HDR.*,
    DTL.*,
    ITEM.TYPE,
    USER.FIRSTNAME AS USER_FIRSTNAME,
    USER.LASTNAME AS USER_LASTNAME,
    USER.EMAIL AS USER_EMAIL,
    USER.LANGUAGE AS USER_LANGUAGE,
    BRANCH.NAME AS BRANCH_NAME,
    BRANCH.MANAGEMENTEMAIL AS BRANCH_MANAGEMENTEMAIL,
    COALESCE(BRANCHADDRESS.LANGUAGE,'EN') AS BRANCH_LANGUAGE,
    ORDERSTATUS AS REALSTATUS
FROM
	orderHeader HDR
INNER JOIN
	orderDetail DTL ON 
		HDR.ORDERID = DTL.ORDERID
INNER JOIN
	items ITEM ON 
		DTL.ITEMID = ITEM.ID
INNER JOIN
	user USER ON 
		HDR.USERNAME = USER.USERNAME
INNER JOIN
	branches BRANCH ON 
		USER.BRANCH = BRANCH.CODE
LEFT OUTER JOIN
	(SELECT * FROM branchesAddresses WHERE ISMAIN = 1) BRANCHADDRESS ON 
		BRANCH.CODE = BRANCHADDRESS.CODE
WHERE 
	HDR.USERNAME = __USERNAME AND 
    HDR.ORDERID = __ORDERID;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetPaypalPaymentInformation` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetPaypalPaymentInformation`(__USERNAME VARCHAR(100))
BEGIN

SELECT
	HDR.ORDERID,
	SHIPCONTACTFIRSTNAME AS FIRSTNAME,
    SHIPCONTACTLASTNAME AS LASTNAME,
    SHIPCONTACTEMAIL AS EMAIL,
    SPECIALINSTRUCTIONS AS SPECINSTR,
    RECEIVERINSTRUCTIONS AS RECINSTR,
    SHIPPINGMETHOD AS SHIPPINGMETHOD,
    SHIPPINGCOST AS SHIPPINGCOST,
	SHIPNAME AS SHIPNAME,
    BILLINGCATEGORY AS BILLINGCATEGORY,
    PONUMBER AS PONUMBER,
    ROUND(COALESCE(PROMODISC,0)+COALESCE(ITEMTOT,0)+SHIPPINGCOST+SHIPPINGCOSTTAXAMT1+SHIPPINGCOSTTAXAMT2+SHIPPINGCOSTTAXAMT3+SHIPPINGCOSTTAXAMT4+SHIPPINGCOSTTAXAMT5,2) AS AMT
FROM
	orderHeader HDR
INNER JOIN
	( SELECT ORDERID,SUM(EXTPRICE+TAXAMT1+TAXAMT2+TAXAMT3+TAXAMT4+TAXAMT5) AS ITEMTOT FROM orderDetail GROUP BY ORDERID) DTL ON 
		HDR.ORDERID = DTL.ORDERID
LEFT OUTER JOIN
	( SELECT ORDERID,SUM(CALCDISCOUNT+TAXAMT1+TAXAMT2+TAXAMT3+TAXAMT4+TAXAMT5) AS PROMODISC FROM 
      orderPromos GROUP BY ORDERID ) PROMOS ON 
		HDR.ORDERID = PROMOS.ORDERID
WHERE 
	USERNAME  = __USERNAME AND 
    ORDERSTATUS = 'CART';
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetPendingOrders` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetPendingOrders`(__USERNAME VARCHAR(20))
BEGIN

	SELECT
		HDR.*,
        CAST(HDR.ORDERDATE AS DATE) AS SHORTDATE,
        DTL.TOTAMT+HDR.SHIPPINGCOST+HDR.SHIPPINGCOSTTAXAMT1+HDR.SHIPPINGCOSTTAXAMT2+HDR.SHIPPINGCOSTTAXAMT3+HDR.SHIPPINGCOSTTAXAMT4+HDR.SHIPPINGCOSTTAXAMT5 AS ORDERAMOUNT
	FROM
		orderHeader HDR
	INNER JOIN
		(SELECT ORDERID, SUM(EXTPRICE+TAXAMT1+TAXAMT2+TAXAMT3+TAXAMT4+TAXAMT5) AS TOTAMT FROM orderDetail GROUP BY ORDERID) DTL ON 
			HDR.ORDERID = DTL.ORDERID
	WHERE
		USERNAME = __USERNAME AND
        ORDERSTATUS IN ('WAITMA');
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetPromoProfile` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetPromoProfile`(__CODE VARCHAR(50))
BEGIN
	SELECT * FROM promos WHERE CODE = __CODE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetPromoProfileCategories` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetPromoProfileCategories`(__CODE VARCHAR(50))
BEGIN

  SELECT
    PROMOS.CATID,
        CONCAT(CATS.NAME, ' - ', CATS.DESCRIPTION) AS CATNAME
  FROM
    promosCategories PROMOS
  INNER JOIN 
    categories CATS ON 
      PROMOS.CATID = CATS.CATID
  WHERE
    PROMOS.CODE = __CODE;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetPromoProfileItems` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetPromoProfileItems`(__CODE VARCHAR(50))
BEGIN
	SELECT 
		PROMOS.ITEMID,
		CONCAT(ITEMS.CODE,' - ',DESCRIPTION) AS ITEMNAME
	FROM 
		promosItems PROMOS
	INNER JOIN 
		items ITEMS ON 
			PROMOS.ITEMID = ITEMS.ID
	WHERE 
		PROMOS.CODE = __CODE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetSearchItems` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetSearchItems`(__USERNAME VARCHAR(50), __TERM NVARCHAR(200))
BEGIN
    SELECT DISTINCT
        ITEMS.ID AS ITEMID,
        ITEMS.CODE AS ITEMCODE,
        ITEMS.DESCRIPTION AS ITEMDESC,
        ITEMS.DISPLAYIMAGEPATH,
        ITEMS.PROOFPDFNAME,
        ITEMS.SIZE,
        ITEMS.NUMPAGES,
        ITEMS.MINLEVEL,
        ITEMS.STATUS,
        ITEMS.TYPE AS ITEMTYPE,
        COALESCE(ONORDERSTAT.TOTORDERQTY,0) AS ONORDER, 
        COALESCE(DATE(ONORDERSTAT.ORDERDATE),'') AS LASTORDERED,
        COALESCE(ITEMINV.QTYONHAND,0) AS INSTOCK,
        MIN(SUBCATS.CATID) AS CATID,
        MIN(SUBCATS.SUBCATID) AS SUBCATID
    FROM
        categories CATS
    LEFT OUTER JOIN
        subcategories SUBCATS ON 
            CATS.CATID = SUBCATS.CATID
    LEFT OUTER JOIN
        itemsSubcategoryLink SCTOI ON
            SCTOI.SUBCATID = SUBCATS.SUBCATID
    LEFT OUTER JOIN
        items ITEMS ON 
            ITEMS.ID = SCTOI.ITEMID
    LEFT OUTER JOIN
        (SELECT ITEMID, SUM(CASE WHEN ORDERQTY-SHIPTODATEQTY < 0 THEN 0 ELSE ORDERQTY-SHIPTODATEQTY END) AS TOTORDERQTY, MAX(ORDERDATE) AS ORDERDATE FROM orderHeader HDR INNER JOIN orderDetail DTL ON HDR.ORDERID = DTL.ORDERID WHERE ORDERSTATUS NOT IN ('WAITMA','CART','CANCELLED') GROUP BY ITEMID) ONORDERSTAT ON
            ONORDERSTAT.ITEMID = SCTOI.ITEMID  
    LEFT OUTER JOIN
        itemsInventory ITEMINV ON 
            ITEMS.ID = ITEMINV.ITEMID
    INNER JOIN 
        (SELECT DISTINCT 
            ITEMID 
         FROM
            (
                SELECT 
                    ITOB.ITEMID 
                FROM 
                    user USERS 
                INNER JOIN 
                    itemsBranchesLink ITOB ON USERS.BRANCH = ITOB.BRANCHCODE 
                WHERE 
                    USERS.USERNAME = __USERNAME
                    
                UNION ALL 
                SELECT ITOB.ITEMID FROM itemsBranchesLink ITOB WHERE ITOB.BRANCHCODE = 'ALL_BRANCHES'
                
                UNION ALL
                SELECT ITOB.ITEMID FROM user UU INNER JOIN branches BB ON UU.BRANCH = BB.CODE
                INNER JOIN itemsBranchesLink ITOB ON CONCAT('BRN_',BB.SKIN) = ITOB.BRANCHCODE 
                WHERE UU.USERNAME = __USERNAME                
            ) LINKS
        )  BRANCHLINK ON 
                BRANCHLINK.ITEMID = ITEMS.ID  
    CROSS JOIN
        ( SELECT * FROM user WHERE USERNAME = __USERNAME) USERS                        
    WHERE
        (
            ITEMS.CODE COLLATE utf8_unicode_ci LIKE CONCAT('%',__TERM,'%') OR 
            ITEMS.DESCRIPTION COLLATE utf8_unicode_ci LIKE CONCAT('%',__TERM,'%')
        ) AND 
        ITEMS.ARCHIVED = 0 AND
        ITEMS.ASSETAPPROVED = 1 AND
        CATS.CATID IN (
                        SELECT CC.CATID 
                        FROM categories CC 
                        INNER JOIN categoriesBrand CCC ON CC.CATID = CCC.CATID
                        INNER JOIN ( SELECT SKIN FROM branches BB INNER JOIN user UU ON BB.CODE = UU.BRANCH WHERE USERNAME COLLATE utf8_unicode_ci = __USERNAME) UBS ON 
                            (UBS.SKIN = CCC.BRANDNAME OR CCC.BRANDNAME = 'ALL')
                            ) AND
        CATS.USERLEVEL <= COALESCE((SELECT USERLEVEL FROM user WHERE USERNAME = __USERNAME LIMIT 1),0) AND
        USERS.USERLEVEL >= SUBCATS.USERLEVEL
    GROUP BY
        ITEMS.ID ,
        ITEMS.CODE ,
        ITEMS.DESCRIPTION ,
        ITEMS.DISPLAYIMAGEPATH,
        ITEMS.PROOFPDFNAME,
        ITEMS.SIZE,
        ITEMS.NUMPAGES,
        ITEMS.MINLEVEL,
        ITEMS.STATUS,
        ITEMS.TYPE ,
        COALESCE(ONORDERSTAT.TOTORDERQTY,0) , 
        COALESCE(DATE(ONORDERSTAT.ORDERDATE),'') ,
        COALESCE(ITEMINV.QTYONHAND,0) 
    ORDER BY
        ITEMS.CODE
    ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetSettingsValue` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetSettingsValue`(SETTING_KEY VARCHAR(100))
BEGIN
	SELECT 
		*
	FROM
		settings
	WHERE
		`KEY` = SETTING_KEY;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetShipmentInfo` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetShipmentInfo`(__SHIPID INT)
BEGIN

	SELECT
		SHIPHDR.*,
        SHIPDTL.*,
        ORDHDR.*,
        ORDDTL.*,
        ORDDTL.ORDERQTY - ORDDTL.SHIPTODATEQTY AS BOQTY,
		USER.EMAIL AS USER_EMAIL,
		USER.LANGUAGE AS USER_LANGUAGE,
		BRANCH.MANAGEMENTEMAIL AS BRANCH_MANAGEMENTEMAIL,
		COALESCE(BRANCHADDRESS.LANGUAGE,'EN') AS BRANCH_LANGUAGE,
        ITEM.TYPE
	FROM
		shipmentHeader SHIPHDR
	INNER JOIN
		shipmentDetail SHIPDTL ON
			SHIPHDR.SHIPID = SHIPDTL.SHIPID
	INNER JOIN
		orderDetail ORDDTL ON 
			SHIPDTL.ORDERID = ORDDTL.ORDERID AND
            SHIPDTL.ORDERLINE = ORDDTL.ITEMLINE
	INNER JOIN
		items ITEM ON 
			ORDDTL.ITEMID = ITEM.ID
	INNER JOIN
		orderHeader ORDHDR ON 
			SHIPHDR.ORDERID = ORDHDR.ORDERID 
	INNER JOIN
		user USER ON 
			ORDHDR.USERNAME = USER.USERNAME 
	INNER JOIN
		branches BRANCH ON 
			USER.BRANCH = BRANCH.CODE 
	LEFT OUTER JOIN
		(SELECT * FROM branchesAddresses WHERE ISMAIN = 1) BRANCHADDRESS ON 
			BRANCH.CODE = BRANCHADDRESS.CODE
	WHERE
		SHIPHDR.SHIPID = __SHIPID;            

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetShipToAddress` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetShipToAddress`(__ID VARCHAR(50), __USEBRANCHES BOOLEAN)
BEGIN
	SELECT
		NAME,ADDRESS,ADDRESS2,CITY,PROVINCE,COUNTRY,POSTAL,PHONE,FAX
	FROM
    (
	SELECT
		'S' AS RECTYPE,ID,NAME,ADDRESS,ADDRESS2,CITY,PROVINCE,COUNTRY,POSTAL,PHONE,FAX
	FROM
		shipToAddresses
        
	UNION ALL
    
    SELECT
		'B' AS RECTYPE,BRANCH.CODE,NAME,ADDRESS,ADDRESS2,CITY,PROVINCE,COUNTRY,POSTALCODE,PHONE,FAX
    FROM
		branches BRANCH
	INNER JOIN
		branchesAddresses BADDR ON 
			BRANCH.CODE = BADDR.CODE
	WHERE
		__USEBRANCHES = 1 AND
        BRANCH.STATUS = 1 AND
        BADDR.ISMAIN = 1
    ) ADDR
    WHERE
		CONCAT(ADDR.RECTYPE,'-',ADDR.ID) = __ID
    ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetShipToAddressInformation` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetShipToAddressInformation`(__ID INT)
BEGIN

	SELECT
		*
	FROM
		shipToAddresses
	WHERE
		ID = __ID;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetShipToAddressUsersList` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetShipToAddressUsersList`(__SHIPTOID INT)
BEGIN
	SELECT 
		USERS.USERNAME,
		USERS.FIRSTNAME,
		USERS.LASTNAME,
		CASE WHEN USERADDR.ID IS NOT NULL THEN 1 ELSE 0 END AS SELECTED
	FROM
		( SELECT 'ALL' AS USERNAME, 'All' AS FIRSTNAME, 'Users' AS LASTNAME UNION ALL
          SELECT USERNAME,FIRSTNAME,LASTNAME FROM user
        ) USERS 
	LEFT OUTER JOIN 
		(SELECT * FROM shipToAddressesUserList WHERE ID = __SHIPTOID) USERADDR ON 
			USERS.USERNAME = USERADDR.USERNAME
	ORDER BY 
		USERS.USERNAME;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetShipTosBySearchTerm` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetShipTosBySearchTerm`(__USEBRANCHES BOOLEAN, __TERM VARCHAR(50), __USERNAME VARCHAR(30))
BEGIN

	SELECT
		CONCAT(RECTYPE,'-',ID) AS ID,
        CONCAT(NAME, ' - ', ADDRESS) AS SHIPDESC
	FROM
    (
	SELECT
		'S' AS RECTYPE,
        ID, 
        NAME,
        ADDRESS,
        ADDRESS2,
        CITY,
        POSTAL AS POSTALCODE,        
        CASE WHEN IFNULL(STOREID,'') = '' THEN 'NA' ELSE STOREID END AS STOREID
	FROM
		shipToAddresses
	WHERE
		ID IN (SELECT ID FROM shipToAddressesUserList WHERE USERNAME = '**ALL**' OR USERNAME = __USERNAME) 
        
	UNION ALL
    
    SELECT
		'B' AS RECTYPE,
        BRANCH.CODE,
        BRANCH.NAME,
        BADDR.ADDRESS,
        BADDR.ADDRESS2,
        BADDR.CITY,
        BADDR.POSTALCODE,
        BRANCH.CODE AS STOREID
    FROM
		branches BRANCH
	INNER JOIN
		branchesAddresses BADDR ON 
			BRANCH.CODE = BADDR.CODE
	WHERE
		__USEBRANCHES = 1 AND
        BRANCH.STATUS = 1 AND
        BADDR.ISMAIN = 1
    ) ADDR
    WHERE
	(
	ADDR.NAME LIKE CONCAT('%',__TERM,'%') OR 
    ADDR.ADDRESS LIKE CONCAT('%',__TERM,'%') OR
    ADDR.ADDRESS2 LIKE CONCAT('%',__TERM,'%') OR
    ADDR.CITY LIKE CONCAT('%',__TERM,'%') OR
    ADDR.POSTALCODE LIKE CONCAT('%',__TERM,'%') OR 
    ADDR.STOREID LIKE CONCAT('%',__TERM,'%')
    ) 
    ORDER BY
		NAME;	

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetSkinOptions` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetSkinOptions`()
BEGIN
	SELECT
		*
	FROM
		branchSkinDefinition
	ORDER BY
		SKINNAME;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetSubCategoryInformation` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetSubCategoryInformation`(__SUBCATID INTEGER)
BEGIN
	SELECT * FROM subcategories WHERE SUBCATID = __SUBCATID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetSupportTicketAttachments` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetSupportTicketAttachments`(__TICKETID INT)
BEGIN
	SELECT * FROM ticketAttachment WHERE TICKETID = __TICKETID ORDER BY
    ID;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetSupportTicketData` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetSupportTicketData`(__TICKETID INT, __USERNAME VARCHAR(50))
BEGIN

	SELECT
	HDR.TITLE,
	HDR.STATUS,
		DTL.*,
        USR.FIRSTNAME,
        USR.LASTNAME,
        UNIX_TIMESTAMP(DTL.DATEENTERED) AS UNIX_DATEENTERED
	FROM
		ticketHeader HDR
	INNER JOIN
		ticketDetail DTL ON 
			HDR.ID = DTL.TICKETID
	LEFT OUTER JOIN
		user USR ON 
			DTL.ENTEREDBY = USR.USERNAME
	WHERE
        ( HDR.ENTEREDBY = __USERNAME OR __USERNAME IN (SELECT USERNAME FROM user WHERE USERLEVEL >= 81)) AND
        ( DTL.TICKETID = __TICKETID )
	ORDER BY
		DTL.DATEENTERED DESC;
		

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetSupportTicketList` */;
DELIMITER ;;
CREATE DEFINER=`admin`@`localhost` PROCEDURE `GetSupportTicketList`(__USERNAME VARCHAR(50))
BEGIN

	SELECT
		*,
        UNIX_TIMESTAMP(HDR.DATEENTERED) AS UNIX_DATEENTERED
	FROM
		ticketHeader HDR
	WHERE
		( HDR.STATUS = 1 OR (HDR.STATUS = 0 AND DATECLOSED >= DATE_ADD(NOW(), INTERVAL -14 DAY)) ) AND
        ( HDR.ENTEREDBY = __USERNAME OR __USERNAME IN (SELECT USERNAME FROM user WHERE USERLEVEL >= 81))
	ORDER BY
		HDR.STATUS DESC,
		HDR.DATEENTERED DESC;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetTaxRecords` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetTaxRecords`()
BEGIN
	SELECT * FROM taxes;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `GetUserBranchAssets` */;
