-- $Revision: 1599 $  --
CREATE TABLE `perlDesk_accesslog` (`id` int(11) unsigned NOT NULL auto_increment, `user` varchar(255) default NULL, `ip` varchar(255) default NULL, `time` varchar(255) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_activitylog` (`id` int(11) unsigned NOT NULL auto_increment, `cid` varchar(255) NOT NULL, `date` varchar(255) NOT NULL, `user` varchar(255) NOT NULL, `action` varchar(255) NOT NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_announce` (`id` int(11) unsigned NOT NULL auto_increment, `author` varchar(255) default NULL, `subject` varchar(255) default NULL, `message` text default NULL, `staff` char(1) default NULL, `users` char(1) default NULL, `time` varchar(16) default NULL, `display_until` varchar(255) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_blocked_email` (`id` int(11) unsigned NOT NULL auto_increment, `address` varchar(255) NOT NULL, `type` varchar(255) NOT NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_call_fields` (`id` int(11) unsigned NOT NULL auto_increment, `cid` varchar(255) default NULL, `fid` varchar(255) default NULL, `value` text default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_callrules` (`id` int(11) unsigned NOT NULL auto_increment, `rule` int(11) NOT NULL, `type` text default NULL, `value` text DEFAULT NULL, `param` text DEFAULT NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_calls` (`id` int(11) unsigned NOT NULL auto_increment, `status` ENUM ('OPEN','CLOSED','HOLD','DELETED') NOT NULL, `username` varchar(30) default NULL, `email` varchar(255) default NULL, `priority` char(1) default NULL, `category` varchar(255) default NULL, `subject` varchar(255) default NULL, `description` text default NULL, `time` varchar(20) default NULL, `ownership` varchar(255) default NULL, `closedby` varchar(255) default NULL, `method` char(2) default NULL, `track` varchar(50) NOT NULL, `active` varchar(50) NOT NULL, `aw` char(1) default NULL, `an` char(1) NOT NULL, `time_spent` varchar(255) NOT NULL, `sub_status` text default NULL, `is_locked` int(11) NOT NULL, `ikey` varchar(255) NOT NULL, `close_timer` int(11) default NULL, `lock_time` int(11) default NULL, `due_date` datetime default NULL, `color` varchar(255) default NULL, `responses` int(11) unsigned NOT NULL default 0, `lastnote` int(11) unsigned default NULL, PRIMARY KEY (`id`), INDEX (`status`));
CREATE TABLE `perlDesk_calls_timespent` (`id` int(11) unsigned NOT NULL auto_increment, `when` timestamp NOT NULL, `staff` varchar(30) NOT NULL, `username` varchar(30) NOT NULL, `useremail` varchar(255), `call_id` int(11) unsigned NOT NULL, `timespent` int(11) unsigned NOT NULL , PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_chatsession` (`id` int(11) unsigned NOT NULL auto_increment, `time` TIMESTAMP NOT NULL, `activity` TIMESTAMP NOT NULL, `username` VARCHAR(30) default NULL, `staffname` VARCHAR(20) DEFAULT NULL, `department` VARCHAR(255) DEFAULT NULL,  `state` text, `message` text, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_contacts` (`id` int(11) unsigned NOT NULL auto_increment, `staff` int(11) NOT NULL, `name` varchar(50) NOT NULL, `company` varchar(50) NOT NULL, `address` varchar(255) NOT NULL, `email` varchar(90) NOT NULL, `phone` varchar(19) default NULL, `url` varchar(90) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_cronrules` (`id` int(11) unsigned NOT NULL auto_increment, `period` int(11) NOT NULL, `action` text default NULL, `lastrun` INT NOT NULL, `lastcheck` INT NOT NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_debug` (`id` int(11) unsigned NOT NULL auto_increment, `time` TIMESTAMP NOT NULL, `priority` varchar(10), `category` varchar(25), `file` varchar(50), `function` varchar(50), `message` varchar(255), PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_departments` (`id` int(11) unsigned NOT NULL auto_increment, `level` varchar(255) default NULL, `from_name` text default NULL, `from_email` text default NULL, `assign_staff` text default NULL, `internal` int(1) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_downloadcats` (`id` int(11) unsigned NOT NULL auto_increment, `parent_id` int(11) default NULL, `name` varchar(255) default NULL, `assign_staff` text default NULL, `datetime` timestamp , PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_downloadfiles` (`id` int(11) unsigned NOT NULL auto_increment, `filename` varchar(255) default NULL, `parent_id` int(11) unsigned NOT NULL, `subject` text NOT NULL, `keywords` text default NULL, `description` text default NULL, `pd_file_id` int(11) NOT NULL, `owner` int(11) default NULL, `datetime` timestamp , PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_em_forwarders` (`id` int(11) unsigned NOT NULL auto_increment, `address` varchar(255) default NULL, `category` varchar(255) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_em_floodprotect` (`id` int(11) NOT NULL auto_increment, `sender` varchar(255) default NULL, `timestamp` varchar(255) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_emaillog` (`id` int(11) unsigned NOT NULL auto_increment, `time` TIMESTAMP NOT NULL, `direction` int(11) default 0, `from` varchar(255), `to` varchar(255), `msgid` varchar(255), `subject` varchar(255), `log` varchar(255), PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_files` (`id` int(11) unsigned NOT NULL auto_increment, `cid` int(11) default NULL, `nid` int(11) default NULL, `filename` varchar(255) NOT NULL, `file` varchar(255) NOT NULL, `kb` int(11) default NULL, `type` text default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_kb_acronym` (`id` int(11) unsigned NOT NULL auto_increment, `letter` char(1) default NULL, `acronym` varchar(255) default NULL, `acronymname` varchar(255) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_kb_cat` (`id` int(11) unsigned NOT NULL auto_increment, `category` varchar(255) default NULL, `parent_category` int(11) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_kb_comments` (`id` int(11) unsigned NOT NULL auto_increment, `article_id` int(11) default NULL, `name` varchar(255) default NULL, `email` varchar(255) default NULL, `comments` text default NULL, PRIMARY KEY (`id`), INDEX (`article_id`));
CREATE TABLE `perlDesk_kb_entries` (`id` int(11) unsigned NOT NULL auto_increment, `category` varchar(255) default NULL, `catid` int(11) default NULL, `author` varchar(255) default NULL, `subject` varchar(255) default NULL, `keywords` text default NULL, `description` text default NULL, `views` varchar(50) default NULL, `stamp` timestamp , `filetype` varchar(255) default NULL, `fileid` int(11) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_kb_glossary` (`id` int(11) unsigned NOT NULL auto_increment, `letter` char(1) default NULL, `shortname` varchar(255) default NULL, `description` text default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_kb_ratings` (`id` int(11) unsigned NOT NULL auto_increment, `article_id` int(11) default NULL, `word_id` int(11) default NULL, `rating` int(2) default NULL, PRIMARY KEY (`id`), INDEX (`article_id`), INDEX (`word_id`));
CREATE TABLE `perlDesk_kb_stats` (`id` int(11) unsigned NOT NULL auto_increment, `article_id` int(11) default NULL, `number` int(11) default NULL, `date` date default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_kb_words` (`id` int(11) unsigned NOT NULL auto_increment, `word` varchar(255) default NULL, PRIMARY KEY (`id`), UNIQUE INDEX (`word`));
CREATE TABLE `perlDesk_mailrules` (`id` int(11) unsigned NOT NULL auto_increment, `rule_id` int(11) default NULL, `rule` int(5) default NULL, `action` int(5) default NULL, `text` text default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_messages` (`id` int(11) unsigned NOT NULL auto_increment, `touser` varchar(50) NOT NULL, `sender` varchar(50) NOT NULL, `date` varchar(20) NOT NULL, `subject` varchar(255) NOT NULL, `message` text NOT NULL, `stamp` varchar(20) NOT NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_notedrafts` (`id` int(11) unsigned NOT NULL auto_increment, `owner` char(1) default NULL, `visible` char(1) default NULL, `action` varchar(255) default NULL, `call` int(11) default NULL, `author` varchar(255) default NULL, `time` varchar(20) default NULL, `ikey` varchar(255) default NULL, `comment` text default NULL, `poster_ip` varchar(40) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_notes` (`id` int(11) unsigned NOT NULL auto_increment, `owner` char(1) default NULL, `visible` char(1) default NULL, `action` varchar(255) default NULL, `call` int(11) default NULL, `author` varchar(255) default NULL, `time` varchar(20) default NULL, `ikey` varchar(255) default NULL, `comment` text default NULL, `poster_ip` varchar(40) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_preans` (`id` int(11) unsigned NOT NULL auto_increment, `author` varchar(25) default NULL, `subject` varchar(255) default NULL, `text` text default NULL, `date` varchar(20) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_reviews` (`id` int(11) unsigned NOT NULL auto_increment, `owner` varchar(255) default NULL, `staff` varchar(255) default NULL, `nid` varchar(255) default NULL, `rating` varchar(255) default NULL, `comments` text default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_settings` (`setting` varchar(50) NOT NULL, `value` varchar(225) default NULL, PRIMARY KEY (`setting`));
CREATE TABLE `perlDesk_settings_extra` (`setting` varchar(50) NOT NULL, `value` text default NULL, PRIMARY KEY (`setting`));
CREATE TABLE `perlDesk_signup_fields` (`id` int(11) unsigned NOT NULL auto_increment, `name` varchar(255) default NULL, `value` varchar(255) default NULL, `dorder` varchar(10) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_signup_values` (`id` int(11) unsigned NOT NULL auto_increment, `cid` varchar(10) default NULL, `sid` varchar(10) default NULL, `value` varchar(255) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_staffaccess` (`staff_id` int(11) default NULL, `dep_id` int(11) default NULL);
CREATE TABLE `perlDesk_staffactive` (`username` varchar(20) NOT NULL, `date` varchar(20) NOT NULL);
CREATE TABLE `perlDesk_stafflogin` (`username` varchar(50) default NULL, `date` varchar(20) default NULL);
CREATE TABLE `perlDesk_staffread` (`username` varchar(50) NOT NULL, `date` varchar(20) NOT NULL);
CREATE TABLE `perlDesk_survey` (`id` int(11) unsigned NOT NULL auto_increment, `order` int(11) default NULL, `text` varchar(30) NOT NULL, PRIMARY KEY (`id`) );
CREATE TABLE `perlDesk_taskbar` (`id` int(11) unsigned NOT NULL auto_increment, `username` varchar(50) default NULL, `last_call` varchar(50) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_tasks` (`id` int(11) NOT NULL auto_increment, `user_id` int(11) default NULL, `name` varchar(50) default NULL, `details` varchar(255) default NULL, `time` datetime default NULL, `notify` tinyint(4) default NULL, `notify_type` tinyint(4) default NULL, `notify_earlier` int(11) default NULL, `notify_email` varchar(255) default NULL, `your_period` int(11) default NULL, `status` tinyint(4) default NULL, `stamp` timestamp , `callid` int(11) default NULL, `progress` int(11) default 0, `lastingdays` int(11) default 0, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_templates` (`id` int(11) NOT NULL auto_increment, `user_dir` text default NULL, `staff_dir` text default NULL, `admin_dir` text default NULL, `name` text default NULL, `img_dir` text default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_ticket_fields` (`id` int(11) unsigned NOT NULL auto_increment, `name` varchar(255) default NULL, `value` varchar(255) default NULL, `dorder` varchar(10) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_tshooter` (`id` int(11) NOT NULL auto_increment, `name` varchar(50) default NULL, `first_question_id` int(11) default NULL, `stamp` timestamp , PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_tshooter_archive` (`id` int(11) NOT NULL auto_increment, `tshooter_id` int(11) default NULL, `parent_id` int(11) default NULL, `name` varchar(255) default NULL, `question` text default NULL, `answer` text default NULL, `level` tinyint(4) default NULL, `action_type` tinyint(4) default NULL, `stamp` timestamp , PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_user_events` (`id` int(11) unsigned NOT NULL auto_increment, `user` varchar(255) default NULL, `time` varchar(255) default NULL, `subject` varchar(255) default NULL, `description` text default NULL, `date` varchar(50) default NULL, PRIMARY KEY (`id`));
CREATE TABLE `perlDesk_usergroups` (`id` int(11) NOT NULL auto_increment, `name` varchar(255) default NULL, PRIMARY KEY (`id`));
REPLACE INTO perlDesk_cronrules (period, action, lastrun, lastcheck) VALUES ('1800', 'check_calls', 0, 0);
