/**
 * Incident Ticket System
 */
CREATE TABLE `wbticket` (
  `ticid` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `obscure` char(4) NOT NULL DEFAULT '',
  `status` enum('new','trash','assigned','waitforstaff','waitforcustomer','solved','closed','paused') NOT NULL DEFAULT 'new',
  `assigneduid` int(11) unsigned NOT NULL DEFAULT '0',
  `scopeid` int(11) unsigned NOT NULL DEFAULT '0',
  `ticresid` int(11) unsigned NOT NULL DEFAULT '0',
  `namespace` char(25) NOT NULL DEFAULT '',
  `deadline` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `title` varchar(255) NOT NULL DEFAULT '',
  `blurb` text NOT NULL,
  `lang` char(5) NOT NULL DEFAULT 'de_DE',
  `created` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `changed` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `statuschanged` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `deleted` tinyint(4) NOT NULL DEFAULT '0',
  `uid` int(11) unsigned NOT NULL DEFAULT '0',
  `customeruid` int(11) unsigned NOT NULL DEFAULT '0',
  `customeremailurlid` int(11) unsigned NOT NULL DEFAULT '0',
  `customerforename` varchar(255) NOT NULL DEFAULT '',
  `customersurname` varchar(255) NOT NULL DEFAULT '',
  `customername` varchar(255) NOT NULL DEFAULT '',
  `customerphone` varchar(255) NOT NULL DEFAULT '',
  `serial` varchar(255) NOT NULL DEFAULT '',
  `orderdate` datetime NOT NULL DEFAULT '2000-01-01 00:00:00',
  `orderno` varchar(255) NOT NULL DEFAULT '',
  `reference` int(11) unsigned NOT NULL DEFAULT '0',
  `company` varchar(255) NOT NULL DEFAULT '',
  `street` varchar(255) NOT NULL DEFAULT '',
  `city` varchar(255) NOT NULL DEFAULT '',
  `zip` varchar(256) NOT NULL DEFAULT '',
  `country` char(2) NOT NULL DEFAULT 'C',
  `newsletter` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ticid`),
  KEY `status` (`status`),
  KEY `assigneduid` (`assigneduid`),
  KEY `namespace` (`namespace`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='Ticket system: tickets';
 
CREATE TABLE `wbticketmedia` (
  `ticid` int(11) unsigned NOT NULL,
  `vfsfid` int(11) unsigned NOT NULL,
  KEY `ticid` (`ticid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Ticket system: media files of ticket';

CREATE TABLE wbticketwatcher (
    `ticid` int(11) unsigned NOT NULL DEFAULT 0,
    `uid` int(11) unsigned NOT NULL DEFAULT 0,
    KEY (ticid),
    KEY (uid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Ticket system: users watching tickets';

 CREATE TABLE `wbticketscope` (
  `scopeid` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `title` varchar(255) NOT NULL DEFAULT '',
  `blurb` text NOT NULL DEFAULT "",
  `deleted` tinyint(4) unsigned NOT NULL DEFAULT 0
  PRIMARY KEY (`scopeid`)
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COMMENT='Ticket system: Available ticket scopes';

CREATE TABLE wbticketscopeuser (
    scopeid int(11) unsigned NOT NULL DEFAULT 0,
    uid int(11) unsigned NOT NULL DEFAULT 0,
    KEY (uid),
    KEY (scopeid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Ticket system: Map users to ticket scopes' ;

CREATE TABLE `wbticketreason` (
  `ticresid` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `reason` varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (`ticresid`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='Ticket system: Reasons for tickets';


