/**
 * shop tables
 *
 *
 */

/*
 * shop articles
 */

CREATE TABLE `wbshoparticle` (
    `said` int(11) UNSIGNED NOT NULL auto_increment
     , sacid int(11) UNSIGNED NOT NULL DEFAULT 0
     , rate DECIMAL(6,2) NOT NULL DEFAULT 0
     , unit ENUM('', 'pcs') NOT NULL DEFAULT 'pcs'
     , minquantity SMALLINT(11) UNSIGNED NOT NULL DEFAULT 1
     , tradename VARCHAR(200) NOT NULL DEFAULT ''
     , vfsfid INT(11) UNSIGNED NOT NULL DEFAULT 0 -- Thumbnail VFS media fila
     , brief VARCHAR(255) NOT NULL DEFAULT ''
     , blurb TEXT NOT NULL DEFAULT ''
     , state ENUM('', 'new') NOT NULL DEFAULT ''
     , availability ENUM('instock', 'soldout', 'datefrom', 'datebetween', 'dateto') NOT NULL DEFAULT 'instock'
     , availabilitystart DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'
     , availabilityend DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'
     , changed DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'
     , created DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'
     , enabled tinyint(1) NOT NULL DEFAULT 1
     , deleted tinyint(1) NOT NULL DEFAULT 0
     , PRIMARY KEY said (said)
     , KEY tradename (tradename)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='articles in shop';

CREATE TABLE `wbshoparticlemultiplier` (
    `said` int(11) UNSIGNED NOT NULL
    , multiplier VARCHAR(200) NOT NULL DEFAULT ''
    , factor SMALLINT(11) UNSIGNED NOT NULL DEFAULT 1
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='article quantity multiplier for ordering';


/*
 * shop article media references
 */
CREATE TABLE `wbshoparticlemedia` (
    `said` INT(11) UNSIGNED NOT NULL
     , vfsfid INT(11) UNSIGNED NOT NULL DEFAULT 0 -- VFS media fila
     , KEY `said` (`said`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='shop article media references';


/*
 * shopping cart
 */
CREATE TABLE `wbshopcart` (
  `scid` int(11) UNSIGNED NOT NULL auto_increment
  , `uid` int(11) UNSIGNED NOT NULL
  , `title` varchar(255) NOT NULL default ''
  , `note` text NOT NULL DEFAULT ''
  , `created` datetime NOT NULL default '0000-00-00 00:00:00'
  , `changed` datetime NOT NULL
  , `status` ENUM('saved', 'active', 'ordered', 'postponed', 'verified', 'prepared', 'shipped', 'canceled', 'done') NOT NULL default 'saved'
  , `deleted` tinyint(1) NOT NULL default 0
  , PRIMARY KEY  (`scid`)
  , KEY ( `uid` )
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='shopping cart';


/*
 * items in shoppging cart
 */
CREATE TABLE `wbshopcartitem` (
  `scid` int(11) UNSIGNED NOT NULL
  , `said` int(11) UNSIGNED NOT NULL
  , `comment` text NOT NULL DEFAULT ''
  , `created` datetime NOT NULL default '0000-00-00 00:00:00'
  , `quantity` int(11) NOT NULL default 1
  , PRIMARY KEY ( scid, said )
  , KEY ( `scid` )
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='items shopping cart';

