SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ;
USE `mydb`;

-- -----------------------------------------------------
-- Table `mydb`.`user`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`user` (
  `idUSER` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `jmeno` VARCHAR(25) NOT NULL ,
  `prijmeni` VARCHAR(28) NOT NULL ,
  `login` VARCHAR(12) NOT NULL ,
  `password` VARCHAR(40) NOT NULL ,
  `email` VARCHAR(45) NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  PRIMARY KEY (`idUSER`) ,
  UNIQUE INDEX `login` (`login` ASC) ,
  UNIQUE INDEX `email` (`email` ASC) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`cdr`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`cdr` (
  `idCDR` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `calldate` DATETIME NOT NULL DEFAULT 0000-00-00 00:00:00 ,
  `clid` VARCHAR(80) NOT NULL ,
  `src` VARCHAR(80) NOT NULL ,
  `dst` VARCHAR(80) NOT NULL ,
  `dcontext` VARCHAR(80) NOT NULL ,
  `channel` VARCHAR(80) NOT NULL ,
  `dstchannel` VARCHAR(80) NOT NULL ,
  `lastapp` VARCHAR(80) NOT NULL ,
  `lastdata` VARCHAR(80) NOT NULL ,
  `duration` INT NOT NULL DEFAULT 0 ,
  `billsec` INT NOT NULL DEFAULT 0 ,
  `disposition` VARCHAR(45) NOT NULL ,
  `amaflags` INT NOT NULL DEFAULT 0 ,
  `accountcode` VARCHAR(20) NOT NULL ,
  `uniqueid` VARCHAR(32) NOT NULL ,
  `userfield` VARCHAR(255) NOT NULL ,
  INDEX `calldate` (`calldate` ASC) ,
  INDEX `dst` (`dst` ASC) ,
  INDEX `accountcode` (`accountcode` ASC) ,
  PRIMARY KEY (`idCDR`) )
ENGINE = InnoDB
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`union_cost`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`union_cost` (
  `idCENAJEDNOTKY` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `cost` INT NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  PRIMARY KEY (`idCENAJEDNOTKY`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Table `mydb`.`tarif`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`tarif` (
  `idTARIF` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `Name` VARCHAR(32) NOT NULL ,
  `idCENAJEDNOTKY` INT UNSIGNED NOT NULL ,
  `description` VARCHAR(255) NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  INDEX `fk_TARIF_CENA_JEDNOTKY1` (`idCENAJEDNOTKY` ASC) ,
  PRIMARY KEY (`idTARIF`) ,
  UNIQUE INDEX `Name` (`Name` ASC) ,
  CONSTRAINT `fk_TARIF_CENA_JEDNOTKY1`
    FOREIGN KEY (`idCENAJEDNOTKY` )
    REFERENCES `mydb`.`union_cost` (`idCENAJEDNOTKY` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Table `mydb`.`functions`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`functions` (
  `idFUNCTIONS` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `Name` VARCHAR(32) NOT NULL ,
  `description` VARCHAR(255) NULL ,
  `last_change` TIMESTAMP NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `scriptname` VARCHAR(40) NOT NULL ,
  PRIMARY KEY (`idFUNCTIONS`) ,
  UNIQUE INDEX `Name` (`Name` ASC) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`billing_period`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`billing_period` (
  `idBILLINGPERIOD` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `uptotime` INT NOT NULL ,
  `unionnum` INT UNSIGNED ZEROFILL NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  PRIMARY KEY (`idBILLINGPERIOD`) ,
  UNIQUE INDEX `uniq` (`uptotime` ASC, `unionnum` ASC) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Table `mydb`.`spec_billing_period`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`spec_billing_period` (
  `idTARIF` INT UNSIGNED NOT NULL ,
  `idBILLINGPERIOD` INT UNSIGNED NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  PRIMARY KEY (`idTARIF`, `idBILLINGPERIOD`) ,
  INDEX `fk_TARIF_has_BILLING_PERIOD_TARIF1` (`idTARIF` ASC) ,
  INDEX `fk_TARIF_has_BILLING_PERIOD_1` (`idBILLINGPERIOD` ASC) ,
  CONSTRAINT `fk_TARIF_has_BILLING_PERIOD_TARIF1`
    FOREIGN KEY (`idTARIF` )
    REFERENCES `mydb`.`tarif` (`idTARIF` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_TARIF_has_BILLING_PERIOD_1`
    FOREIGN KEY (`idBILLINGPERIOD` )
    REFERENCES `mydb`.`billing_period` (`idBILLINGPERIOD` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Table `mydb`.`provider`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`provider` (
  `idPROVIDER` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(15) NOT NULL ,
  `last_change` TIMESTAMP NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `description` VARCHAR(255) NULL ,
  PRIMARY KEY (`idPROVIDER`) ,
  UNIQUE INDEX `name` (`name` ASC) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`trunk`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`trunk` (
  `idTrunk` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `Name` VARCHAR(45) NOT NULL ,
  `HOST` VARCHAR(60) NOT NULL ,
  `description` VARCHAR(255) NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  `idPROVIDER` INT UNSIGNED NOT NULL ,
  PRIMARY KEY (`idTrunk`) ,
  INDEX `fk_TRUNK_PROVIDER1` (`idPROVIDER` ASC) ,
  UNIQUE INDEX `Name` (`Name` ASC) ,
  CONSTRAINT `fk_TRUNK_PROVIDER1`
    FOREIGN KEY (`idPROVIDER` )
    REFERENCES `mydb`.`provider` (`idPROVIDER` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`technology`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`technology` (
  `idTECHNOLOGY` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `technology` VARCHAR(45) NOT NULL ,
  `table_name` VARCHAR(45) NOT NULL ,
  PRIMARY KEY (`idTECHNOLOGY`) ,
  UNIQUE INDEX `unikatni` (`technology` ASC) ,
  UNIQUE INDEX `unikatni2` (`table_name` ASC) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`bill`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`bill` (
  `idBILL` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `last_change` TIMESTAMP NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  PRIMARY KEY (`idBILL`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Table `mydb`.`user_account`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`user_account` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `idTECHNOLOGY` INT UNSIGNED NOT NULL ,
  `idUSER` INT UNSIGNED NOT NULL ,
  `idBILL` INT UNSIGNED NOT NULL ,
  `last_change` TIMESTAMP NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  INDEX `fk_USER_ACCOUNT_TECHNOLOGY1` (`idTECHNOLOGY` ASC) ,
  INDEX `fk_USER_ACCOUNT_USER1` (`idUSER` ASC) ,
  PRIMARY KEY (`id`, `idTECHNOLOGY`) ,
  INDEX `fk_USER_ACCOUNT_bill1` (`idBILL` ASC) ,
  CONSTRAINT `fk_USER_ACCOUNT_TECHNOLOGY1`
    FOREIGN KEY (`idTECHNOLOGY` )
    REFERENCES `mydb`.`technology` (`idTECHNOLOGY` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_USER_ACCOUNT_USER1`
    FOREIGN KEY (`idUSER` )
    REFERENCES `mydb`.`user` (`idUSER` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_USER_ACCOUNT_bill1`
    FOREIGN KEY (`idBILL` )
    REFERENCES `mydb`.`bill` (`idBILL` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`dest_number`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`dest_number` (
  `idNUMBER` INT UNSIGNED NOT NULL ,
  `number` VARCHAR(10) NOT NULL ,
  `last_change` TIMESTAMP NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  PRIMARY KEY (`idNUMBER`) ,
  UNIQUE INDEX `number` (`number` ASC) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Table `mydb`.`tarif_mix`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`tarif_mix` (
  `idTARIFMIX` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `Name` VARCHAR(45) NOT NULL ,
  `start_date` DATETIME NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  `description` VARCHAR(160) NULL ,
  PRIMARY KEY (`idTARIFMIX`) ,
  UNIQUE INDEX `unique Name` (`Name` ASC) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Table `mydb`.`spec_tarif_mix`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`spec_tarif_mix` (
  `idNUMBER` INT UNSIGNED NOT NULL ,
  `idTRUNK` INT UNSIGNED NOT NULL ,
  `idTARIF` INT UNSIGNED NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  `idTARIFMIX` INT UNSIGNED NOT NULL ,
  INDEX `fk_SPEC_TRUNK_TRUNK1` (`idTRUNK` ASC) ,
  INDEX `fk_SPEC_TRUNK_DEST_NUMBER1` (`idNUMBER` ASC) ,
  INDEX `fk_SPEC_TRUNK_TARIF1` (`idTARIF` ASC) ,
  PRIMARY KEY (`idNUMBER`, `idTARIFMIX`) ,
  INDEX `fk_SPEC_TRUNK_tarif_mix1` (`idTARIFMIX` ASC) ,
  CONSTRAINT `fk_SPEC_TRUNK_TRUNK1`
    FOREIGN KEY (`idTRUNK` )
    REFERENCES `mydb`.`trunk` (`idTrunk` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_SPEC_TRUNK_DEST_NUMBER1`
    FOREIGN KEY (`idNUMBER` )
    REFERENCES `mydb`.`dest_number` (`idNUMBER` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_SPEC_TRUNK_TARIF1`
    FOREIGN KEY (`idTARIF` )
    REFERENCES `mydb`.`tarif` (`idTARIF` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_SPEC_TRUNK_tarif_mix1`
    FOREIGN KEY (`idTARIFMIX` )
    REFERENCES `mydb`.`tarif_mix` (`idTARIFMIX` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Table `mydb`.`user_group`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`user_group` (
  `idUSERGROUP` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `Name` VARCHAR(45) NOT NULL ,
  `description` VARCHAR(255) NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  PRIMARY KEY (`idUSERGROUP`) ,
  UNIQUE INDEX `Name` (`Name` ASC) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`spec_group_rights`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`spec_group_rights` (
  `idUSERGROUP` INT UNSIGNED NOT NULL ,
  `idFUNCTIONS` INT UNSIGNED NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  PRIMARY KEY (`idFUNCTIONS`, `idUSERGROUP`) ,
  INDEX `fk_SPEC_GROUP_RIGHTS_FUNCTION1` (`idFUNCTIONS` ASC) ,
  INDEX `fk_SPEC_GROUP_RIGHTS_USER_GROUP1` (`idUSERGROUP` ASC) ,
  CONSTRAINT `fk_SPEC_GROUP_RIGHTS_FUNCTION1`
    FOREIGN KEY (`idFUNCTIONS` )
    REFERENCES `mydb`.`functions` (`idFUNCTIONS` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_SPEC_GROUP_RIGHTS_USER_GROUP1`
    FOREIGN KEY (`idUSERGROUP` )
    REFERENCES `mydb`.`user_group` (`idUSERGROUP` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`spec_user_group`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`spec_user_group` (
  `idUSER` INT UNSIGNED NOT NULL ,
  `idUSERGROUP` INT UNSIGNED NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NULL ,
  PRIMARY KEY (`idUSER`, `idUSERGROUP`) ,
  INDEX `fk_USER_GROUP_has_USER_USER1` (`idUSER` ASC) ,
  INDEX `fk_SPEC_USER_GROUP_USER_GROUP1` (`idUSERGROUP` ASC) ,
  CONSTRAINT `fk_USER_GROUP_has_USER_USER1`
    FOREIGN KEY (`idUSER` )
    REFERENCES `mydb`.`user` (`idUSER` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_SPEC_USER_GROUP_USER_GROUP1`
    FOREIGN KEY (`idUSERGROUP` )
    REFERENCES `mydb`.`user_group` (`idUSERGROUP` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`direction`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`direction` (
  `idDIRECTION` INT UNSIGNED NOT NULL ,
  `name` VARCHAR(10) NOT NULL ,
  PRIMARY KEY (`idDIRECTION`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`call_records`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`call_records` (
  `idCALL_RECORDS` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `idCDR` INT UNSIGNED NOT NULL ,
  `id` INT UNSIGNED NOT NULL ,
  `idTECHNOLOGY` INT UNSIGNED NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  `price` FLOAT NULL ,
  `checked` TINYINT(1) NOT NULL DEFAULT 0 ,
  `idTARIF` INT UNSIGNED NULL ,
  `idDIRECTION` INT UNSIGNED NOT NULL ,
  `idPAYTYPE` INT UNSIGNED NULL ,
  PRIMARY KEY (`idCALL_RECORDS`) ,
  INDEX `fk_CALL_RECORDS_CDR1` (`idCDR` ASC) ,
  INDEX `fk_call_records_user_account1` (`id` ASC, `idTECHNOLOGY` ASC) ,
  INDEX `fk_call_records_direction1` (`idDIRECTION` ASC) ,
  CONSTRAINT `fk_CALL_RECORDS_CDR1`
    FOREIGN KEY (`idCDR` )
    REFERENCES `mydb`.`cdr` (`idCDR` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_call_records_user_account1`
    FOREIGN KEY (`id` , `idTECHNOLOGY` )
    REFERENCES `mydb`.`user_account` (`id` , `idTECHNOLOGY` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_call_records_direction1`
    FOREIGN KEY (`idDIRECTION` )
    REFERENCES `mydb`.`direction` (`idDIRECTION` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`period`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`period` (
  `idObdobi` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `since` DATETIME NOT NULL ,
  `to` DATETIME NOT NULL ,
  PRIMARY KEY (`idObdobi`) ,
  UNIQUE INDEX `time` (`since` ASC, `to` ASC) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`function_sequences`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`function_sequences` (
  `idFUNCTIONS` INT UNSIGNED NOT NULL ,
  `idnextFUNCTIONS` INT UNSIGNED NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `lastchange` TIMESTAMP NOT NULL ,
  `submenu` TINYINT(1) NOT NULL DEFAULT 0 ,
  PRIMARY KEY (`idFUNCTIONS`, `idnextFUNCTIONS`) ,
  INDEX `fk_FUNCTION_SEQUENCES_FUNCTION1` (`idFUNCTIONS` ASC) ,
  INDEX `fk_FUNCTION_SEQUENCES_FUNCTION2` (`idnextFUNCTIONS` ASC) ,
  CONSTRAINT `fk_FUNCTION_SEQUENCES_FUNCTION1`
    FOREIGN KEY (`idFUNCTIONS` )
    REFERENCES `mydb`.`functions` (`idFUNCTIONS` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_FUNCTION_SEQUENCES_FUNCTION2`
    FOREIGN KEY (`idnextFUNCTIONS` )
    REFERENCES `mydb`.`functions` (`idFUNCTIONS` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`sip_buddies`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`sip_buddies` (
  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(80) NOT NULL DEFAULT '' ,
  `accountcode` VARCHAR(20) NULL DEFAULT NULL ,
  `amaflags` VARCHAR(13) NULL DEFAULT NULL ,
  `callgroup` VARCHAR(10) NULL DEFAULT NULL ,
  `callerid` VARCHAR(80) NULL DEFAULT NULL ,
  `canreinvite` CHAR(3) NULL DEFAULT 'no' ,
  `context` VARCHAR(80) NULL DEFAULT NULL ,
  `defaultip` VARCHAR(15) NULL DEFAULT NULL ,
  `dtmfmode` VARCHAR(7) NULL DEFAULT NULL ,
  `fromuser` VARCHAR(80) NULL DEFAULT NULL ,
  `fromdomain` VARCHAR(80) NULL DEFAULT NULL ,
  `fullcontact` VARCHAR(80) NULL DEFAULT NULL ,
  `host` VARCHAR(31) NOT NULL DEFAULT '' ,
  `insecure` VARCHAR(4) NULL DEFAULT NULL ,
  `language` CHAR(2) NULL DEFAULT NULL ,
  `mailbox` VARCHAR(50) NULL DEFAULT NULL ,
  `md5secret` VARCHAR(80) NULL DEFAULT NULL ,
  `nat` VARCHAR(5) NOT NULL DEFAULT 'no' ,
  `deny` VARCHAR(95) NULL DEFAULT NULL ,
  `permit` VARCHAR(95) NULL DEFAULT NULL ,
  `mask` VARCHAR(95) NULL DEFAULT NULL ,
  `pickupgroup` VARCHAR(10) NULL DEFAULT NULL ,
  `port` VARCHAR(5) NOT NULL DEFAULT '' ,
  `qualify` CHAR(3) NULL DEFAULT 'no' ,
  `restrictcid` CHAR(1) NULL DEFAULT NULL ,
  `rtptimeout` CHAR(3) NULL DEFAULT NULL ,
  `rtpholdtimeout` CHAR(3) NULL DEFAULT NULL ,
  `secret` VARCHAR(80) NULL DEFAULT NULL ,
  `type` VARCHAR(6) NOT NULL DEFAULT 'friend' ,
  `username` VARCHAR(80) NOT NULL DEFAULT '' ,
  `disallow` VARCHAR(100) NULL DEFAULT 'all' ,
  `allow` VARCHAR(100) NULL DEFAULT 'gsm;ulaw;alaw' ,
  `musiconhold` VARCHAR(100) NULL DEFAULT NULL ,
  `regseconds` INT(11) NOT NULL DEFAULT '0' ,
  `ipaddr` VARCHAR(15) NOT NULL DEFAULT '' ,
  `regexten` VARCHAR(80) NOT NULL DEFAULT '' ,
  `cancallforward` CHAR(3) NULL DEFAULT 'yes' ,
  `setvar` VARCHAR(100) NOT NULL DEFAULT '' ,
  PRIMARY KEY (`id`) ,
  UNIQUE INDEX `name` (`name` ASC) ,
  INDEX `name_2` (`name` ASC) )
ENGINE = InnoDB
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`sip_buddies`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`sip_buddies` (
  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(80) NOT NULL DEFAULT '' ,
  `accountcode` VARCHAR(20) NULL DEFAULT NULL ,
  `amaflags` VARCHAR(13) NULL DEFAULT NULL ,
  `callgroup` VARCHAR(10) NULL DEFAULT NULL ,
  `callerid` VARCHAR(80) NULL DEFAULT NULL ,
  `canreinvite` CHAR(3) NULL DEFAULT 'no' ,
  `context` VARCHAR(80) NULL DEFAULT NULL ,
  `defaultip` VARCHAR(15) NULL DEFAULT NULL ,
  `dtmfmode` VARCHAR(7) NULL DEFAULT NULL ,
  `fromuser` VARCHAR(80) NULL DEFAULT NULL ,
  `fromdomain` VARCHAR(80) NULL DEFAULT NULL ,
  `fullcontact` VARCHAR(80) NULL DEFAULT NULL ,
  `host` VARCHAR(31) NOT NULL DEFAULT '' ,
  `insecure` VARCHAR(4) NULL DEFAULT NULL ,
  `language` CHAR(2) NULL DEFAULT NULL ,
  `mailbox` VARCHAR(50) NULL DEFAULT NULL ,
  `md5secret` VARCHAR(80) NULL DEFAULT NULL ,
  `nat` VARCHAR(5) NOT NULL DEFAULT 'no' ,
  `deny` VARCHAR(95) NULL DEFAULT NULL ,
  `permit` VARCHAR(95) NULL DEFAULT NULL ,
  `mask` VARCHAR(95) NULL DEFAULT NULL ,
  `pickupgroup` VARCHAR(10) NULL DEFAULT NULL ,
  `port` VARCHAR(5) NOT NULL DEFAULT '' ,
  `qualify` CHAR(3) NULL DEFAULT 'no' ,
  `restrictcid` CHAR(1) NULL DEFAULT NULL ,
  `rtptimeout` CHAR(3) NULL DEFAULT NULL ,
  `rtpholdtimeout` CHAR(3) NULL DEFAULT NULL ,
  `secret` VARCHAR(80) NULL DEFAULT NULL ,
  `type` VARCHAR(6) NOT NULL DEFAULT 'friend' ,
  `username` VARCHAR(80) NOT NULL DEFAULT '' ,
  `disallow` VARCHAR(100) NULL DEFAULT 'all' ,
  `allow` VARCHAR(100) NULL DEFAULT 'gsm;ulaw;alaw' ,
  `musiconhold` VARCHAR(100) NULL DEFAULT NULL ,
  `regseconds` INT(11) NOT NULL DEFAULT '0' ,
  `ipaddr` VARCHAR(15) NOT NULL DEFAULT '' ,
  `regexten` VARCHAR(80) NOT NULL DEFAULT '' ,
  `cancallforward` CHAR(3) NULL DEFAULT 'yes' ,
  `setvar` VARCHAR(100) NOT NULL DEFAULT '' ,
  PRIMARY KEY (`id`) ,
  UNIQUE INDEX `name` (`name` ASC) ,
  INDEX `name_2` (`name` ASC) )
ENGINE = InnoDB
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`trunk_detail`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`trunk_detail` (
  `idTrunk` INT UNSIGNED NOT NULL ,
  `id` INT UNSIGNED NOT NULL ,
  `idTECHNOLOGY` INT UNSIGNED NOT NULL ,
  `last_change` TIMESTAMP NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  PRIMARY KEY (`id`, `idTECHNOLOGY`, `idTrunk`) ,
  INDEX `fk_TRUNK_DETAIL_USER_ACCOUNT1` (`id` ASC, `idTECHNOLOGY` ASC) ,
  INDEX `fk_TRUNK_DETAIL_TRUNK1` (`idTrunk` ASC) ,
  CONSTRAINT `fk_TRUNK_DETAIL_USER_ACCOUNT1`
    FOREIGN KEY (`id` , `idTECHNOLOGY` )
    REFERENCES `mydb`.`user_account` (`id` , `idTECHNOLOGY` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_TRUNK_DETAIL_TRUNK1`
    FOREIGN KEY (`idTrunk` )
    REFERENCES `mydb`.`trunk` (`idTrunk` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`pay_type`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`pay_type` (
  `idPAYTYPE` INT UNSIGNED NOT NULL ,
  `name` VARCHAR(15) NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  PRIMARY KEY (`idPAYTYPE`) ,
  UNIQUE INDEX `unique name` (`name` ASC) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Table `mydb`.`spec_pay_type`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`spec_pay_type` (
  `idTARIFMIX` INT UNSIGNED NOT NULL ,
  `idPAYTYPE` INT UNSIGNED NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  INDEX `fk_spec_pay_type_pay_type1` (`idPAYTYPE` ASC) ,
  PRIMARY KEY (`idTARIFMIX`) ,
  INDEX `fk_spec_pay_type_tarif_mix1` (`idTARIFMIX` ASC) ,
  CONSTRAINT `fk_spec_pay_type_pay_type1`
    FOREIGN KEY (`idPAYTYPE` )
    REFERENCES `mydb`.`pay_type` (`idPAYTYPE` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_spec_pay_type_tarif_mix1`
    FOREIGN KEY (`idTARIFMIX` )
    REFERENCES `mydb`.`tarif_mix` (`idTARIFMIX` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`bill_credit`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`bill_credit` (
  `idBILL` INT UNSIGNED NOT NULL ,
  `value` INT NOT NULL DEFAULT 0 ,
  PRIMARY KEY (`idBILL`) ,
  INDEX `fk_bill_credit_bill` (`idBILL` ASC) ,
  CONSTRAINT `fk_bill_credit_bill`
    FOREIGN KEY (`idBILL` )
    REFERENCES `mydb`.`bill` (`idBILL` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs
ROW_FORMAT = DYNAMIC;


-- -----------------------------------------------------
-- Table `mydb`.`bill_faktura`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`bill_faktura` (
  `idBILL` INT UNSIGNED NOT NULL ,
  `idObdobi` INT UNSIGNED NOT NULL ,
  `paid` TINYINT(1) NOT NULL DEFAULT 0 ,
  `last_change` TIMESTAMP NOT NULL ,
  PRIMARY KEY (`idBILL`, `idObdobi`) ,
  INDEX `fk_bill_faktura_bill1` (`idBILL` ASC) ,
  INDEX `fk_bill_faktura_PERIOD1` (`idObdobi` ASC) ,
  CONSTRAINT `fk_bill_faktura_bill1`
    FOREIGN KEY (`idBILL` )
    REFERENCES `mydb`.`bill` (`idBILL` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_bill_faktura_PERIOD1`
    FOREIGN KEY (`idObdobi` )
    REFERENCES `mydb`.`period` (`idObdobi` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`assign_tarif_mix`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`assign_tarif_mix` (
  `idTARIFMIX` INT UNSIGNED NOT NULL ,
  `id` INT UNSIGNED NOT NULL ,
  `idTECHNOLOGY` INT UNSIGNED NOT NULL ,
  `validity` TINYINT(1) NOT NULL DEFAULT 1 ,
  `last_change` TIMESTAMP NOT NULL ,
  PRIMARY KEY (`id`, `idTECHNOLOGY`, `idTARIFMIX`) ,
  INDEX `fk_assign_tarif_mix_user_account1` (`id` ASC, `idTECHNOLOGY` ASC) ,
  INDEX `fk_assign_tarif_mix_tarif_mix1` (`idTARIFMIX` ASC) ,
  CONSTRAINT `fk_assign_tarif_mix_user_account1`
    FOREIGN KEY (`id` , `idTECHNOLOGY` )
    REFERENCES `mydb`.`user_account` (`id` , `idTECHNOLOGY` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_assign_tarif_mix_tarif_mix1`
    FOREIGN KEY (`idTARIFMIX` )
    REFERENCES `mydb`.`tarif_mix` (`idTARIFMIX` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Table `mydb`.`asterisk_stats`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`asterisk_stats` (
  `Status_name` VARCHAR(10) NOT NULL ,
  `value` INT NOT NULL DEFAULT 0 ,
  PRIMARY KEY (`Status_name`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Table `mydb`.`ast_config`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`ast_config` (
  `id` INT UNSIGNED NOT NULL ,
  `cat_metric` INT(11) NOT NULL DEFAULT '0' ,
  `var_metric` INT(11) NOT NULL DEFAULT '0' ,
  `commented` INT(11) NOT NULL DEFAULT '0' ,
  `filename` VARCHAR(128) NOT NULL DEFAULT '' ,
  `category` VARCHAR(128) NOT NULL DEFAULT 'default' ,
  `var_name` VARCHAR(128) NOT NULL DEFAULT '' ,
  `var_val` VARCHAR(128) NOT NULL DEFAULT '' ,
  INDEX `filename_comment` (`filename` ASC, `commented` ASC) ,
  PRIMARY KEY (`id`) )
ENGINE = MyISAM
AUTO_INCREMENT = 3
DEFAULT CHARACTER SET = cp1250
COLLATE = cp1250_czech_cs;


-- -----------------------------------------------------
-- Placeholder table for view `mydb`.`user_function_view`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`user_function_view` (`login` INT, `Name` INT, `Function_Name` INT, `nextFunction_Name` INT, `submenu` INT);

-- -----------------------------------------------------
-- Placeholder table for view `mydb`.`users_list_view`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`users_list_view` (`idUser` INT, `surname` INT, `lastname` INT, `idTECHNOLOGY` INT, `technology` INT);

-- -----------------------------------------------------
-- Placeholder table for view `mydb`.`user_function_view1`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`user_function_view1` (`login` INT, `Name` INT, `Function_ID` INT, `Function_Name` INT, `nextFunction_ID` INT, `nextFunction_Name` INT, `submenu` INT);

-- -----------------------------------------------------
-- Placeholder table for view `mydb`.`call_records_view`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`call_records_view` (`idCALL_RECORDS` INT, `uptotime` INT, `unionnum` INT, `destnum` INT, `cost` INT, `trunkname` INT, `idPAYTYPE` INT, `idBILL` INT, `StartDate` INT, `Tarif` INT);

-- -----------------------------------------------------
-- Placeholder table for view `mydb`.`call_check_view`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`call_check_view` (`DestNumber` INT, `TrunkName` INT, `value` INT, `idPAYTYPE` INT, `technology` INT, `idtechnology` INT, `id` INT, `StartDate` INT);

-- -----------------------------------------------------
-- Placeholder table for view `mydb`.`bill_date_faktura_view`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`bill_date_faktura_view` (`idUSER` INT, `id` INT, `idTECHNOLOGY` INT, `idBILL` INT, `idCALL_RECORDS` INT, `idPAYTYPE` INT, `DatumOd` INT, `DatumDo` INT, `idObdobi` INT, `Zaplaceno` INT, `billsec` INT, `price` INT);

-- -----------------------------------------------------
-- View `mydb`.`user_function_view`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`user_function_view`;
CREATE  OR REPLACE VIEW `mydb`.`user_function_view` AS 
SELECT u.login,ug.Name,f.Name AS Function_Name,f2.Name AS nextFunction_Name,fs.submenu as submenu
FROM user u
JOIN SPEC_USER_GROUP sug ON sug.idUSER=u.idUSER AND u.validity=1 AND sug.validity=1
JOIN USER_GROUP ug ON ug.idUSERGROUP=sug.idUSERGROUP AND ug.validity=1 AND sug.validity=1
JOIN SPEC_GROUP_RIGHTS sgr ON  sgr.idUSERGROUP=ug.idUSERGROUP  AND sgr.validity=1 AND ug.validity=1
JOIN FUNCTIONS  f ON f.idfunctions=sgr.idfunctions AND f.validity=1 AND sgr.validity=1
JOIN FUNCTION_SEQUENCES fs ON fs.idFUNCTIONs=f.idfunctions AND fs.validity=1 AND f.validity=1
JOIN FUNCTIONS f2 ON f2.idFUNCTIONS=fs.idnextFUNCTIONS AND f2.validity=1 AND fs.validity=1


;

-- -----------------------------------------------------
-- View `mydb`.`users_list_view`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`users_list_view`;
CREATE  OR REPLACE VIEW `mydb`.`users_list_view` AS 
SELECT U.idUSER AS idUser,U.jmeno AS surname,U.prijmeni AS lastname,T.idTECHNOLOGY AS idTECHNOLOGY,T.technology AS technology
FROM USER_ACCOUNT UA
JOIN USER U ON U.idUSER=UA.idUSER AND U.validity=1 
JOiN TECHNOLOGY T ON T.idtechnology=UA.idTECHNOLOGY 
;

-- -----------------------------------------------------
-- View `mydb`.`user_function_view1`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`user_function_view1`;
CREATE  OR REPLACE VIEW `mydb`.`user_function_view1` AS
SELECT u.login,ug.Name,f.idFUNCTIONS AS Function_ID,f.Name AS Function_Name,f2.idFUNCTIONS AS nextFunction_ID,f2.Name AS nextFunction_Name,fs.submenu as submenu
FROM user u
JOIN spec_user_group sug ON sug.idUSER=u.idUSER AND u.validity=1 AND sug.validity=1
JOIN user_group ug ON ug.idUSERGROUP=sug.idUSERGROUP AND ug.validity=1 AND sug.validity=1
JOIN spec_group_rights sgr ON  sgr.idUSERGROUP=ug.idUSERGROUP  AND sgr.validity=1 AND ug.validity=1
JOIN functions  f ON f.idfunctions=sgr.idfunctions AND f.validity=1 AND sgr.validity=1
JOIN function_sequences fs ON fs.idFUNCTIONs=f.idfunctions AND fs.validity=1 AND f.validity=1
JOIN functions f2 ON f2.idFUNCTIONS=fs.idnextFUNCTIONS AND f2.validity=1 AND fs.validity=1

;

-- -----------------------------------------------------
-- View `mydb`.`call_records_view`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`call_records_view`;
CREATE  OR REPLACE VIEW `mydb`.`call_records_view` AS
SELECT  CR.idCALL_RECORDS,BP.uptotime AS uptotime,BP.unionnum AS unionnum,DN.number AS destnum,UC.cost,TRU.Name AS trunkname,SPT.idPAYTYPE AS idPAYTYPE,BC.idBILL AS idBILL,TM.start_date AS StartDate,TAR.idTARIF AS Tarif
    FROM user_account UA
    JOIN call_records CR ON CR.id=UA.id AND CR.idTECHNOLOGY=UA.idTECHNOLOGY  AND CR.validity=1
    
    JOIN technology T ON T.idTECHNOLOGY=UA.idTECHNOLOGY AND T.validity=1
    JOIN assign_tarif_mix ATM ON ATM.id=UA.id AND ATM.idTECHNOLOGY=UA.idTECHNOLOGY AND ATM.validity=1
    JOIN tarif_mix TM ON TM.idTARIFMIX=ATM.idTARIFMIX AND TM.validity=1
    JOIN spec_tarif_mix STM ON STM.idTARIFMIX=TM.idTARIFMIX AND STM.validity=1
    LEFT JOIN spec_pay_type SPT ON SPT.idTARIFMIX=TM.idTARIFMIX AND SPT.validity=1
    JOIN tarif TAR ON TAR.idTARIF=STM.idTARIF AND TAR.validity=1
    JOIN union_cost UC ON UC.idCENAJEDNOTKY=TAR.idCENAJEDNOTKY AND UC.validity=1
    JOIN spec_billing_period SBP ON SBP.idTARIF=TAR.idTARIF AND SBP.validity=1
    JOIN billing_period BP ON BP.idBILLINGPERIOD=SBP.idBILLINGPERIOD AND BP.validity=1
    JOIN dest_number DN ON DN.idNUMBER=STM.idNUMBER AND DN.validity=1
    JOIN trunk TRU ON TRU.idTRUNK=STM.idTRUNK AND TRU.validity=1
    JOIN bill BIL ON BIL.idBILL=UA.idBILL AND BIL.validity=1
    LEFT JOIN bill_credit BC ON BC.idBILL=BIL.idBILL
;

-- -----------------------------------------------------
-- View `mydb`.`call_check_view`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`call_check_view`;
CREATE  OR REPLACE VIEW `mydb`.`call_check_view` AS
SELECT DN.number AS DestNumber, T.Name AS TrunkName,BC.value,SPT.idPAYTYPE,TECH.technology,TECH.idtechnology,UA.id AS id,TM.start_date AS StartDate
FROM user_account UA
    JOIN assign_tarif_mix ATM ON ATM.id=UA.id AND ATM.idTECHNOLOGY=UA.idTECHNOLOGY AND ATM.validity=1
    JOIN tarif_mix TM ON ATM.idTARIFMIX=TM.idTARIFMIX AND TM.validity=1
    LEFT JOIN spec_pay_type SPT ON TM.idTARIFMIX=SPT.idTARIFMIX AND SPT.validity=1
    JOIN spec_tarif_mix STM ON STM.idTARIFMIX=TM.idTARIFMIX AND STM.validity=1
    JOIN trunk T ON T.idTRUNK=STM.idTRUNK AND  T.validity=1
    JOIN dest_number DN ON DN.idNUMBER=STM.idNUMBER AND DN.validity=1
    JOIN bill B ON B.idBILL=UA.idBILL AND B.validity=1
    LEFT JOIN bill_credit BC ON BC.idBILL=B.idBILL
    LEFT JOIN bill_faktura BF ON B.idBILL=BF.idBILL
    JOIN technology TECH ON UA.idTECHNOLOGY=TECH.idTECHNOLOGY
    
    
    
 

 ;

-- -----------------------------------------------------
-- View `mydb`.`bill_date_faktura_view`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`bill_date_faktura_view`;
CREATE  OR REPLACE VIEW `mydb`.`bill_date_faktura_view` AS
SELECT U.idUSER,UA.id,UA.idTECHNOLOGY,UA.idBILL,CR.idCALL_RECORDS,CR.idPAYTYPE,P.since AS DatumOd,P.to AS DatumDo,P.idObdobi,BF.paid AS Zaplaceno,CDR.billsec,CR.price 
FROM user_account UA
JOIN bill B ON B.idBILL=UA.idBILL AND B.validity=1
 JOIN bill_faktura BF ON B.idBILL=BF.idBILL
 JOIN period P ON P.idObdobi=BF.idObdobi
 JOIN bill_credit BC ON BC.idBILL=B.idBILL

JOIN call_records CR ON CR.id=UA.id AND CR.idTECHNOLOGY=UA.idTECHNOLOGY AND UA.validity=1
JOIN cdr CDR ON CDR.idCDR=CR.idCDR 
JOIN user U ON U.idUSER=UA.idUSER AND U.validity=1
WHERE UA.idTECHNOLOGY=1
AND CDR.calldate>= P.since AND CDR.calldate<=P.to

;
USE `mydb`;

DELIMITER //
CREATE trigger after_cdr_insert after insert on cdr for each row
  BEGIN
    
      IF 1<=(SELECT COUNT(1) FROM sip_buddies WHERE name = substring_index(substring(new.channel,length(substring_index(new.channel,'/',1))+2),'-',1)) THEN
               BEGIN
                        IF new.dst=substring_index(substring(new.dstchannel,length(substring_index(new.channel,'/',1))+2),'-',1) THEN
                                INSERT INTO call_records (idCDR,ID,idTECHNOLOGY,idDIRECTION)
                                SELECT new.idCDR,UA.id,UA.idtechnology,1 FROM user_account UA
                                JOIN technology T ON T.idTECHNOLOGY=UA.idTECHNOLOGY
                                JOIN sip_buddies SB ON UA.ID=SB.ID
                                WHERE T.technology like (substring_index(new.channel,'/',1) )
                                AND SB.NAME LIKE new.src;
                        ELSE
                                INSERT INTO call_records (idCDR,ID,idTECHNOLOGY,idDIRECTION)
                                SELECT new.idCDR,UA.id,UA.idtechnology,1 FROM user_account UA
                                JOIN technology T ON T.idTECHNOLOGY=UA.idTECHNOLOGY
                                JOIN sip_buddies SB ON UA.ID=SB.ID
                                WHERE T.technology like (substring_index(new.channel,'/',1) )
                                AND SB.NAME LIKE new.src;
                                
                                INSERT INTO call_records (idCDR,ID,idTECHNOLOGY,idDIRECTION)
                                SELECT new.idCDR,UA.id,UA.idtechnology,1 FROM user_account UA
                                JOIN technology T ON T.idTECHNOLOGY=UA.idTECHNOLOGY
                                JOIN sip_buddies SB ON UA.ID=SB.ID
                                WHERE T.technology like (substring_index(new.dstchannel,'/',1) )
                                AND SB.NAME LIKE (substring_index(substring(new.dstchannel,length(substring_index(new.channel,"/",1))+2),"-",1));
                        END IF;
                END;
        ELSE
                BEGIN
                     INSERT INTO call_records (idCDR,ID,idTECHNOLOGY,idDIRECTION)
                                SELECT new.idCDR,UA.id,UA.idtechnology,2 FROM user_account UA
                                JOIN technology T ON T.idTECHNOLOGY=UA.idTECHNOLOGY
                                JOIN sip_buddies SB ON UA.ID=SB.ID
                                WHERE T.technology like (substring_index(new.dstchannel,'/',1) )
                                AND SB.NAME LIKE new.dst;
                END;
        END IF;
        END;
            
         
    
//


DELIMITER ;

DELIMITER //
CREATE TRIGGER after_specbillingperiod_insert
    BEFORE INSERT ON SPEC_BILLING_PERIOD
    FOR EACH ROW
    BEGIN
      IF ((new.idTARIF  IN(SELECT idTARIF FROM spec_billing_period) AND (new.idBILLINGPERIODSELECT in(SELECT idBILLINGPERIODSELECT FROM spec_billing_period))))
    THEN      UPDATE   spec_billing_period SET validity=1 where idBILLINGPERIODSELECT=new.idBILLINGPERIOD  AND idTARIF=new.idTARIF;
    END IF;
    END;
    
//


DELIMITER ;

DELIMITER //
CREATE trigger after_bill_insert after insert on bill for each row
BEGIN
  INSERT INTO bill_credit (idBILL) VALUES (new.idBILL);
  INSERT INTO bill_faktura (idBILL,idObdobi)
    SELECT new.idBILL,idObdobi
        FROM period p
        WHERE p.since < now() AND p.to > now();

    END;
    
//


DELIMITER ;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

-- -----------------------------------------------------
-- Data for table `mydb`.`user`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `user` (`idUSER`, `jmeno`, `prijmeni`, `login`, `password`, `email`, `validity`, `last_change`) VALUES (1, 'Master', 'Admin', 'Admin', 'AdminMaster', NULL, 1, 0);

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`functions`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (1, 'Default', 'pozice korenoveho menu admina', 0, 1, NULL);
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (2, 'Defaultuser', 'pozice kořenového menu useru', 0, 1, 'user_home.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (3, 'Adminpage', 'domovska administratorska stranka', 0, 1, 'admin_home.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (4, 'Účty', 'Read stránka s informacemi o přihlášeném uživateli', 0, 1, 'user_info.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (5, 'Pøehled statistik', '', 0, 1, 'user_stats_report.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (6, 'Nový uživatel', '', 0, 1, 'create_user.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (7, 'Uživatelé', '', 0, 1, 'user_edit_filter.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (8, 'User Detail', '', 0, 1, 'user_edit_detail.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (9, 'Nový úèet', '', 0, 1, 'create_callaccount.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (10, 'Tarify', '', 0, 1, 'tarif_edit_filter.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (11, 'Tarif Detail', '', 0, 1, 'tarif_edit_detail.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (12, 'Tarifní intervaly', '', 0, 1, 'billing_periods_edit.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (13, 'Nová položka', '', 0, 1, 'tarif_create.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (14, 'Detail účtu', '', 0, 1, 'user_callacc_detail.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (15, 'Nová skupina', 'Sdružení několika tarifních položek', 0, 1, 'tarif_group_create.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (16, 'Skupina Detail', '', 0, 1, 'tarif_group_edit_detail.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (17, 'Trunky', 'Filtr pro listovani v trunkach', 0, 1, 'trunk_edit_filter.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (18, 'Nový trunk', 'Formulář pro vytvoření nového trunku', 0, 1, 'trunk_create.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (19, 'Poskytovatelé', 'Filtr pro listovani v providerech', 0, 1, 'provider_edit_filter.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (20, 'Nový poskytovatel', 'Vytváření providerů', 0, 1, 'provider_create.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (21, 'Úèty asterisk', 'Práce s volacími účty', 0, 1, 'callacc_edit_filter.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (22, 'Přiřázení uživatele k ast účtu', 'Přiřazení uživatele k asterisk účtu', 0, 1, 'callacc_assign.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (23, 'Editace trunku', 'Editování již existujícího trunku', 0, 1, 'trunk_edit_detail.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (24, 'Editace poskytovatele', 'Editovani vytrvoreneho poskytovatele', 0, 1, 'provider_edit_detail.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (25, 'Faktury', 'Filtr pro faktury', 0, 1, 'faktury_filtr.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (26, 'Období', 'Fitrl pro výběr období uživatele', 0, 1, 'faktura_period_filter.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (27, 'Období detail', 'Obdobi detail', 0, 1, 'faktura_period_detail.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (28, 'User období', 'User Období detail', 0, 1, 'user_period_detail.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (29, 'Pøedvolby', 'Vytvareni a uprava predvoleb', 0, 1, 'prefix_edit.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (30, 'SSH', 'Spuštění ssh appletu', 0, 1, 'files/ssh_applet.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (31, 'Dobití kreditu', 'Dobijeni kreditu', 0, 1, 'charge_credit.inc.php');
INSERT INTO `functions` (`idFUNCTIONS`, `Name`, `description`, `last_change`, `validity`, `scriptname`) VALUES (23, 'Vytoèit úèet', 'volání click to call', 0, 1, 'click_to_call.inc.php');

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`provider`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `provider` (`idPROVIDER`, `name`, `last_change`, `validity`, `description`) VALUES (0, 'není definován', 0, 1, 'nedefinovaný provider');

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`technology`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `technology` (`idTECHNOLOGY`, `technology`, `table_name`) VALUES (1, 'SIP', 'sip_buddies');

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`user_group`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `user_group` (`idUSERGROUP`, `Name`, `description`, `validity`, `last_change`) VALUES (1, 'Administrator', 'Skupina administrátorů', 1, 0);
INSERT INTO `user_group` (`idUSERGROUP`, `Name`, `description`, `validity`, `last_change`) VALUES (2, 'User', 'Skupina uživatelů', 1, 0);

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`spec_group_rights`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 1, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 2, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (2, 2, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 3, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 4, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (2, 4, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 5, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (2, 5, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 6, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 7, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 8, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 9, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 10, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 11, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 12, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 13, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 14, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (2, 14, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 15, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 16, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 17, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 18, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 19, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 20, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 21, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 22, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 23, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 24, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 25, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 26, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 27, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 28, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (2, 28, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 29, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 30, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 31, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (1, 32, 1, 0);
INSERT INTO `spec_group_rights` (`idUSERGROUP`, `idFUNCTIONS`, `validity`, `last_change`) VALUES (2, 32, 1, 0);

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`spec_user_group`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `spec_user_group` (`idUSER`, `idUSERGROUP`, `validity`, `last_change`) VALUES (1, 1, 1, 0);

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`direction`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `direction` (`idDIRECTION`, `name`) VALUES (1, 'Odchozí');
INSERT INTO `direction` (`idDIRECTION`, `name`) VALUES (2, 'Příchozí');

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`period`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `period` (`idObdobi`, `since`, `to`) VALUES (1, 2010-04-01, 2010-04-30);
INSERT INTO `period` (`idObdobi`, `since`, `to`) VALUES (2, 2010-05-01, 2010-05-31);
INSERT INTO `period` (`idObdobi`, `since`, `to`) VALUES (3, 2010-09-01, 2010-06-30);
INSERT INTO `period` (`idObdobi`, `since`, `to`) VALUES (4, 0, 0);

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`function_sequences`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (1, 2, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (2, 4, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (2, 5, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (3, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (3, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (3, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (3, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (3, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (3, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (3, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (4, 4, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (4, 5, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (4, 32, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (5, 4, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (5, 5, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (5, 32, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (6, 6, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (6, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (6, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (6, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (6, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (6, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (6, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (6, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (7, 6, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (7, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (7, 9, 1, 0, 1);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (7, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (7, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (7, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (7, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (7, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (7, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (8, 6, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (8, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (8, 9, 1, 0, 1);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (8, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (8, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (8, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (8, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (8, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (8, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (9, 6, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (9, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (9, 9, 1, 0, 1);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (9, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (9, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (9, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (9, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (9, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (9, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (10, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (10, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (10, 12, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (10, 13, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (10, 15, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (10, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (10, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (10, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (10, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (10, 29, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (10, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (11, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (11, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (11, 12, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (11, 13, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (11, 15, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (11, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (11, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (11, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (11, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (11, 29, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (11, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (12, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (12, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (12, 12, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (12, 13, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (12, 15, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (12, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (12, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (12, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (12, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (12, 29, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (12, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (13, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (13, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (13, 12, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (13, 13, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (13, 15, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (13, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (13, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (13, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (13, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (13, 29, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (13, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (14, 4, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (14, 5, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (15, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (15, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (15, 12, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (15, 13, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (15, 15, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (15, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (15, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (15, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (15, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (15, 29, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (15, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (16, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (16, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (16, 12, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (16, 13, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (16, 15, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (16, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (16, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (16, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (16, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (16, 29, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (16, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (17, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (17, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (17, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (17, 18, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (17, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (17, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (17, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (17, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (18, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (18, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (18, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (18, 18, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (18, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (18, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (18, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (18, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (19, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (19, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (19, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (19, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (19, 20, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (19, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (19, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (19, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (20, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (20, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (20, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (20, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (20, 20, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (20, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (20, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (20, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (21, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (21, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (21, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (21, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (21, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (21, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (21, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (22, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (22, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (22, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (22, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (22, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (22, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (22, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (23, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (23, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (23, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (23, 18, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (23, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (23, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (23, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (23, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (24, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (24, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (24, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (24, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (24, 20, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (24, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (24, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (24, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (25, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (25, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (25, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (25, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (25, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (25, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (25, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (25, 31, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (26, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (26, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (26, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (26, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (26, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (26, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (26, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (26, 31, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (27, 1, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (28, 1, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (29, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (29, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (29, 12, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (29, 13, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (29, 15, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (29, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (29, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (29, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (29, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (29, 29, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (29, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (30, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (30, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (30, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (30, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (30, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (30, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (31, 7, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (31, 10, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (31, 17, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (31, 19, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (31, 21, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (31, 25, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (31, 30, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (31, 31, 1, 0, 2);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (32, 4, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (32, 5, 1, 0, 0);
INSERT INTO `function_sequences` (`idFUNCTIONS`, `idnextFUNCTIONS`, `validity`, `lastchange`, `submenu`) VALUES (32, 32, 1, 0, 0);

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`pay_type`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `pay_type` (`idPAYTYPE`, `name`, `validity`) VALUES (1, 'Fakturou', 1);
INSERT INTO `pay_type` (`idPAYTYPE`, `name`, `validity`) VALUES (2, 'Předplaceno', 1);

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`asterisk_stats`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `asterisk_stats` (`Status_name`, `value`) VALUES ('runStats', 0);

COMMIT;

-- -----------------------------------------------------
-- Data for table `mydb`.`ast_config`
-- -----------------------------------------------------
SET AUTOCOMMIT=0;
USE `mydb`;
INSERT INTO `ast_config` (`id`, `cat_metric`, `var_metric`, `commented`, `filename`, `category`, `var_name`, `var_val`) VALUES (1, '0', '5', '0', 'sip.conf', 'general', 'rtcachefriends', 'yes');
INSERT INTO `ast_config` (`id`, `cat_metric`, `var_metric`, `commented`, `filename`, `category`, `var_name`, `var_val`) VALUES (2, '1', '1', '0', 'sip.conf', 'general', 'rtautoclear', 'yes');
INSERT INTO `ast_config` (`id`, `cat_metric`, `var_metric`, `commented`, `filename`, `category`, `var_name`, `var_val`) VALUES (3, '1', '2', '0', 'sip.conf', 'general', 'bindport', '5060');
INSERT INTO `ast_config` (`id`, `cat_metric`, `var_metric`, `commented`, `filename`, `category`, `var_name`, `var_val`) VALUES (4, '1', '3', '0', 'sip.conf', 'general', 'context', 'default');
INSERT INTO `ast_config` (`id`, `cat_metric`, `var_metric`, `commented`, `filename`, `category`, `var_name`, `var_val`) VALUES (5, '1', '4', '0', 'sip.conf', 'general', 'allowquest', 'no');

COMMIT;
