-- DROP TABLE IF EXISTS `crm_address`;
CREATE TABLE IF NOT EXISTS `crm_address` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `objectType` char(30) NOT NULL,
  `objectID` mediumint(8) unsigned NOT NULL,
  `title` varchar(255) NOT NULL,
  `area` mediumint(8) unsigned NOT NULL,
  `location` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `objectType` (`objectType`,`objectID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_contact`;
CREATE TABLE IF NOT EXISTS `crm_contact` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `realname` char(30) NOT NULL DEFAULT '',
  `nickname` char(30) NOT NULL,
  `resume` mediumint(8) unsigned NOT NULL,
  `origin` varchar(150) NOT NULL,
  `originAccount` varchar(255) NOT NULL,
  `status` enum('normal','wait','ignore') NOT NULL DEFAULT 'normal',
  `subStatus` varchar(30) NOT NULL,
  `avatar` varchar(255) NOT NULL,
  `birthday` date NOT NULL default '0000-00-00',
  `gender` enum('f','m','u') NOT NULL DEFAULT 'u',
  `email` char(50) NOT NULL DEFAULT '',
  `skype` char(50) NOT NULL,
  `qq` char(20) NOT NULL DEFAULT '',
  `yahoo` char(50) NOT NULL DEFAULT '',
  `gtalk` char(50) NOT NULL DEFAULT '',
  `wangwang` char(50) NOT NULL DEFAULT '',
  `site` varchar(100) NOT NULL,
  `mobile` char(11) NOT NULL DEFAULT '',
  `phone` char(20) NOT NULL DEFAULT '',
  `company` varchar(255) NOT NULL,
  `fax` char(20) NOT NULL DEFAULT '',
  `weibo` char(50) NOT NULL,
  `weixin` char(50) NOT NULL,
  `desc` text NOT NULL,
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `assignedTo` char(30) NOT NULL,
  `assignedBy` char(30) NOT NULL,
  `assignedDate` datetime NOT NULL,
  `ignoredBy` char(30) NOT NULL,
  `ignoredDate` datetime NOT NULL,
  `contactedBy` char(30) NOT NULL,
  `contactedDate` datetime NOT NULL,
  `nextDate` date NOT NULL,
  `deleted` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `realname` (`realname`),
  KEY `nickname` (`nickname`),
  KEY `origin` (`origin`),
  KEY `birthday` (`birthday`),
  KEY `email` (`email`),
  KEY `qq` (`qq`),
  KEY `mobile` (`mobile`),
  KEY `phone` (`phone`),
  KEY `createdBy` (`createdBy`),
  KEY `contactedBy` (`contactedBy`),
  KEY `contactedDate` (`contactedDate`),
  KEY `nextDate` (`nextDate`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_delivery`;
CREATE TABLE IF NOT EXISTS `crm_delivery` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `contract` mediumint(8) unsigned NOT NULL,
  `deliveredBy` char(30) COLLATE 'utf8_general_ci' NOT NULL,
  `deliveredDate` date NOT NULL,
  `comment` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `contract` (`contract`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_plan`;
CREATE TABLE IF NOT EXISTS `crm_plan` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `trade` mediumint(8) unsigned NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `contract` mediumint(8) unsigned NOT NULL,
  `returnedBy` char(30) COLLATE 'utf8_general_ci' NOT NULL,
  `returnedDate` date NOT NULL,
  PRIMARY KEY (`id`),
  KEY `contract` (`contract`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_contract`;
CREATE TABLE IF NOT EXISTS `crm_contract` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `dept` mediumint(8) unsigned NOT NULL,
  `type` enum('sale', 'purchase') NOT NULL DEFAULT 'sale',
  `customer` mediumint(8) unsigned NOT NULL,
  `name` char(100) NOT NULL,
  `code` char(30) NOT NULL,
  `product` char(255) NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `items` text NOT NULL,
  `begin` date NOT NULL,
  `end` date NOT NULL,
  `delivery` char(30) NOT NULL,
  `return` char(30) NOT NULL,
  `currency` varchar(20) NOT NULL,
  `status` enum('normal', 'closed', 'canceled') NOT NULL DEFAULT 'normal',
  `subStatus` varchar(30) NOT NULL,
  `contact` mediumint(8) unsigned NOT NULL,
  `address` mediumint(8) unsigned NOT NULL,
  `handlers` varchar(255) NOT NULL,
  `signType` varchar(30) NOT NULL,
  `signedBy` char(30) NOT NULL,
  `signedDate` date NOT NULL,
  `deliveredBy` char(30) COLLATE 'utf8_general_ci' NOT NULL,
  `deliveredDate` date NOT NULL,
  `returnedBy` char(30) COLLATE 'utf8_general_ci' NOT NULL,
  `returnedDate` date NOT NULL,
  `finishedBy` char(30) NOT NULL,
  `finishedDate` date NOT NULL,
  `canceledBy` char(30) NOT NULL,
  `canceledDate` date NOT NULL,
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `contactedBy` char(30) NOT NULL,
  `contactedDate` datetime NOT NULL,
  `nextDate` date NOT NULL,
  `scanFile` tinyint(1) NOT NULL DEFAULT 0,
  `inspectFile` tinyint(1) NOT NULL DEFAULT 0,
  `deleted` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `customer` (`customer`),
  KEY `amount` (`amount`),
  KEY `delivery` (`delivery`),
  KEY `return` (`return`),
  KEY `begin` (`begin`),
  KEY `end` (`end`),
  KEY `status` (`status`),
  KEY `handlers` (`handlers`),
  KEY `contactedDate` (`contactedDate`),
  KEY `nextDate` (`nextDate`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_contractorder`;
CREATE TABLE IF NOT EXISTS `crm_contractorder` (
  `contract` mediumint(8) unsigned NOT NULL,
  `order` mediumint(8) unsigned NOT NULL,
  UNIQUE KEY `contract` (`contract`,`order`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_customer`;
CREATE TABLE IF NOT EXISTS `crm_customer` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `name` char(100) NOT NULL,
  `type` char(30) NOT NULL,
  `relation` enum('client', 'provider', 'partner') NOT NULL default 'client',
  `sourceType` varchar(30) NOT NULL,
  `source` varchar(20) NOT NULL,
  `sourceNote` varchar(255) NOT NULL,
  `size` tinyint(3) unsigned NOT NULL,
  `industry` mediumint(8) unsigned NOT NULL,
  `area` mediumint(8) unsigned NOT NULL,
  `status` char(30) NOT NULL,
  `subStatus` varchar(30) NOT NULL,
  `level` char(10) NOT NULL,
  `intension` text NOT NULL,
  `site` varchar(100) NOT NULL,
  `weibo` char(50) NOT NULL,
  `weixin` char(50) NOT NULL,
  `CSM` char(30) NOT NULL,
  `category` mediumint(8) NOT NULL,
  `depositor` varchar(100) NOT NULL,
  `desc` text NOT NULL,
  `public` enum('0', '1') NOT NULL DEFAULT '0',
  `recommendationRate` char(2) NOT NULL,
  `stage` varchar(30) NOT NULL,
  `paymentIntention` varchar(10) NOT NULL,
  `health` varchar(10) NOT NULL,
  `renewalIntention` varchar(10) NOT NULL,
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `assignedTo` char(30) NOT NULL,
  `assignedBy` char(30) NOT NULL,
  `assignedDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `contactedBy` char(30) NOT NULL,
  `contactedDate` datetime NOT NULL,
  `nextDate` date NOT NULL,
  `deleted` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `industry` (`industry`),
  KEY `size` (`size`),
  KEY `name` (`name`),
  KEY `type` (`type`),
  KEY `relation` (`relation`),
  KEY `area` (`area`),
  KEY `status` (`status`),
  KEY `level` (`level`),
  KEY `category` (`category`),
  KEY `public` (`public`),
  KEY `assignedTo` (`assignedTo`),
  KEY `contactedDate` (`contactedDate`),
  KEY `nextDate` (`nextDate`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_order`;
CREATE TABLE IF NOT EXISTS `crm_order` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `product` char(255) NOT NULL,
  `customer` mediumint(8) unsigned NOT NULL,
  `plan` decimal(12,2) NOT NULL,
  `real` decimal(12,2) NOT NULL,
  `currency` varchar(20) NOT NULL,
  `status` enum('normal', 'signed', 'closed') NOT NULL DEFAULT 'normal',
  `subStatus` varchar(30) NOT NULL,
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `assignedTo` char(30) NOT NULL,
  `assignedBy` char(30) NOT NULL,
  `assignedDate` datetime NOT NULL,
  `signedBy` char(30) NOT NULL,
  `signedDate` date NOT NULL,
  `closedBy` char(30) NOT NULL,
  `closedDate` datetime NOT NULL,
  `closedReason` varchar(10) NOT NULL DEFAULT '',
  `activatedBy` char(30) NOT NULL,
  `activatedDate` datetime NOT NULL,
  `contactedBy` char(30) NOT NULL,
  `contactedDate` datetime NOT NULL,
  `nextDate` date NOT NULL,
  `deleted` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `product` (`product`),
  KEY `customer` (`customer`),
  KEY `plan` (`plan`),
  KEY `real` (`real`),
  KEY `status` (`status`),
  KEY `createdBy` (`createdBy`),
  KEY `assignedTo` (`assignedTo`),
  KEY `closedBy` (`closedBy`),
  KEY `closedReason` (`closedReason`),
  KEY `contactedDate` (`contactedDate`),
  KEY `nextDate` (`nextDate`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_dating`;
CREATE TABLE IF NOT EXISTS `crm_dating` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `objectType` varchar(30) NOT NULL,
  `objectID` mediumint(8) unsigned NOT NULL,
  `action` mediumint(8) unsigned NOT NULL,
  `customer` mediumint(8) unsigned NOT NULL,
  `contact` mediumint(8) unsigned NOT NULL,
  `account` varchar(30) NOT NULL,
  `date` date NOT NULL,
  `desc` text NOT NULL,
  `status` enum('wait', 'done') NOT NULL DEFAULT 'wait',
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `nextDate` (`status`, `objectType`, `objectID`, `date`, `account`, `contact`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_resume`;
CREATE TABLE IF NOT EXISTS `crm_resume` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `contact` mediumint(8) unsigned NOT NULL,
  `customer` mediumint(8) unsigned NOT NULL,
  `maker` enum('0','1') NOT NULL DEFAULT '0',
  `dept` char(100) NOT NULL,
  `position` varchar(100) NOT NULL,
  `title` char(100) NOT NULL,
  `address` mediumint(8) unsigned NOT NULL,
  `join` char(10) NOT NULL,
  `left` char(10) NOT NULL,
  `deleted` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `contact` (`contact`),
  KEY `customer` (`customer`),
  KEY `left` (`left`),
  KEY `maker` (`maker`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_salesgroup`;
CREATE TABLE IF NOT EXISTS `crm_salesgroup` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `desc` varchar(255) NOT NULL,
  `users` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_salespriv`;
CREATE TABLE IF NOT EXISTS `crm_salespriv` (
  `account` char(30) NOT NULL,
  `salesgroup` mediumint(8) unsigned NOT NULL,
  `priv` enum('view','edit') NOT NULL,
  KEY `account` (`account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_doc`;
CREATE TABLE IF NOT EXISTS `oa_doc` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `product` mediumint(8) unsigned NOT NULL,
  `project` mediumint(8) unsigned NOT NULL,
  `lib` mediumint(8) unsigned NOT NULL,
  `module` mediumint(8) unsigned NOT NULL,
  `title` varchar(255) NOT NULL,
  `keywords` varchar(255) NOT NULL,
  `type` varchar(30) NOT NULL,
  `views` mediumint(8) unsigned NOT NULL,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `version` smallint(5) unsigned NOT NULL DEFAULT '1',
  `private` enum('0', '1') NOT NULL DEFAULT '0',
  `users` text NOT NULL,
  `groups` varchar(255) NOT NULL DEFAULT '',
  `deleted` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_doccontent`;
CREATE TABLE IF NOT EXISTS `oa_doccontent` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `doc` mediumint(8) unsigned NOT NULL,
  `title` varchar(255) NOT NULL,
  `digest` varchar(255) NOT NULL,
  `content` text NOT NULL,
  `files` text NOT NULL,
  `type` varchar(10) NOT NULL,
  `version` smallint(5) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `docVersion` (`doc`,`version`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_doclib`;
CREATE TABLE IF NOT EXISTS `oa_doclib` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `project` mediumint(8) unsigned NOT NULL,
  `name` varchar(60) NOT NULL,
  `private` enum('0', '1') NOT NULL DEFAULT '0',
  `users` text NOT NULL,
  `groups` varchar(255) NOT NULL DEFAULT '',
  `main` enum('0', '1') NOT NULL DEFAULT '0',
  `order` tinyint(5) unsigned NOT NULL,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `deleted` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_project`;
CREATE TABLE IF NOT EXISTS `oa_project` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(90) NOT NULL,
  `desc` text NOT NULL,
  `begin` date NOT NULL,
  `end` date NOT NULL,
  `status` enum('doing','finished','suspend') NOT NULL DEFAULT 'doing',
  `taskStatus` char(30) NOT NULL,
  `whitelist` varchar(255) NOT NULL,
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `deleted` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_attend`;
CREATE TABLE IF NOT EXISTS `oa_attend` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `account` char(30) NOT NULL,
  `date` date NOT NULL,
  `signIn` time NOT NULL,
  `signOut` time NOT NULL,
  `status` varchar(30) NOT NULL DEFAULT '',
  `ip` varchar(15) NOT NULL,
  `device` varchar(30) NOT NULL,
  `client` varchar(20) NOT NULL,
  `manualIn` time NOT NULL,
  `manualOut` time NOT NULL,
  `lateMinutes` int(3) unsigned NOT NULL,
  `earlyMinutes` int(3) unsigned NOT NULL,
  `reason` varchar(30) NOT NULL DEFAULT '',
  `desc` text NOT NULL,
  `reviewStatus` varchar(30) NOT NULL DEFAULT '',
  `reviewedBy` char(30) NOT NULL,
  `reviewedDate` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `account` (`account`),
  KEY `date` (`date`),
  KEY `status` (`status`),
  KEY `reason` (`reason`),
  KEY `reviewStatus` (`reviewStatus`),
  KEY `reviewedBy` (`reviewedBy`),
  UNIQUE KEY `attend` (`date`,`account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_attendstat`;
CREATE TABLE IF NOT EXISTS `oa_attendstat` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `account` char(30) NOT NULL,
  `month` char(10) NOT NULL DEFAULT '',
  `normal` decimal(12,2) NOT NULL DEFAULT 0.00,
  `late` decimal(12,2) NOT NULL DEFAULT 0.00,
  `early` decimal(12,2) NOT NULL DEFAULT 0.00,
  `absent` decimal(12,2) NOT NULL DEFAULT 0.00,
  `trip` decimal(12,2) NOT NULL DEFAULT 0.00,
  `egress` decimal(12,2) NOT NULL DEFAULT 0.00,
  `lieu` decimal(12,2) NOT NULL DEFAULT 0.00,
  `paidLeave` decimal(12,2) NOT NULL DEFAULT 0.00,
  `unpaidLeave` decimal(12,2) NOT NULL DEFAULT 0.00,
  `timeOvertime` decimal(12,2) NOT NULL DEFAULT 0.00,
  `restOvertime` decimal(12,2) NOT NULL DEFAULT 0.00,
  `holidayOvertime` decimal(12,2) NOT NULL DEFAULT 0.00,
  `deserve` decimal(12,2) NOT NULL DEFAULT 0.00,
  `actual` decimal(12,2) NOT NULL DEFAULT 0.00,
  `paid` decimal(12,2) unsigned NOT NULL DEFAULT 0.00,
  `toMakeup` decimal(12,2) NOT NULL DEFAULT 0.00,
  `toLieu` decimal(12,2) NOT NULL DEFAULT 0.00,
  `status` char(30) NOT NULL DEFAULT '',
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `account` (`account`),
  KEY `month` (`month`),
  KEY `status` (`status`),
  UNIQUE KEY `attend` (`month`,`account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_attengroup`;
CREATE TABLE IF NOT EXISTS `oa_attendgroup` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL,
  `signInLimit` char(10) NOT NULL,
  `signOutLimit` char(10) NOT NULL,
  `lunchBegin` char(10) NOT NULL,
  `lunchEnd` char(10) NOT NULL,
  `dinnerBegin` char(10) NOT NULL,
  `dinnerEnd` char(10) NOT NULL,
  `users` text NOT NULL,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `deleted` enum('0', '1') NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_annual`;
CREATE TABLE IF NOT EXISTS `oa_annual` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `year` char(4) NOT NULL,
  `account` varchar(30) NOT NULL,
  `days` smallint(5) NOT NULL,
  `times` smallint(5) NOT NULL,
  `balance` smallint(5) NOT NULL,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `account` (`account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_conversion`;
CREATE TABLE IF NOT EXISTS `oa_conversion` (
    `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
    `year` char(4) NOT NULL,
    `days` float unsigned NOT NULL,
    `dept` mediumint(8) unsigned NOT NULL,
    `status` enum('wait', 'draft', 'pass', 'reject', 'grant'),
    `desc` text NOT NULL,
    `reason` text NOT NULL,
    `createdBy` char(30) NOT NULL,
    `createdDate` datetime NOT NULL,
    `reviewedBy` char(30) NOT NULL,
    `reviewedDate` datetime NOT NULL,
    `grantedBy` char(30) NOT NULL,
    `grantedDate` datetime NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_overtime`;
CREATE TABLE IF NOT EXISTS `oa_overtime` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `year` char(4) NOT NULL,
  `begin` date NOT NULL,
  `end` date NOT NULL,
  `start` time NOT NULL,
  `finish` time NOT NULL,
  `hours` float unsigned NOT NULL,
  `leave` varchar(255) NOT NULL,
  `type` varchar(30) NOT NULL DEFAULT '',
  `desc` text NOT NULL,
  `status` varchar(30) NOT NULL DEFAULT '',
  `rejectReason` varchar(100) NOT NULL,
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `reviewedBy` char(30) NOT NULL,
  `reviewedDate` datetime NOT NULL,
  `reviewers` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `year` (`year`),
  KEY `type` (`type`),
  KEY `status` (`status`),
  KEY `createdBy` (`createdBy`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_holiday`;
CREATE TABLE IF NOT EXISTS `oa_holiday` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL DEFAULT '',
  `type` enum('holiday', 'working') NOT NULL DEFAULT 'holiday',
  `desc` text NOT NULL,
  `year` char(4) NOT NULL,
  `begin` date NOT NULL,
  `end` date NOT NULL,
  PRIMARY KEY (`id`),
  KEY `year` (`year`),
  KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_leave`;
CREATE TABLE IF NOT EXISTS `oa_leave` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `year` char(4) NOT NULL,
  `begin` date NOT NULL,
  `end` date NOT NULL,
  `start` time NOT NULL,
  `finish` time NOT NULL,
  `hours` float unsigned NOT NULL,
  `backDate` datetime NOT NULL,
  `type` varchar(30) NOT NULL DEFAULT '',
  `desc` text NOT NULL,
  `status` varchar(30) NOT NULL DEFAULT '',
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `reviewedBy` char(30) NOT NULL,
  `reviewedDate` datetime NOT NULL,
  `reviewers` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `year` (`year`),
  KEY `type` (`type`),
  KEY `status` (`status`),
  KEY `createdBy` (`createdBy`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_lieu`;
CREATE TABLE IF NOT EXISTS `oa_lieu` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `year` char(4) NOT NULL,
  `begin` date NOT NULL,
  `end` date NOT NULL,
  `start` time NOT NULL,
  `finish` time NOT NULL,
  `hours` float unsigned NOT NULL,
  `overtime` char(255) NOT NULL,
  `trip` char(255) NOT NULL,
  `desc` text NOT NULL,
  `status` varchar(30) NOT NULL DEFAULT '',
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `reviewedBy` char(30) NOT NULL,
  `reviewedDate` datetime NOT NULL,
  `reviewers` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `year` (`year`),
  KEY `status` (`status`),
  KEY `createdBy` (`createdBy`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_lieuconversion`;
CREATE TABLE IF NOT EXISTS `oa_lieuconversion` (
    `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
    `account` char(30) NOT NULL,
    `dept` mediumint(8) unsigned NOT NULL,
    `hours` float unsigned NOT NULL,
    `desc` text NOT NULL,
    `createdBy` char(30) NOT NULL,
    `createdDate` datetime NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_trip`;
CREATE TABLE IF NOT EXISTS `oa_trip` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `type` enum('trip', 'egress') NOT NULL DEFAULT 'trip',
  `customers` varchar(20) NOT NULL,
  `name` char(30) NOT NULL,
  `desc` text NOT NULL,
  `year` char(4) NOT NULL,
  `begin` date NOT NULL,
  `end` date NOT NULL,
  `start` time NOT NULL,
  `finish` time NOT NULL,
  `from` char(50) NOT NULL,
  `to` char(50) NOT NULL,
  `status` varchar(30) NOT NULL,
  `rejectReason` varchar(100) NOT NULL,
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `reviewedBy` varchar(30) NOT NULL,
  `reviewedDate` datetime NOT NULL,
  `reviewers` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `year` (`year`),
  KEY `createdBy` (`createdBy`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_todo`;
CREATE TABLE IF NOT EXISTS `oa_todo` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `account` char(30) NOT NULL,
  `date` date NOT NULL,
  `begin` smallint(4) unsigned zerofill NOT NULL,
  `end` smallint(4) unsigned zerofill NOT NULL,
  `type` char(20) NOT NULL,
  `cycle` tinyint(3) unsigned NOT NULL,
  `idvalue` mediumint(8) unsigned NOT NULL default '0',
  `pri` tinyint(3) unsigned NOT NULL,
  `name` char(150) NOT NULL,
  `desc` text NOT NULL,
  `status` varchar(30) NOT NULL DEFAULT '',
  `private` tinyint(1) NOT NULL,
  `config` varchar(255) NOT NULL,
  `assignedTo` varchar(30) NOT NULL DEFAULT '',
  `assignedBy` varchar(30) NOT NULL DEFAULT '',
  `assignedDate` datetime NOT NULL,
  `finishedBy` varchar(30) NOT NULL DEFAULT '',
  `finishedDate` datetime NOT NULL,
  `closedBy` varchar(30) NOT NULL DEFAULT '',
  `closedDate` datetime NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `user` (`account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `oa_refund`;
CREATE TABLE IF NOT EXISTS `oa_refund` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `customer` mediumint(8) unsigned NOT NULL,
  `order` mediumint(8) unsigned NOT NULL,
  `contract` mediumint(8) unsigned NOT NULL,
  `project` mediumint(8) unsigned NOT NULL,
  `trip` mediumint(8) unsigned NOT NULL,
  `parent`  mediumint(8) unsigned NOT NULL DEFAULT 0,
  `dept`  mediumint(8) unsigned NOT NULL DEFAULT 0,
  `name` char(150) NOT NULL,
  `payee` varchar(30) NOT NULL,
  `category` char(30) NOT NULL DEFAULT '0',
  `date` date NOT NULL,
  `money` decimal(12,2) NOT NULL,
  `invoice` decimal(12,2) NOT NULL,
  `currency` varchar(30) NOT NULL,
  `desc` text NOT NULL,
  `related` char(200) NOT NULL DEFAULT '',
  `status` char(30) NOT NULL DEFAULT 'wait',
  `createdBy` char(30) NOT NULL DEFAULT '',
  `createdDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL DEFAULT '',
  `editedDate` datetime NOT NULL,
  `firstReviewer` char(30) NOT NULL DEFAULT '',
  `firstReviewDate` datetime NOT NULL,
  `secondReviewer` char(30) NOT NULL DEFAULT '',
  `secondReviewDate` datetime NOT NULL,
  `refundBy` char(30) NOT NULL DEFAULT '',
  `refundDate` datetime NOT NULL,
  `reason` text NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `createdBy` (`createdBy`),
  KEY `firstReviewer` (`firstReviewer`),
  KEY `secondReviewer` (`secondReviewer`),
  KEY `refundBy` (`refundBy`),
  KEY `category` (`category`),
  KEY `date` (`date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_relation`;
CREATE TABLE IF NOT EXISTS `sys_relation` (
  `type` char(20) NOT NULL,
  `id` mediumint(8) NOT NULL,
  `category` mediumint(8) NOT NULL,
  UNIQUE KEY `relation` (`type`,`id`,`category`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `cash_depositor`;
CREATE TABLE IF NOT EXISTS `cash_depositor` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `type` enum('cash','bank','online') NOT NULL,
  `abbr` char(60) NOT NULL,
  `title` char(100) NOT NULL,
  `tags` varchar(255) NOT NULL,
  `provider` char(100) NOT NULL,
  `bank` varchar(10) NOT NULL,
  `customerNo` varchar(20) NOT NULL,
  `account` char(90) NOT NULL,
  `unionBankNo` varchar(30) NOT NULL,
  `clearingBankNo` varchar(30) NOT NULL,
  `public` enum('0','1') NOT NULL,
  `currency` char(30) NOT NULL,
  `status` enum('normal','disable') NOT NULL DEFAULT 'normal',
  `createdBy` char(30) NOT NULL DEFAULT '',
  `createdDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL DEFAULT '',
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `cash_balance`;
CREATE TABLE IF NOT EXISTS `cash_balance` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `depositor` mediumint(8) unsigned NOT NULL,
  `date` date NOT NULL,
  `money` decimal(12,2) NOT NULL,
  `currency` char(30) NOT NULL,
  `createdBy` char(30) NOT NULL DEFAULT '',
  `createdDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL DEFAULT '',
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `depositor` (`depositor`,`date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `cash_trade`;
CREATE TABLE IF NOT EXISTS `cash_trade` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `depositor` mediumint(8) unsigned NOT NULL,
  `parent`  mediumint(8) unsigned NOT NULL DEFAULT 0,
  `product` mediumint(8) unsigned NOT NULL,
  `trader` mediumint(8) unsigned NOT NULL DEFAULT 0,
  `order` mediumint(8) unsigned NOT NULL,
  `contract` mediumint(8) unsigned NOT NULL,
  `relatedType` varchar(30) NOT NULL,
  `relatedID` mediumint(8) unsigned NOT NULL,
  `project` mediumint(8) unsigned NOT NULL,
  `investID` mediumint(8) unsigned NOT NULL,
  `loanID` mediumint(8) unsigned NOT NULL,
  `transferID` mediumint(8) unsigned NOT NULL,
  `dept` mediumint(8) unsigned NOT NULL,
  `type` enum('in', 'out', 'transferin', 'transferout', 'invest', 'redeem', 'loan', 'repay') NOT NULL,
  `money` decimal(12,2) NOT NULL,
  `exchangeRate` decimal(12,4) NOT NULL DEFAULT 1,
  `currency` varchar(30) NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `deadline` date NOT NULL,
  `handlers` varchar(255) NOT NULL,
  `category` char(30) NOT NULL DEFAULT '0',
  `desc` text NOT NULL,
  `createdBy` char(30) NOT NULL DEFAULT '',
  `createdDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL DEFAULT '',
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `depositor` (`depositor`),
  KEY `parent` (`parent`),
  KEY `product` (`product`),
  KEY `trader` (`trader`),
  KEY `order` (`order`),
  KEY `contract` (`contract`),
  KEY `investID` (`investID`),
  KEY `loanID` (`loanID`),
  KEY `dept` (`dept`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `team_thread`;
CREATE TABLE IF NOT EXISTS `team_thread` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `board` mediumint(8) unsigned NOT NULL,
  `title` varchar(255) NOT NULL,
  `content` text NOT NULL,
  `author` varchar(60) NOT NULL,
  `editor` varchar(60) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedDate` datetime NOT NULL,
  `readonly` tinyint(1) NOT NULL DEFAULT '0',
  `views` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `stick` enum('0','1','2','3') NOT NULL DEFAULT '0',
  `replies` mediumint(8) unsigned NOT NULL,
  `repliedBy` varchar(30) NOT NULL,
  `repliedDate` datetime NOT NULL,
  `replyID` mediumint(8) unsigned NOT NULL,
  `hidden` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `category` (`board`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `team_reply`;
CREATE TABLE IF NOT EXISTS `team_reply` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `thread` mediumint(8) unsigned NOT NULL,
  `content` text NOT NULL,
  `author` char(30) NOT NULL,
  `editor` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedDate` datetime NOT NULL,
  `hidden` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `thread` (`thread`),
  KEY `author` (`author`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_action`;
CREATE TABLE IF NOT EXISTS `sys_action` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `customer` mediumint(8) unsigned DEFAULT NULL,
  `contact` mediumint(8) unsigned DEFAULT NULL,
  `objectType` varchar(30) NOT NULL DEFAULT '',
  `objectID` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `actor` varchar(30) NOT NULL DEFAULT '',
  `action` varchar(30) NOT NULL DEFAULT '',
  `stage` varchar(20) NOT NULL,
  `date` datetime NOT NULL,
  `comment` text NOT NULL,
  `extra` varchar(255) NOT NULL,
  `read` enum('0', '1') NOT NULL DEFAULT '0',
  `reader` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `customer` (`customer`),
  KEY `contact` (`contact`),
  KEY `objectType` (`objectType`),
  KEY `objectID` (`objectID`),
  KEY `date` (`date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_actionreader`;
CREATE TABLE IF NOT EXISTS `sys_actionreader` (
  `action` mediumint(8) unsigned NOT NULL,
  `account` varchar(30) NOT NULL,
  UNIQUE KEY `reader` (`action`, `account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_notify`;
CREATE TABLE IF NOT EXISTS `sys_notify` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `objectType` varchar(50) NOT NULL,
  `objectID` mediumint(8) unsigned NOT NULL,
  `action` mediumint(8) NOT NULL,
  `toList` varchar(255) NOT NULL,
  `ccList` text NOT NULL,
  `subject` varchar(255) NOT NULL,
  `data` text NOT NULL,
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `sendTime` datetime NOT NULL,
  `status` varchar(10) NOT NULL DEFAULT 'wait',
  `failReason` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_block`;
CREATE TABLE IF NOT EXISTS `sys_block` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `account` char(30) NOT NULL,
  `app` varchar(20) NOT NULL,
  `title` varchar(100) NOT NULL,
  `source` varchar(20) NOT NULL,
  `block` varchar(20) NOT NULL,
  `params` text NOT NULL,
  `order` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `grid` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `height` smallint(5) unsigned NOT NULL DEFAULT '0',
  `hidden` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `accountAppOrder` (`account`, `app`, `order`),
  KEY `account` (`account`, `app`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_category`;
CREATE TABLE IF NOT EXISTS `sys_category` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `name` char(30) NOT NULL DEFAULT '',
  `alias` varchar(100) NOT NULL,
  `desc` text NOT NULL,
  `keywords` varchar(150) NOT NULL,
  `root` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `parent` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `path` char(255) NOT NULL DEFAULT '',
  `grade` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `order` smallint(5) unsigned NOT NULL DEFAULT '0',
  `type` char(30) NOT NULL,
  `readonly` enum('0','1') NOT NULL DEFAULT '0',
  `moderators` varchar(255) NOT NULL,
  `threads` smallint(5) NOT NULL,
  `posts` smallint(5) NOT NULL,
  `postedBy` varchar(30) NOT NULL,
  `postedDate` datetime NOT NULL,
  `postID` mediumint(8) unsigned NOT NULL,
  `replyID` mediumint(8) unsigned NOT NULL,
  `users` text NOT NULL,
  `rights` varchar(255) NOT NULL,
  `refund` enum('0','1') NOT NULL DEFAULT '0',
  `score` smallint(5) unsigned NOT NULL,
  `major` enum('0','1','2','3','4','5','6','7','8') NOT NULL DEFAULT '0',
  `deleted` enum('0', '1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `type` (`type`),
  KEY `order` (`order`),
  KEY `parent` (`parent`),
  KEY `path` (`path`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_package`;
CREATE TABLE IF NOT EXISTS `sys_package` (
  `id` mediumint(8) unsigned NOT NULL auto_increment,
  `name` varchar(150) NOT NULL,
  `code` varchar(30) NOT NULL,
  `version` varchar(50) NOT NULL,
  `author` varchar(100) NOT NULL,
  `desc` text NOT NULL,
  `license` text NOT NULL,
  `type` varchar(20) NOT NULL default 'extension',
  `site` varchar(150) NOT NULL,
  `ranzhiCompatible` varchar(100) NOT NULL,
  `installedTime` datetime NOT NULL,
  `depends` varchar(100) NOT NULL,
  `dirs` text NOT NULL,
  `files` text NOT NULL,
  `status` varchar(20) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `code` (`code`),
  KEY `name` (`name`),
  KEY `addedTime` (`installedTime`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_config`;
CREATE TABLE IF NOT EXISTS `sys_config` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `owner` char(30) NOT NULL DEFAULT '',
  `app` varchar(30) NOT NULL DEFAULT 'sys',
  `module` varchar(30) NOT NULL,
  `section` char(30) NOT NULL DEFAULT '',
  `key` char(30) DEFAULT NULL,
  `value` text NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique` (`owner`,`app`,`module`,`section`,`key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_entry`;
CREATE TABLE IF NOT EXISTS `sys_entry` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `abbr` char(6) NOT NULL,
  `code` varchar(20) NOT NULL,
  `buildin` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `version` varchar(20) NOT NULL,
  `platform` varchar(255) NOT NULL DEFAULT 'zdoo',
  `package` int(11) NOT NULL DEFAULT 0,
  `integration` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `open` varchar(20) NOT NULL,
  `key` char(32) NOT NULL,
  `ip` varchar(100) NOT NULL,
  `logo` varchar(100) NOT NULL,
  `login` varchar(255) NOT NULL,
  `logout` varchar(255) NOT NULL,
  `block` varchar(255) NOT NULL,
  `control` varchar(10) NOT NULL DEFAULT 'simple',
  `size` varchar(50) NOT NULL DEFAULT 'max',
  `position` varchar(10) NOT NULL DEFAULT 'default',
  `visible` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `order` tinyint(5) unsigned NOT NULL DEFAULT '0',
  `zentao` enum('0', '1') NOT NULL DEFAULT '0',
  `flow` enum('0', '1') NOT NULL DEFAULT '0',
  `hideNavigation` enum('0', '1') NOT NULL DEFAULT '0',
  `category` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `status` enum('online','offline') NOT NULL DEFAULT 'online',
  PRIMARY KEY (`id`),
  UNIQUE KEY `code` (`code`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_article`;
CREATE TABLE IF NOT EXISTS `sys_article` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(150) NOT NULL,
  `alias` varchar(100) NOT NULL,
  `keywords` varchar(150) NOT NULL,
  `summary` text NOT NULL,
  `content` text NOT NULL,
  `original` enum('1','0') NOT NULL,
  `copySite` varchar(60) NOT NULL,
  `copyURL` varchar(255) NOT NULL,
  `author` varchar(60) NOT NULL,
  `editor` varchar(60) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedDate` datetime NOT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'normal',
  `type` varchar(30) NOT NULL,
  `views` mediumint(5) unsigned NOT NULL DEFAULT '0',
  `sticky` enum('0','1','2','3') NOT NULL DEFAULT '0',
  `order` smallint(5) unsigned NOT NULL,
  `private` enum('0', '1') NOT NULL DEFAULT '0',
  `users` text NOT NULL,
  `groups` varchar(255) NOT NULL DEFAULT '',
  `readers` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `order` (`order`),
  KEY `views` (`views`),
  KEY `sticky` (`sticky`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_tag`;
CREATE TABLE IF NOT EXISTS `sys_tag` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `tag` varchar(50) NOT NULL,
  `rank` smallint(5) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tag` (`tag`),
  KEY `rank` (`rank`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_message`;
CREATE TABLE IF NOT EXISTS `sys_message` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `type` char(20) NOT NULL,
  `objectType` varchar(30) NOT NULL DEFAULT '',
  `objectID` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `account` char(30) DEFAULT NULL,
  `from` char(30) NOT NULL,
  `to` char(30) NOT NULL,
  `date` datetime NOT NULL,
  `content` text NOT NULL,
  `status` char(20) NOT NULL,
  `readed` enum('0','1') NOT NULL,
  PRIMARY KEY (`id`),
  KEY `status` (`status`),
  KEY `object` (`objectType`,`objectID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_file`;
CREATE TABLE IF NOT EXISTS `sys_file` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `pathname` char(50) NOT NULL,
  `title` varchar(90) NOT NULL,
  `extension` char(30) NOT NULL,
  `size` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `objectType` char(30) NOT NULL,
  `objectID` mediumint(8) unsigned NOT NULL,
  `createdBy` char(30) NOT NULL DEFAULT '',
  `createdDate` datetime NOT NULL,
  `editor` enum('1','0') NOT NULL DEFAULT '0',
  `primary` enum('1','0') DEFAULT '0',
  `public` enum('1','0') NOT NULL DEFAULT '1',
  `downloads` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `extra` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `object` (`objectType`,`objectID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_history`;
CREATE TABLE IF NOT EXISTS `sys_history` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `action` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `field` varchar(30) NOT NULL DEFAULT '',
  `old` text NOT NULL,
  `new` text NOT NULL,
  `diff` mediumtext NOT NULL,
  PRIMARY KEY (`id`),
  KEY `action` (`action`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_kanbanregion`;
CREATE TABLE `sys_kanbanregion` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `project` mediumint(8) unsigned NOT NULL,
  `name` varchar(90) NOT NULL,
  `order` tinyint(3) unsigned NOT NULL,
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `deleted` enum('0', '1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `project` (`project`),
  KEY `order` (`order`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_kanbangroup`;
CREATE TABLE `sys_kanbangroup` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `project` mediumint(8) unsigned NOT NULL,
  `region` mediumint(8) unsigned NOT NULL,
  `order` tinyint(3) unsigned NOT NULL,
  `name` varchar(60) NOT NULL,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `deleted` enum('0', '1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `project` (`project`),
  KEY `region` (`region`),
  KEY `order` (`order`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_kanbanlane`;
CREATE TABLE `sys_kanbanlane` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `project` mediumint(8) unsigned NOT NULL,
  `region` mediumint(8) unsigned NOT NULL,
  `group` tinyint(3) unsigned NOT NULL,
  `order` tinyint(3) unsigned NOT NULL,
  `name` varchar(90) NOT NULL,
  `color` varchar(10) NOT NULL DEFAULT '#3DC6FD',
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `deleted` enum('0', '1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `project` (`project`),
  KEY `region` (`region`),
  KEY `order` (`order`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_kanbancolumn`;
CREATE TABLE `sys_kanbancolumn` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `project` mediumint(8) unsigned NOT NULL,
  `region` mediumint(8) unsigned NOT NULL,
  `group` tinyint(3) unsigned NOT NULL,
  `parent` mediumint(8) unsigned NOT NULL,
  `order` tinyint(3) unsigned NOT NULL,
  `name` varchar(90) NOT NULL,
  `color` varchar(10) NOT NULL DEFAULT '#272E33',
  `limit` smallint(5) unsigned NOT NULL,
  `taskStatus` varchar(30) NOT NULL,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `archivedBy` varchar(30) NOT NULL,
  `archivedDate` datetime NOT NULL,
  `archived` enum('0', '1') NOT NULL DEFAULT '0',
  `deleted` enum('0', '1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `project` (`project`),
  KEY `region` (`region`),
  KEY `order` (`order`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_lang`;
CREATE TABLE IF NOT EXISTS `sys_lang` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `lang` varchar(30) NOT NULL,
  `app` varchar(30) NOT NULL DEFAULT 'sys',
  `module` varchar(30) NOT NULL,
  `section` varchar(30) NOT NULL,
  `key` varchar(60) NOT NULL,
  `value` text NOT NULL,
  `system` enum('0','1') NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  UNIQUE KEY `lang` (`app`,`lang`,`module`,`section`,`key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_product`;
CREATE TABLE IF NOT EXISTS `sys_product` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `category` mediumint(8) unsigned NOT NULL,
  `subject` mediumint(8) unsigned NOT NULL,
  `name` varchar(150) NOT NULL,
  `code` varchar(20) NOT NULL,
  `type` varchar(10) NOT NULL,
  `order` smallint(5) NOT NULL,
  `status` varchar(10) NOT NULL,
  `subStatus` varchar(30) NOT NULL,
  `gift` enum('0', '1') NOT NULL DEFAULT '0',
  `score` smallint(5) unsigned NOT NULL,
  `limit` smallint(5) unsigned NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `desc` text NOT NULL,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `deleted` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `name` (`name`),
  KEY `type` (`type`),
  KEY `status` (`status`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_schema`;
CREATE TABLE IF NOT EXISTS `sys_schema` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `otherDepositor` varchar(5) NOT NULL,
  `name` varchar(255) NOT NULL,
  `category` char(10) NOT NULL,
  `trader`   char(10) NOT NULL,
  `type`     char(10) NOT NULL,
  `money`    char(10) NOT NULL,
  `desc`     char(10) NOT NULL,
  `date`     char(10) NOT NULL,
  `fee`      char(10) NOT NULL,
  `dept`     char(10) NOT NULL,
  `product`  char(10) NOT NULL,
  `handlers` char(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_sso`;
CREATE TABLE IF NOT EXISTS `sys_sso` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `sid` char(32) NOT NULL,
  `entry` mediumint(8) unsigned NOT NULL,
  `token` char(32) NOT NULL,
  `time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `sid` (`sid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_task`;
CREATE TABLE IF NOT EXISTS `sys_task` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `project` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `customer` mediumint(8) unsigned NOT NULL,
  `order` mediumint(8) unsigned NOT NULL,
  `category` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `name` varchar(255) NOT NULL,
  `color` varchar(10) NOT NULL DEFAULT '#FFFFFF',
  `type` varchar(20) NOT NULL,
  `pri` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `estimate` decimal(12,1) unsigned NOT NULL,
  `consumed` decimal(12,1) unsigned NOT NULL,
  `left` decimal(12,1) unsigned NOT NULL,
  `deadline` date NOT NULL,
  `status` enum('wait','doing','done','cancel','closed') NOT NULL DEFAULT 'wait',
  `statusCustom` tinyint(3) unsigned NOT NULL,
  `mailto` varchar(255) NOT NULL DEFAULT '',
  `desc` text NOT NULL,
  `parent` mediumint(8) unsigned NOT NULL DEFAULT 0,
  `kanbanRegion` mediumint(8) unsigned NOT NULL,
  `kanbanGroup` mediumint(8) unsigned NOT NULL,
  `kanbanLane` mediumint(8) unsigned NOT NULL,
  `kanbanColumn` mediumint(8) unsigned NOT NULL,
  `kanbanOrder` tinyint(3) unsigned NOT NULL,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `assignedTo` varchar(30) NOT NULL,
  `assignedDate` datetime NOT NULL,
  `estStarted` date NOT NULL,
  `realStarted` date NOT NULL,
  `finishedBy` varchar(30) NOT NULL,
  `finishedDate` datetime NOT NULL,
  `canceledBy` varchar(30) NOT NULL,
  `canceledDate` datetime NOT NULL,
  `closedBy` varchar(30) NOT NULL,
  `closedDate` datetime NOT NULL,
  `closedReason` varchar(30) NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `archivedBy` varchar(30) NOT NULL,
  `archivedDate` datetime NOT NULL,
  `archived` enum('0', '1') NOT NULL DEFAULT '0',
  `deleted` enum('0','1') NOT NULL DEFAULT '0',
  `key` smallint(5) unsigned NOT NULL default 0,
  PRIMARY KEY (`id`),
  KEY `statusOrder` (`statusCustom`),
  KEY `assignedTo` (`assignedTo`),
  KEY `createdBy` (`createdBy`),
  KEY `finishedBy` (`finishedBy`),
  KEY `closedBy` (`closedBy`),
  KEY `closedReason` (`closedReason`),
  KEY `type` (`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_team`;
CREATE TABLE IF NOT EXISTS `sys_team` (
  `type` char(30) NOT NULL,
  `id` mediumint(8) NOT NULL DEFAULT '0',
  `account` char(30) NOT NULL DEFAULT '',
  `role` char(30) NOT NULL DEFAULT '',
  `join` date NOT NULL DEFAULT '0000-00-00',
  `days` smallint(5) unsigned NOT NULL,
  `hours` float unsigned NOT NULL,
  `estimate` decimal(12,1) unsigned NOT NULL,
  `consumed` decimal(12,1) unsigned NOT NULL,
  `left` decimal(12,1) unsigned NOT NULL,
  `order` tinyint(3) unsigned NOT NULL,
  `contribution` decimal(6,2) unsigned NOT NULL,
  `rate` decimal(6,2) unsigned NOT NULL,
  `participation` decimal(6,2) unsigned NOT NULL,
  `status` enum('wait', 'accept', 'reject') NOT NULL DEFAULT 'wait',
  PRIMARY KEY (`type`,`id`,`account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_score`;
CREATE TABLE IF NOT EXISTS `sys_score` (
  `id` bigint(12) unsigned NOT NULL AUTO_INCREMENT,
  `account` varchar(30) NOT NULL,
  `dept` mediumint(8) unsigned NOT NULL,
  `type` enum('common', 'share', 'bonus') NOT NULL DEFAULT 'common',
  `module` varchar(30) NOT NULL DEFAULT '',
  `method` varchar(30) NOT NULL,
  `rule` mediumint(8) unsigned NOT NULL,
  `actionDate` date NOT NULL,
  `desc` varchar(250) NOT NULL DEFAULT '',
  `before` int(11) unsigned NOT NULL DEFAULT '0',
  `score` int(11) NOT NULL DEFAULT '0',
  `after` int(11) unsigned NOT NULL DEFAULT '0',
  `giver` varchar(30) NOT NULL,
  `receiver` varchar(30) NOT NULL,
  `reviewer` varchar(30) NOT NULL,
  `time` datetime NOT NULL,
  `status` enum('normal','wait','rejected') NOT NULL DEFAULT 'normal',
  `rejectReason` varchar(250) NOT NULL DEFAULT '',
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `account` (`account`),
  KEY `rule` (`rule`),
  KEY `module` (`module`),
  KEY `method` (`method`),
  KEY `status` (`status`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_scorerule`;
CREATE TABLE IF NOT EXISTS `sys_scorerule` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `type` varchar(30) NOT NULL,
  `name` varchar(30) NOT NULL,
  `score` int(11) NOT NULL DEFAULT '0',
  `desc` varchar(250) NOT NULL DEFAULT '',
  `order` mediumint(8) unsigned NOT NULL,
  `buildin` enum('0', '1') NOT NULL DEFAULT '0',
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `deleted` enum('0', '1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_exchange`;
CREATE TABLE IF NOT EXISTS `sys_exchange` (
  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
  `gift` mediumint(8) unsigned NOT NULL DEFAULT 0,
  `amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `score` smallint(5) unsigned NOT NULL DEFAULT 0,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `grantedBy` varchar(30) NOT NULL,
  `grantedDate` datetime NOT NULL,
  `cancelledBy` varchar(30) NOT NULL,
  `cancelledDate` datetime NOT NULL,
  `finishedDate` datetime NOT NULL,
  `status` varchar(10) NOT NULL DEFAULT 'normal',
  `cancelledReason` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `createdBy` (`createdBy`),
  KEY `status` (`status`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE IF NOT EXISTS `sys_user` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `dept` mediumint(8) unsigned NOT NULL,
  `account` char(30) NOT NULL DEFAULT '',
  `password` char(32) NOT NULL DEFAULT '',
  `realname` char(30) NOT NULL DEFAULT '',
  `role` char(30) NOT NULL,
  `nickname` char(60) NOT NULL DEFAULT '',
  `admin` enum('no','super') NOT NULL DEFAULT 'no',
  `avatar` varchar(255) NOT NULL DEFAULT '',
  `birthday` date NOT NULL,
  `gender` enum('f','m','u') NOT NULL DEFAULT 'u',
  `email` char(90) NOT NULL DEFAULT '',
  `skype` char(90) NOT NULL,
  `qq` char(20) NOT NULL DEFAULT '',
  `weixin` char(50) NOT NULL,
  `yahoo` char(90) NOT NULL DEFAULT '',
  `gtalk` char(90) NOT NULL DEFAULT '',
  `wangwang` char(90) NOT NULL DEFAULT '',
  `site` varchar(100) NOT NULL,
  `mobile` char(11) NOT NULL DEFAULT '',
  `phone` char(20) NOT NULL DEFAULT '',
  `address` char(120) NOT NULL DEFAULT '',
  `zipcode` char(10) NOT NULL DEFAULT '',
  `visits` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `ip` char(50) NOT NULL DEFAULT '',
  `last` datetime NOT NULL,
  `ping` datetime NOT NULL,
  `fails` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `join` datetime NOT NULL,
  `score` int(11) unsigned NOT NULL DEFAULT '0',
  `levelScore` int(11) unsigned NOT NULL DEFAULT '0',
  `giftScore` smallint(5) unsigned NOT NULL DEFAULT '0',
  `lastService` datetime NOT NULL,
  `annualLeave` text NOT NULL,
  `sect` varchar(30) NOT NULL DEFAULT '',
  `order` mediumint(8) UNSIGNED NOT NULL,
  `createdBy` char(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` char(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  `locked` datetime NOT NULL,
  `resetToken` varchar(50) NOT NULL,
  `deleted` enum('0','1') NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `account` (`account`),
  KEY `admin` (`admin`),
  KEY `accountPassword` (`account`,`password`),
  KEY `dept` (`dept`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_usercontact`;
CREATE TABLE IF NOT EXISTS `sys_usercontact` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `account` char(30) NOT NULL,
  `name` varchar(60) NOT NULL,
  `member` text NOT NULL,
  `public` enum('0', '1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `account` (`account`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_group`;
CREATE TABLE IF NOT EXISTS `sys_group` (
  `id` mediumint(8) unsigned NOT NULL auto_increment,
  `name` char(30) NOT NULL,
  `order` smallint(5) unsigned NOT NULL,
  `desc` char(255) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_usergroup`;
CREATE TABLE IF NOT EXISTS `sys_usergroup` (
  `account` char(30) NOT NULL DEFAULT '',
  `group` mediumint(8) unsigned NOT NULL DEFAULT '0',
  UNIQUE KEY `account` (`account`,`group`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_grouppriv`;
CREATE TABLE IF NOT EXISTS `sys_grouppriv` (
  `group` mediumint(8) unsigned NOT NULL default '0',
  `module` char(30) NOT NULL default '',
  `method` char(30) NOT NULL default '',
  UNIQUE KEY `group` (`group`,`module`,`method`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_userquery`;
CREATE TABLE IF NOT EXISTS `sys_userquery` (
  `id` mediumint(8) unsigned NOT NULL auto_increment,
  `account` char(30) NOT NULL,
  `module` varchar(30) NOT NULL,
  `title` varchar(90) NOT NULL,
  `form` text NOT NULL,
  `sql` text NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `account` (`account`),
  KEY `module` (`module`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_cron`;
CREATE TABLE IF NOT EXISTS `sys_cron` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `m` varchar(20) NOT NULL,
  `h` varchar(20) NOT NULL,
  `dom` varchar(20) NOT NULL,
  `mon` varchar(20) NOT NULL,
  `dow` varchar(20) NOT NULL,
  `command` text NOT NULL,
  `remark` varchar(255) NOT NULL,
  `type` varchar(20) NOT NULL,
  `buildin` tinyint(1) NOT NULL DEFAULT '0',
  `status` varchar(20) NOT NULL,
  `lastTime` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `sys_gift`;
CREATE TABLE IF NOT EXISTS `sys_gift` (
   `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
   `name` varchar(150) NOT NULL,
   `score` smallint(5) unsigned NOT NULL,
   `amount` decimal(15,2) NOT NULL,
   `status` enum('normal', 'offline') NOT NULL,
   `limit` smallint(5) unsigned NOT NULL,
   `desc` text NOT NULL,
   `scoreGift` tinyint(1) NOT NULL DEFAULT 1,
   `createdBy` varchar(30) NOT NULL,
   `createdDate` datetime NOT NULL,
   `editedBy` varchar(30) NOT NULL,
   `editedDate` datetime NOT NULL,
   `deleted` enum('0','1') NOT NULL,
   PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_stageservice`;
CREATE TABLE IF NOT EXISTS `crm_stageservice` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `customer` mediumint(8) unsigned NOT NULL COMMENT '关联客户',
  `contract` mediumint(8) unsigned NOT NULL COMMENT '关联合同',
  `renewalIntention` varchar(10) NOT NULL COMMENT '续费意向',
  `M6Finished` tinyint(1) NOT NULL COMMENT '是否已完成M6满意度调查',
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_stagedelivery`;
CREATE TABLE IF NOT EXISTS `crm_stagedelivery` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `customer` mediumint(8) unsigned NOT NULL COMMENT '关联客户',
  `contract` mediumint(8) unsigned NOT NULL COMMENT '关联合同',
  `date` datetime NOT NULL COMMENT '交付培训日期',
  `record` text NOT NULL COMMENT '交付培训记录',
  `health` varchar(10) NOT NULL COMMENT '客户应用健康度',
  `M1Finished` tinyint(1) NOT NULL COMMENT '是否完成M1满意度调查',
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_stagetrial`;
CREATE TABLE IF NOT EXISTS `crm_stagetrial` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `customer` mediumint(8) unsigned NOT NULL COMMENT '关联客户',
  `reply` text NOT NULL COMMENT '使用问题答疑',
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_stageguidance`;
CREATE TABLE IF NOT EXISTS `crm_stageguidance` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `customer` mediumint(8) unsigned NOT NULL,
  `materialFinished` tinyint(1) NOT NULL COMMENT '是否完成发送物料',
  `ourStaff` varchar(100) NOT NULL COMMENT '我方参与人员',
  `customerStaff` varchar(100) NOT NULL COMMENT '客户方参与人员',
  `record` text NOT NULL COMMENT '演示记录',
  `paymentIntention` varchar(10) NOT NULL COMMENT '客户付费意向度',
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_stagecommunication`;
CREATE TABLE IF NOT EXISTS `crm_stagecommunication` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `customer` mediumint(8) unsigned NOT NULL,
  `scene` varchar(30) NOT NULL COMMENT '使用场景',
  `sceneOther` varchar(100) NOT NULL COMMENT '其他使用场景',
  `currentWay` varchar(30) NOT NULL COMMENT '目前管理方式',
  `currentWayOther` varchar(100) NOT NULL COMMENT '其他目前管理方式',
  `expect` text NOT NULL COMMENT '执行层期望解决的其他问题',
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- DROP TABLE IF EXISTS `crm_material`;
CREATE TABLE IF NOT EXISTS `crm_material`(
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL,
  `stage` varchar(30) NOT NULL,
  `url` text NOT NULL,
  `platitudes` text NOT NULL,
  `createdBy` varchar(30) NOT NULL,
  `createdDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL,
  `editedDate` datetime NOT NULL,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `sys_category` (`id`, `name`, `parent`, `path`, `grade`, `type`, `order`, `major`) VALUES
('1', '主营业务收入',   '0', ',1,',   '1', 'in',  '1', '1'),
('2', '非主营业务收入', '0', ',2,',   '1', 'in',  '2', '2'),
('3', '主营业务成本',   '0', ',3,',   '1', 'out', '3', '3'),
('4', '非主营业务成本', '0', ',4,',   '1', 'out', '4', '4'),
('5', '理财盈利',       '2', ',2,5,', '2', 'in',  '5', '5'),
('6', '理财亏损',       '4', ',4,6,', '2', 'out', '6', '6'),
('7', '手续费',         '4', ',4,7,', '2', 'out', '7', '7'),
('8', '借贷利息',       '4', ',4,8,', '2', 'out', '8', '8');

INSERT INTO `sys_scorerule` (`id`, `type`, `name`, `score`, `order`, `buildin`) VALUES
('1','system', '工龄积分', '50', '1', '1'),
('2','system', '全勤积分', '10',  '2', '1'),
('3','system', '绩效积分', '50', '3', '1'),
('4','system', '分享积分', '5',  '4', '1');

INSERT INTO `sys_group` VALUES (1,'管理员', 1,'管理员拥有前台所有权限'),(2,'财务专员', 2,'财务专员拥有现金流所有权限'),(3,'销售经理', 3,'销售经理拥有客户管理所有权限'),(4,'销售人员', 4,'默认的销售人员权限'),(5,'普通用户', 5,'默认的普通账号权限');
INSERT INTO `sys_usergroup` (account,`group`) SELECT account,5 FROM `sys_user`;
INSERT INTO `sys_schema` (`name`, `category`, `trader`, `type`, `money`, `desc`, `date`, `fee`) VALUES
('支付宝',       '', 'H', 'K', 'J',   'I,O', 'D', 'M'),
('中信银行简版', '', 'C', '',  'E,D', 'G,H', 'A', '');

INSERT INTO `sys_grouppriv` (`group`, `module`, `method`) VALUES
(1,'action','deleteAllDating'),
(1,'action','finishAllDating'),
(1,'address','browse'),
(1,'address','create'),
(1,'address','delete'),
(1,'address','edit'),
(1,'announce','browse'),
(1,'announce','create'),
(1,'announce','delete'),
(1,'announce','edit'),
(1,'announce','view'),
(1,'apppriv','cash'),
(1,'apppriv','crm'),
(1,'apppriv','doc'),
(1,'apppriv','oa'),
(1,'apppriv','proj'),
(1,'apppriv','superadmin'),
(1,'apppriv','team'),
(1,'apppriv','welfare'),
(1,'attend','attendStat'),
(1,'attend','batchReview'),
(1,'attend','waitReview'),
(1,'attend','company'),
(1,'attend','department'),
(1,'attend','detail'),
(1,'attend','export'),
(1,'attend','exportDetail'),
(1,'attend','exportStat'),
(1,'attend','lateStat'),
(1,'attend','leaveStat'),
(1,'attend','machineSettings'),
(1,'attend','personalSettings'),
(1,'attend','review'),
(1,'attend','saveStat'),
(1,'attend','setManager'),
(1,'attend','settings'),
(1,'attend','syncAttend'),
(1,'balance','browse'),
(1,'balance','create'),
(1,'balance','delete'),
(1,'balance','edit'),
(1,'blog','create'),
(1,'blog','delete'),
(1,'blog','edit'),
(1,'blog','index'),
(1,'blog','view'),
(1,'contact','browse'),
(1,'contact','create'),
(1,'contact','delete'),
(1,'contact','edit'),
(1,'contact','export'),
(1,'contact','exportTemplate'),
(1,'contact','vcard'),
(1,'contact','view'),
(1,'contract','browse'),
(1,'contract','cancel'),
(1,'contract','confirmTeam'),
(1,'contract','create'),
(1,'contract','delete'),
(1,'contract','deleteDelivery'),
(1,'contract','deleteReturn'),
(1,'contract','delivery'),
(1,'contract','edit'),
(1,'contract','editDelivery'),
(1,'contract','editReturn'),
(1,'contract','export'),
(1,'contract','finish'),
(1,'contract','manageTeam'),
(1,'contract','receive'),
(1,'contract','view'),
(1,'company','setBasic'),
(1,'crm','manageAll'),
(1,'cron','index'),
(1,'cron','create'),
(1,'cron','edit'),
(1,'cron','delete'),
(1,'cron','turnon'),
(1,'cron','toggle'),
(1,'customer','assign'),
(1,'customer','batchAssign'),
(1,'customer','browse'),
(1,'customer','contact'),
(1,'customer','contract'),
(1,'customer','create'),
(1,'customer','delete'),
(1,'customer','edit'),
(1,'customer','export'),
(1,'customer','linkContact'),
(1,'customer','order'),
(1,'customer','view'),
(1,'customer','merge'),
(1,'depositor','activate'),
(1,'depositor','browse'),
(1,'depositor','check'),
(1,'depositor','create'),
(1,'depositor','delete'),
(1,'depositor','edit'),
(1,'depositor','export'),
(1,'depositor','forbid'),
(1,'depositor','savebalance'),
(1,'depositor','view'),
(1,'doc','index'),
(1,'doc','allLibs'),
(1,'doc','projectLibs'),
(1,'doc','showFiles'),
(1,'doc','browse'),
(1,'doc','create'),
(1,'doc','createLib'),
(1,'doc','delete'),
(1,'doc','deleteLib'),
(1,'doc','edit'),
(1,'doc','editLib'),
(1,'doc','view'),
(1,'doc','sort'),
(1,'egress','department'),
(1,'egress','company'),
(1,'file','delete'),
(1,'file','download'),
(1,'file','edit'),
(1,'file','upload'),
(1,'forum','admin'),
(1,'forum','board'),
(1,'forum','index'),
(1,'forum','update'),
(1,'holiday','create'),
(1,'holiday','delete'),
(1,'holiday','edit'),
(1,'leads','apply'),
(1,'leads','assign'),
(1,'leads','assignedToNull'),
(1,'leads','browse'),
(1,'leads','batchAssign'),
(1,'leads','batchIgnore'),
(1,'leads','create'),
(1,'leads','delete'),
(1,'leads','edit'),
(1,'leads','export'),
(1,'leads','exportTemplate'),
(1,'leads','ignore'),
(1,'leads','import'),
(1,'leads','setting'),
(1,'leads','showImport'),
(1,'leads','transform'),
(1,'leads','view'),
(1,'leave','batchReview'),
(1,'leave','browseReview'),
(1,'leave','company'),
(1,'leave','export'),
(1,'leave','personalAnnual'),
(1,'leave','review'),
(1,'leave','setReviewer'),
(1,'lieu','browseReview'),
(1,'lieu','company'),
(1,'lieu','review'),
(1,'lieu','batchReview'),
(1,'lieu','setReviewer'),
(1,'makeup','browseReview'),
(1,'makeup','company'),
(1,'makeup','review'),
(1,'makeup','batchReview'),
(1,'makeup','export'),
(1,'makeup','setReviewer'),
(1,'my','company'),
(1,'order','activate'),
(1,'order','assign'),
(1,'order','batchAssign'),
(1,'order','browse'),
(1,'order','close'),
(1,'order','contact'),
(1,'order','create'),
(1,'order','delete'),
(1,'order','edit'),
(1,'order','export'),
(1,'order','view'),
(1,'overtime','browseReview'),
(1,'overtime','company'),
(1,'overtime','review'),
(1,'overtime','batchReview'),
(1,'overtime','export'),
(1,'overtime','setReviewer'),
(1,'product','browse'),
(1,'product','create'),
(1,'product','delete'),
(1,'product','edit'),
(1,'product','view'),
(1,'provider','browse'),
(1,'provider','contact'),
(1,'provider','create'),
(1,'provider','delete'),
(1,'provider','edit'),
(1,'provider','linkContact'),
(1,'provider','merge'),
(1,'provider','view'),
(1,'purchasecontract','browse'),
(1,'purchasecontract','cancel'),
(1,'purchasecontract','create'),
(1,'purchasecontract','delete'),
(1,'purchasecontract','deleteReturn'),
(1,'purchasecontract','edit'),
(1,'purchasecontract','editReturn'),
(1,'purchasecontract','export'),
(1,'purchasecontract','finish'),
(1,'purchasecontract','pay'),
(1,'purchasecontract','view'),
(1,'refund','browseReview'),
(1,'refund','company'),
(1,'refund','reimburse'),
(1,'refund','review'),
(1,'refund','todo'),
(1,'refund','setReviewer'),
(1,'refund','setCategory'),
(1,'refund','setDepositor'),
(1,'refund','setRefundBy'),
(1,'refund','export'),
(1,'report','browse'),
(1,'resume','browse'),
(1,'resume','create'),
(1,'resume','delete'),
(1,'resume','edit'),
(1,'resume','leave'),
(1,'sales','admin'),
(1,'sales','browse'),
(1,'sales','create'),
(1,'sales','delete'),
(1,'sales','edit'),
(1,'schema','browse'),
(1,'schema','create'),
(1,'schema','delete'),
(1,'schema','edit'),
(1,'schema','view'),
(1,'setting','customerPool'),
(1,'setting','lang'),
(1,'setting','modules'),
(1,'setting','reset'),
(1,'task','deleteAll'),
(1,'task','editAll'),
(1,'task','viewAll'),
(1,'thread','delete'),
(1,'thread','deleteFile'),
(1,'thread','edit'),
(1,'thread','post'),
(1,'thread','stick'),
(1,'thread','switchStatus'),
(1,'thread','transfer'),
(1,'thread','view'),
(1,'trade','batchCreate'),
(1,'trade','batchEdit'),
(1,'trade','browse'),
(1,'trade','view'),
(1,'trade','create'),
(1,'trade','delete'),
(1,'trade','detail'),
(1,'trade','edit'),
(1,'trade','export'),
(1,'trade','import'),
(1,'trade','invest'),
(1,'trade','loan'),
(1,'trade','report'),
(1,'trade','transfer'),
(1,'trade','compare'),
(1,'trade','export2Excel'),
(1,'trade','setReportUnit'),
(1,'trade','tradeSetting'),
(1,'tree','browse'),
(1,'tree','children'),
(1,'tree','delete'),
(1,'tree','edit'),
(1,'tree','merge'),
(1,'trip','company'),
(1,'trip','department'),
(1,'user','active'),
(1,'user','admin'),
(1,'user','batchCreate'),
(1,'user','colleague'),
(1,'user','create'),
(1,'user','delete'),
(1,'user','edit'),
(1,'user','exportTemplate'),
(1,'user','forbid'),
(1,'user','import'),
(2,'address','browse'),
(2,'announce','browse'),
(2,'announce','create'),
(2,'announce','edit'),
(2,'announce','view'),
(2,'apppriv','cash'),
(2,'apppriv','crm'),
(2,'apppriv','doc'),
(2,'apppriv','oa'),
(2,'apppriv','proj'),
(2,'apppriv','team'),
(2,'attend','attendStat'),
(2,'attend','company'),
(2,'attend','export'),
(2,'attend','exportStat'),
(2,'attend','saveStat'),
(2,'balance','browse'),
(2,'balance','create'),
(2,'balance','delete'),
(2,'balance','edit'),
(2,'blog','create'),
(2,'blog','edit'),
(2,'blog','index'),
(2,'blog','view'),
(2,'contact','browse'),
(2,'contact','vcard'),
(2,'contact','view'),
(2,'contract','browse'),
(2,'contract','view'),
(2,'crm','manageAll'),
(2,'customer','browse'),
(2,'customer','contact'),
(2,'customer','contract'),
(2,'customer','order'),
(2,'customer','view'),
(2,'depositor','activate'),
(2,'depositor','browse'),
(2,'depositor','check'),
(2,'depositor','create'),
(2,'depositor','delete'),
(2,'depositor','edit'),
(2,'depositor','export'),
(2,'depositor','forbid'),
(2,'depositor','savebalance'),
(2,'doc','index'),
(2,'doc','allLibs'),
(2,'doc','projectLibs'),
(2,'doc','showFiles'),
(2,'doc','browse'),
(2,'doc','create'),
(2,'doc','createLib'),
(2,'doc','edit'),
(2,'doc','editLib'),
(2,'doc','view'),
(2,'doc','sort'),
(2,'forum','admin'),
(2,'forum','board'),
(2,'forum','index'),
(2,'holiday','create'),
(2,'holiday','delete'),
(2,'holiday','edit'),
(2,'leads','browse'),
(2,'leads','view'),
(2,'leave','company'),
(2,'order','browse'),
(2,'order','contact'),
(2,'order','view'),
(2,'product','browse'),
(2,'product','view'),
(2,'provider','browse'),
(2,'provider','contact'),
(2,'provider','create'),
(2,'provider','delete'),
(2,'provider','edit'),
(2,'provider','linkContact'),
(2,'provider','merge'),
(2,'provider','view'),
(2,'purchasecontract','browse'),
(2,'purchasecontract','view'),
(2,'refund','browseReview'),
(2,'refund','company'),
(2,'refund','reimburse'),
(2,'refund','review'),
(2,'refund','todo'),
(2,'refund','setCategory'),
(2,'refund','setDepositor'),
(2,'resume','browse'),
(2,'sales','browse'),
(2,'schema','browse'),
(2,'schema','create'),
(2,'schema','delete'),
(2,'schema','edit'),
(2,'schema','view'),
(2,'setting','lang'),
(2,'setting','reset'),
(2,'thread','edit'),
(2,'thread','post'),
(2,'thread','stick'),
(2,'thread','switchStatus'),
(2,'thread','transfer'),
(2,'thread','view'),
(2,'trade','batchCreate'),
(2,'trade','batchEdit'),
(2,'trade','browse'),
(2,'trade','view'),
(2,'trade','create'),
(2,'trade','delete'),
(2,'trade','detail'),
(2,'trade','edit'),
(2,'trade','export'),
(2,'trade','import'),
(2,'trade','invest'),
(2,'trade','loan'),
(2,'trade','report'),
(2,'trade','transfer'),
(2,'trade','compare'),
(2,'trade','export2Excel'),
(2,'trade','setReportUnit'),
(2,'trade','tradeSetting'),
(2,'tree','browse'),
(2,'tree','children'),
(2,'tree','edit'),
(2,'tree','merge'),
(2,'trip','company'),
(2,'user','colleague'),
(2,'file','upload'),
(2,'file','download'),
(2,'file','edit'),
(2,'file','delete'),
(3,'action','deleteAllDating'),
(3,'action','finishAllDating'),
(3,'address','browse'),
(3,'address','create'),
(3,'address','delete'),
(3,'address','edit'),
(3,'announce','browse'),
(3,'announce','create'),
(3,'announce','edit'),
(3,'announce','view'),
(3,'apppriv','cash'),
(3,'apppriv','crm'),
(3,'apppriv','doc'),
(3,'apppriv','oa'),
(3,'apppriv','proj'),
(3,'apppriv','team'),
(3,'blog','create'),
(3,'blog','edit'),
(3,'blog','index'),
(3,'blog','view'),
(3,'contact','browse'),
(3,'contact','create'),
(3,'contact','delete'),
(3,'contact','edit'),
(3,'contact','export'),
(3,'contact','exportTemplate'),
(3,'contact','vcard'),
(3,'contact','view'),
(3,'contract','browse'),
(3,'contract','cancel'),
(3,'contract','confirmTeam'),
(3,'contract','create'),
(3,'contract','delete'),
(3,'contract','deleteDelivery'),
(3,'contract','deleteReturn'),
(3,'contract','delivery'),
(3,'contract','edit'),
(3,'contract','editDelivery'),
(3,'contract','editReturn'),
(3,'contract','export'),
(3,'contract','finish'),
(3,'contract','manageTeam'),
(3,'contract','receive'),
(3,'contract','view'),
(3,'crm','manageAll'),
(3,'customer','assign'),
(3,'customer','browse'),
(3,'customer','contact'),
(3,'customer','contract'),
(3,'customer','create'),
(3,'customer','delete'),
(3,'customer','edit'),
(3,'customer','export'),
(3,'customer','linkContact'),
(3,'customer','order'),
(3,'customer','view'),
(3,'customer','merge'),
(3,'depositor','browse'),
(3,'doc','index'),
(3,'doc','allLibs'),
(3,'doc','projectLibs'),
(3,'doc','showFiles'),
(3,'doc','browse'),
(3,'doc','create'),
(3,'doc','createLib'),
(3,'doc','edit'),
(3,'doc','editLib'),
(3,'doc','view'),
(3,'doc','sort'),
(3,'egress','department'),
(3,'forum','admin'),
(3,'forum','board'),
(3,'forum','index'),
(3,'leads','apply'),
(3,'leads','assign'),
(3,'leads','assignedToNull'),
(3,'leads','browse'),
(3,'leads','create'),
(3,'leads','edit'),
(3,'leads','delete'),
(3,'leads','ignore'),
(3,'leads','import'),
(3,'leads','setting'),
(3,'leads','showImport'),
(3,'leads','transform'),
(3,'leads','view'),
(3,'leave','browseReview'),
(3,'leave','review'),
(3,'leave','batchReview'),
(3,'lieu','browseReview'),
(3,'lieu','review'),
(3,'lieu','batchReview'),
(3,'makeup','browseReview'),
(3,'makeup','review'),
(3,'makeup','batchReview'),
(3,'order','activate'),
(3,'order','assign'),
(3,'order','batchAssign'),
(3,'order','browse'),
(3,'order','close'),
(3,'order','contact'),
(3,'order','create'),
(3,'order','delete'),
(3,'order','edit'),
(3,'order','export'),
(3,'order','view'),
(3,'overtime','browseReview'),
(3,'overtime','review'),
(3,'overtime','batchReview'),
(3,'product','browse'),
(3,'product','create'),
(3,'product','delete'),
(3,'product','edit'),
(3,'product','view'),
(3,'purchasecontract','browse'),
(3,'purchasecontract','cancel'),
(3,'purchasecontract','create'),
(3,'purchasecontract','delete'),
(3,'purchasecontract','deleteReturn'),
(3,'purchasecontract','edit'),
(3,'purchasecontract','editReturn'),
(3,'purchasecontract','export'),
(3,'purchasecontract','finish'),
(3,'purchasecontract','pay'),
(3,'purchasecontract','view'),
(3,'refund','browseReview'),
(3,'refund','review'),
(3,'resume','browse'),
(3,'resume','create'),
(3,'resume','delete'),
(3,'resume','edit'),
(3,'resume','leave'),
(3,'sales','browse'),
(3,'sales','create'),
(3,'sales','delete'),
(3,'sales','edit'),
(3,'setting','customerPool'),
(3,'setting','lang'),
(3,'setting','reset'),
(3,'thread','edit'),
(3,'thread','post'),
(3,'thread','stick'),
(3,'thread','switchStatus'),
(3,'thread','transfer'),
(3,'thread','view'),
(3,'tree','browse'),
(3,'tree','children'),
(3,'tree','edit'),
(3,'trip','department'),
(3,'user','colleague'),
(3,'file','upload'),
(3,'file','download'),
(3,'file','edit'),
(3,'file','delete'),
(4,'address','browse'),
(4,'address','create'),
(4,'address','edit'),
(4,'announce','browse'),
(4,'announce','create'),
(4,'announce','edit'),
(4,'announce','view'),
(4,'apppriv','cash'),
(4,'apppriv','crm'),
(4,'apppriv','doc'),
(4,'apppriv','oa'),
(4,'apppriv','proj'),
(4,'apppriv','team'),
(4,'attend','waitReview'),
(4,'attend','department'),
(4,'attend','export'),
(4,'attend','review'),
(4,'blog','create'),
(4,'blog','edit'),
(4,'blog','index'),
(4,'blog','view'),
(4,'contact','browse'),
(4,'contact','create'),
(4,'contact','edit'),
(4,'contact','export'),
(4,'contact','exportTemplate'),
(4,'contact','vcard'),
(4,'contact','view'),
(4,'contract','browse'),
(4,'contract','cancel'),
(4,'contract','confirmTeam'),
(4,'contract','create'),
(4,'contract','delivery'),
(4,'contract','edit'),
(4,'contract','editDelivery'),
(4,'contract','editReturn'),
(4,'contract','export'),
(4,'contract','finish'),
(4,'contract','receive'),
(4,'contract','view'),
(4,'customer','assign'),
(4,'customer','batchAssign'),
(4,'customer','browse'),
(4,'customer','contact'),
(4,'customer','contract'),
(4,'customer','create'),
(4,'customer','edit'),
(4,'customer','export'),
(4,'customer','linkContact'),
(4,'customer','order'),
(4,'customer','view'),
(4,'customer','merge'),
(4,'depositor','browse'),
(4,'doc','index'),
(4,'doc','allLibs'),
(4,'doc','projectLibs'),
(4,'doc','showFiles'),
(4,'doc','browse'),
(4,'doc','create'),
(4,'doc','createLib'),
(4,'doc','edit'),
(4,'doc','editLib'),
(4,'doc','view'),
(4,'doc','sort'),
(4,'forum','admin'),
(4,'forum','board'),
(4,'forum','index'),
(4,'leads','apply'),
(4,'leads','assign'),
(4,'leads','browse'),
(4,'leads','create'),
(4,'leads','edit'),
(4,'leads','ignore'),
(4,'leads','import'),
(4,'leads','showImport'),
(4,'leads','transform'),
(4,'leads','view'),
(4,'order','activate'),
(4,'order','assign'),
(4,'order','batchAssign'),
(4,'order','browse'),
(4,'order','close'),
(4,'order','contact'),
(4,'order','create'),
(4,'order','edit'),
(4,'order','export'),
(4,'order','view'),
(4,'product','browse'),
(4,'product','create'),
(4,'product','edit'),
(4,'product','view'),
(4,'purchasecontract','browse'),
(4,'purchasecontract','cancel'),
(4,'purchasecontract','create'),
(4,'purchasecontract','delete'),
(4,'purchasecontract','deleteReturn'),
(4,'purchasecontract','edit'),
(4,'purchasecontract','editReturn'),
(4,'purchasecontract','export'),
(4,'purchasecontract','finish'),
(4,'purchasecontract','pay'),
(4,'purchasecontract','view'),
(4,'resume','browse'),
(4,'resume','create'),
(4,'resume','edit'),
(4,'sales','browse'),
(4,'setting','lang'),
(4,'setting','reset'),
(4,'thread','edit'),
(4,'thread','post'),
(4,'thread','stick'),
(4,'thread','switchStatus'),
(4,'thread','transfer'),
(4,'thread','view'),
(4,'tree','browse'),
(4,'tree','children'),
(4,'tree','edit'),
(4,'user','colleague'),
(4,'file','upload'),
(4,'file','download'),
(4,'file','edit'),
(4,'file','delete'),
(5,'announce','browse'),
(5,'announce','create'),
(5,'announce','edit'),
(5,'announce','view'),
(5,'apppriv','oa'),
(5,'apppriv','doc'),
(5,'apppriv','proj'),
(5,'apppriv','team'),
(5,'blog','create'),
(5,'blog','edit'),
(5,'blog','index'),
(5,'blog','view'),
(5,'doc','index'),
(5,'doc','allLibs'),
(5,'doc','projectLibs'),
(5,'doc','showFiles'),
(5,'doc','browse'),
(5,'doc','create'),
(5,'doc','createLib'),
(5,'doc','edit'),
(5,'doc','editLib'),
(5,'doc','view'),
(5,'doc','sort'),
(5,'forum','admin'),
(5,'forum','board'),
(5,'forum','index'),
(5,'thread','edit'),
(5,'thread','post'),
(5,'thread','stick'),
(5,'thread','switchStatus'),
(5,'thread','transfer'),
(5,'thread','view'),
(5,'user','colleague'),
(5,'file','upload'),
(5,'file','download'),
(5,'file','edit'),
(5,'file','delete');

INSERT INTO `sys_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type`, `buildin`, `status`, `lastTime`) VALUES
('*',    '*', '*',  '*',  '*', '',                                                                 '监控定时任务',     'zdoo', 1, 'normal', '0000-00-00 00:00:00'),
('1',    '1', '*',  '*',  '*', 'appName=sys&moduleName=backup&methodName=backup&reload=0',         '定时备份任务',     'zdoo', 1, 'normal', '0000-00-00 00:00:00'),
('1',    '1', '*',  '*',  '*', 'appName=sys&moduleName=backup&methodName=batchdelete&saveDays=30', '删除30天前的备份', 'zdoo', 1, 'normal', '0000-00-00 00:00:00'),
('1',    '7', '*',  '*',  '*', 'appName=sys&moduleName=report&methodName=remind',                  '每日提醒',         'zdoo', 1, 'normal', '0000-00-00 00:00:00'),
('*/10', '*', '*',  '*',  '*', 'appName=sys&moduleName=notify&methodName=additional',              '检查是否添加待办', 'zdoo', 0, 'normal', '0000-00-00 00:00:00'),
('1',    '1', '*',  '*',  '*', 'appName=sys&moduleName=todo&methodName=createCycle',               '生成周期性待办',   'zdoo', 1, 'normal', '0000-00-00 00:00:00'),
('20',   '0', '1',  '12', '*', 'appName=sys&moduleName=score&methodName=giveService',              '定时发放工龄积分', 'zdoo', 1, 'normal', '0000-00-00 00:00:00'),
('5',    '0', '10', '*',  '*', 'appName=sys&moduleName=score&methodName=giveAttendance',           '定时发放全勤积分', 'zdoo', 1, 'normal', '0000-00-00 00:00:00'),
('5',    '0', '1',  '12', '*', 'appName=sys&moduleName=score&methodName=clearCommon',              '定时清零通用积分', 'zdoo', 1, 'normal', '0000-00-00 00:00:00'),
('10',   '0', '1',  '*',  '*', 'appName=sys&moduleName=score&methodName=giveShare',                '定时发放分享积分', 'zdoo', 1, 'normal', '0000-00-00 00:00:00'),
('15',   '0', '1',  '12', '*', 'appName=sys&moduleName=score&methodName=giveBonus',                '定时发放绩效积分', 'zdoo', 1, 'normal', '0000-00-00 00:00:00'),
('30',   '1', '1',  '1',  '*', 'appName=oa&moduleName=annual&methodName=giveAnnualLeave',          '定时发放年假',     'zdoo', 1, 'normal', '0000-00-00 00:00:00');
-- DROP TABLE IF EXISTS `im_chat`;
CREATE TABLE IF NOT EXISTS `im_chat` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `gid` char(40) NOT NULL DEFAULT '',
  `name` varchar(60) NOT NULL DEFAULT '',
  `type` varchar(20) NOT NULL DEFAULT 'group',
  `admins` varchar(255) NOT NULL DEFAULT '',
  `committers` varchar(255) NOT NULL DEFAULT '',
  `subject` mediumint(8) unsigned NOT NULL DEFAULT 0,
  `public` enum('0', '1') NOT NULL DEFAULT '0',
  `createdBy` varchar(30) NOT NULL DEFAULT '',
  `createdDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `editedBy` varchar(30) NOT NULL DEFAULT '',
  `editedDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `lastActiveTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `lastMessage` int(11) unsigned NOT NULL DEFAULT 0,
  `dismissDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `pinnedMessages` text NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `gid` (`gid`),
  KEY `name` (`name`),
  KEY `type` (`type`),
  KEY `public` (`public`),
  KEY `createdBy` (`createdBy`),
  KEY `editedBy` (`editedBy`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- DROP TABLE IF EXISTS `im_chatuser`;
CREATE TABLE IF NOT EXISTS `im_chatuser` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `cgid` char(40) NOT NULL DEFAULT '',
  `user` mediumint(8) NOT NULL DEFAULT 0,
  `order` smallint(5) NOT NULL DEFAULT 0,
  `star` enum('0', '1') NOT NULL DEFAULT '0',
  `hide` enum('0', '1') NOT NULL DEFAULT '0',
  `mute` enum('0', '1') NOT NULL DEFAULT '0',
  `freeze` enum('0', '1') NOT NULL DEFAULT '0',
  `join` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `quit` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `category` varchar(40) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `cgid` (`cgid`),
  KEY `user` (`user`),
  KEY `order` (`order`),
  KEY `star` (`star`),
  KEY `hide` (`hide`),
  UNIQUE KEY `chatuser` (`cgid`, `user`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- DROP TABLE IF EXISTS `im_client`;
CREATE TABLE IF NOT EXISTS `im_client` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `version` char(30) NOT NULL DEFAULT '',
  `desc` varchar(100) NOT NULL DEFAULT '',
  `changeLog` text NOT NULL,
  `strategy` varchar(10) NOT NULL DEFAULT '',
  `downloads` text NOT NULL,
  `createdDate` datetime NOT NULL,
  `createdBy` varchar(30) NOT NULL DEFAULT '',
  `editedDate` datetime NOT NULL,
  `editedBy` varchar(30) NOT NULL DEFAULT '',
  `status` enum('released','wait') NOT NULL DEFAULT 'wait',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- DROP TABLE IF EXISTS `im_message`;
CREATE TABLE IF NOT EXISTS `im_message` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `gid` char(40) NOT NULL DEFAULT '',
  `cgid` char(40) NOT NULL DEFAULT '',
  `user` varchar(30) NOT NULL DEFAULT '',
  `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `type` enum('normal', 'broadcast', 'notify', 'bulletin') NOT NULL DEFAULT 'normal',
  `content` text NOT NULL DEFAULT '',
  `contentType` enum('text', 'plain', 'emotion', 'image', 'file', 'object', 'code') NOT NULL DEFAULT 'text',
  `data` text NOT NULL DEFAULT '',
  `deleted` enum('0','1') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `mgid` (`gid`),
  KEY `mcgid` (`cgid`),
  KEY `muser` (`user`),
  KEY `mtype` (`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- DROP TABLE IF EXISTS `im_message_backup`;
CREATE TABLE IF NOT EXISTS `im_message_backup` (
  `id` int(11) unsigned NOT NULL,
  `gid` char(40) NOT NULL DEFAULT '',
  `cgid` char(40) NOT NULL DEFAULT '',
  `user` varchar(30) NOT NULL DEFAULT '',
  `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `type` enum('normal', 'broadcast', 'notify') NOT NULL DEFAULT 'normal',
  `content` text NOT NULL DEFAULT '',
  `contentType` enum('text', 'plain', 'emotion', 'image', 'file', 'object', 'code') NOT NULL DEFAULT 'text',
  `data` text NOT NULL DEFAULT '',
  `deleted` enum('0','1') NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- DROP TABLE IF EXISTS `im_message_index`;
CREATE TABLE IF NOT EXISTS `im_message_index` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `tableName` char(64) NOT NULL,
  `start` int(11) unsigned NOT NULL,
  `end` int(11) unsigned NOT NULL,
  `startDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `endDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `chats` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tableName` (`tableName`),
  KEY `start` (`start`),
  KEY `end` (`end`),
  KEY `startDate` (`startDate`),
  KEY `endDate` (`endDate`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- DROP TABLE IF EXISTS `im_chat_message_index`;
CREATE TABLE IF NOT EXISTS `im_chat_message_index` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `gid` char(40) NOT NULL,
  `tableName` char(64) NOT NULL,
  `start` int(11) unsigned NOT NULL,
  `end` int(11) unsigned NOT NULL,
  `startDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `endDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `count` mediumint(8) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `chattable` (`gid`,`tableName`),
  KEY `start` (`start`),
  KEY `end` (`end`),
  KEY `startDate` (`startDate`),
  KEY `endDate` (`endDate`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- DROP TABLE IF EXISTS `im_messagestatus`;
CREATE TABLE IF NOT EXISTS `im_messagestatus` (
  `user` mediumint(8) NOT NULL DEFAULT 0,
  `message` int(11) unsigned NOT NULL,
  `status` enum('waiting','sent','readed','deleted') NOT NULL DEFAULT 'waiting',
  UNIQUE KEY `user` (`user`,`message`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- DROP TABLE IF EXISTS `im_queue`;
CREATE TABLE IF NOT EXISTS `im_queue` (
  `id` mediumint(8) unsigned NOT NULL auto_increment,
  `type` char(30) NOT NULL,
  `content` text NOT NULL,
  `addDate` datetime NOT NULL,
  `processDate` datetime NOT NULL,
  `result` text NOT NULL,
  `status` char(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

-- DROP TABLE IF EXISTS `im_conference`;
CREATE TABLE IF NOT EXISTS `im_conference` (
  `id` mediumint(8) unsigned NOT NULL auto_increment,
  `rid` char(24) NOT NULL DEFAULT '',
  `cgid` char(40) NOT NULL DEFAULT '',
  `status` enum('closed','open') NOT NULL DEFAULT 'closed',
  `participants` text NOT NULL,
  `invitee` text NOT NULL,
  `openedBy` mediumint(8) NOT NULL DEFAULT 0,
  `openedDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

-- DROP TABLE IF EXISTS `im_conferenceaction`;
CREATE TABLE IF NOT EXISTS `im_conferenceaction` (
  `id` mediumint(8) unsigned NOT NULL auto_increment,
  `rid` char(24) NOT NULL DEFAULT '',
  `type` enum('create','join','leave','close') NOT NULL DEFAULT 'create',
  `user` mediumint(8) NOT NULL DEFAULT 0,
  `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `device` char(40) NOT NULL DEFAULT 'default',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

-- DROP TABLE IF EXISTS `im_userdevice`;
CREATE TABLE IF NOT EXISTS `im_userdevice` (
  `id` mediumint(8) unsigned NOT NULL auto_increment,
  `user` mediumint(8) NOT NULL DEFAULT 0,
  `device` char(40) NOT NULL DEFAULT 'default',
  `deviceID` char(40) NOT NULL DEFAULT '',
  `token` char(64) NOT NULL DEFAULT '',
  `validUntil` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `lastLogin` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `lastLogout` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`),
  KEY `user` (`user`),
  KEY `lastLogin` (`lastLogin`),
  KEY `lastLogout` (`lastLogout`),
  UNIQUE KEY `userdevice` (`user`, `device`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

ALTER TABLE `sys_entry` ADD `sso` enum('0', '1') NOT NULL DEFAULT '0';
ALTER TABLE `sys_file` CHANGE `pathname` `pathname` char(100) NOT NULL;
ALTER TABLE `sys_user` ADD `clientStatus` enum('online', 'away', 'busy', 'offline', 'meeting') NOT NULL DEFAULT 'offline';
ALTER TABLE `sys_user` ADD `clientLang` varchar(10) NOT NULL DEFAULT 'zh-cn';
