-- Table structure for table `breakpoints`
--

CREATE TABLE `breakpoints` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `debug_id` int(11) DEFAULT NULL,
  `module_name` varchar(300) NOT NULL,
  `module_owner` varchar(300) NOT NULL,
  `module_type` int(11) NOT NULL,
  `line` int(11) DEFAULT NULL,
  `pos` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `callstack`
--

CREATE TABLE `callstack` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `debug_id` int(11) NOT NULL,
  `unit_name` varchar(300) DEFAULT NULL,
  `module_name` varchar(300) NOT NULL,
  `module_owner` varchar(300) NOT NULL,
  `module_type` int(11) NOT NULL,
  `start_line` int(11) DEFAULT NULL,
  `end_line` int(11) DEFAULT NULL,
  `start_pos` int(11) DEFAULT NULL,
  `end_pos` int(11) DEFAULT NULL,
  `stack_depth` int(11) NOT NULL,
  `compiler_version` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `debuggings`
--

CREATE TABLE `debuggings` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `proc_id` int(11) NOT NULL,
  `step_kind` int(11) DEFAULT NULL,
  `estimated_depth` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `diagnostics_info`
--

CREATE TABLE `diagnostics_info` (
  `debug_id` int(11) DEFAULT NULL,
  `condition_number` int(11) NOT NULL,
  `class_origin` varchar(64) DEFAULT NULL,
  `subclass_origin` varchar(64) DEFAULT NULL,
  `returned_sqlstate` char(5) DEFAULT NULL,
  `message_text` text,
  `mysql_errno` int(11) DEFAULT NULL,
  `constraint_catalog` varchar(64) DEFAULT NULL,
  `constraint_schema` varchar(64) DEFAULT NULL,
  `constraint_name` varchar(64) DEFAULT NULL,
  `catalog_name` varchar(64) DEFAULT NULL,
  `schema_name` varchar(64) DEFAULT NULL,
  `table_name` varchar(64) DEFAULT NULL,
  `column_name` varchar(64) DEFAULT NULL,
  `cursor_name` varchar(64) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `info`
--

CREATE TABLE `info` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `debug_id` int(11) NOT NULL,
  `break_reason` int(11) DEFAULT NULL,
  `stack_depth` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `watches`
--

CREATE TABLE `watches` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `debug_id` int(11) NOT NULL,
  `stack_depth` int(11) NOT NULL,
  `watch_name` varchar(200) NOT NULL,
  `watch_value` mediumtext,
  `watch_type` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping routines for database 'cr_debug'
--
/*!50003 DROP FUNCTION IF EXISTS `check_breakpoint` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `check_breakpoint`() RETURNS int(11)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
  DECLARE result INTEGER DEFAULT 0;

  IF (@debug_id > 0) THEN
    SELECT
      COUNT(*)
    FROM callstack c,
         breakpoints b
    WHERE c.debug_id = @debug_id
      AND b.debug_id = @debug_id
      AND c.stack_depth = @stack_depth
      AND c.module_name = b.module_name
      AND c.module_owner = b.module_owner
      AND c.module_type = b.module_type
      AND c.start_line = b.line
    INTO result;
  END IF;
  RETURN result;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `check_version_compatibility` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `check_version_compatibility`(in_stack_depth INTEGER) RETURNS int(11)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
  DECLARE c_version INTEGER DEFAULT NULL;
  SELECT
    compiler_version
  FROM callstack
  WHERE debug_id = @debug_id
    AND stack_depth = in_stack_depth
  INTO c_version;
  RETURN COALESCE(c_version, 0) - get_version();
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `enter_handler` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `enter_handler`(in_unit_name        VARCHAR(300),
                              in_module_name      VARCHAR(300),
                              in_module_owner     VARCHAR(300),
                              in_module_type      INTEGER,
                              in_compiler_version INTEGER) RETURNS int(11)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
  CALL set_diagnostics();
  RETURN cr_debug.enter_module3(in_unit_name, in_module_name, in_module_owner, in_module_type, in_compiler_version);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `enter_module` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `enter_module`(in_module_name VARCHAR(300), in_module_owner VARCHAR(300), in_module_type INTEGER) RETURNS int(11)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
  RETURN enter_module2(in_module_name, in_module_owner, in_module_type, NULL);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `enter_module2` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `enter_module2`(in_module_name VARCHAR(300), in_module_owner VARCHAR(300), in_module_type INTEGER, in_compiler_version INTEGER) RETURNS int(11)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
  RETURN enter_module3(NULL, in_module_name, in_module_owner, in_module_type, in_compiler_version);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `enter_module3` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `enter_module3`(in_unit_name VARCHAR(300), in_module_name VARCHAR(300), in_module_owner VARCHAR(300), in_module_type INTEGER, in_compiler_version INTEGER) RETURNS int(11)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
  IF (@debug_id > 0) THEN
    SET @stack_depth := @stack_depth + 1;
    UPDATE info
      SET stack_depth = @stack_depth
      WHERE debug_id = @debug_id;
    INSERT INTO callstack (debug_id, unit_name, module_name, module_owner, module_type, stack_depth, compiler_version)
      VALUES (@debug_id, in_unit_name, in_module_name, in_module_owner, in_module_type, @stack_depth, in_compiler_version);
  END IF;

  RETURN @stack_depth;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `get_found_rows` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `get_found_rows`() RETURNS int(11)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
  RETURN @debug_found_rows;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `get_last_insert_id` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `get_last_insert_id`() RETURNS int(11)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
  RETURN @debug_last_insert_id;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `get_row_count` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `get_row_count`() RETURNS int(11)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN
  RETURN @debug_row_count;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `get_step_kind` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `get_step_kind`() RETURNS int(11)
    READS SQL DATA
BEGIN
  DECLARE result INTEGER DEFAULT -1;

  SELECT
    step_kind
  FROM debuggings
  WHERE id = @debug_id
  INTO result;
  RETURN result;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `get_version` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `get_version`() RETURNS int(11)
    READS SQL DATA
    DETERMINISTIC
    SQL SECURITY INVOKER
BEGIN
  RETURN 100631;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `attach` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `attach`(IN in_debug_id INTEGER)
    SQL SECURITY INVOKER
BEGIN
  SET @debug_id = in_debug_id, @timeout = 5;
  DO GET_LOCK(@debug_id, 5);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `continue` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `continue`(IN in_step_kind INTEGER)
    SQL SECURITY INVOKER
BEGIN
  DECLARE stack_depth INTEGER;

  SELECT
    MAX(c.stack_depth)
  FROM callstack c
  WHERE c.debug_id = @debug_id
  INTO stack_depth;

  UPDATE debuggings
    SET step_kind = in_step_kind
    WHERE id = @debug_id;

  IF (in_step_kind = 3) THEN
    UPDATE debuggings
      SET estimated_depth = stack_depth - 1
      WHERE id = @debug_id;
  ELSEIF (in_step_kind = 2) THEN
    UPDATE debuggings
      SET estimated_depth = stack_depth
      WHERE id = @debug_id;
  ELSE
    UPDATE debuggings
      SET estimated_depth = -1
      WHERE id = @debug_id;
  END IF;

  CALL switch_locks(0);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `debug_off` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `debug_off`()
    SQL SECURITY INVOKER
BEGIN
  DELETE
    FROM callstack
    WHERE debug_id = @debug_id;
  DELETE
    FROM breakpoints
    WHERE debug_id = @debug_id;
  DELETE
    FROM watches
    WHERE debug_id = @debug_id;
  DELETE
    FROM debuggings
    WHERE id = @debug_id;
  DELETE
    FROM info
    WHERE debug_id = @debug_id;
  DO RELEASE_LOCK(@debug_id);
  DO RELEASE_LOCK(CONCAT(@debug_id, 'second'));
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `debug_on` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `debug_on`(OUT out_debug_id INTEGER)
    SQL SECURITY INVOKER
BEGIN
  CALL update_system_calls(-1);

  DELETE d.*, c.*, i.*, w.*, b.*
    FROM debuggings d
      LEFT JOIN callstack c
        ON c.debug_id = d.id
      LEFT JOIN breakpoints b
        ON b.debug_id = d.id
      LEFT JOIN info i
        ON i.debug_id = d.id
      LEFT JOIN watches w
        ON w.debug_id = d.id
    WHERE proc_id = CONNECTION_ID();

  INSERT INTO debuggings (proc_id, step_kind)
    VALUES (CONNECTION_ID(), 1);
  SELECT
    LAST_INSERT_ID()
  INTO @debug_id;

  SET @stack_depth := 0;

  INSERT INTO info (debug_id, break_reason, stack_depth)
    VALUES (@debug_id, -1, @stack_depth);

  SET out_debug_id := @debug_id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `detach` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `detach`()
    SQL SECURITY INVOKER
BEGIN
  DO RELEASE_LOCK(@debug_id);
  DO RELEASE_LOCK(CONCAT(@debug_id, 'second'));
  SET @debug_id = -1;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `get_diagnostics` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `get_diagnostics`(IN  in_condition_number    INT,
                                 OUT out_class_origin       VARCHAR(64),
                                 OUT out_subclass_origin    VARCHAR(64),
                                 OUT out_returned_sqlstate  CHAR(5),
                                 OUT out_message_text       TEXT,
                                 OUT out_mysql_errno        INT,
                                 OUT out_constraint_catalog VARCHAR(64),
                                 OUT out_constraint_schema  VARCHAR(64),
                                 OUT out_constraint_name    VARCHAR(64),
                                 OUT out_catalog_name       VARCHAR(64),
                                 OUT out_schema_name        VARCHAR(64),
                                 OUT out_table_name         VARCHAR(64),
                                 OUT out_column_name        VARCHAR(64),
                                 OUT out_cursor_name        VARCHAR(64))
BEGIN

  IF (@debug_id > 0) THEN
    SELECT
      class_origin,
      subclass_origin,
      returned_sqlstate,
      message_text,
      mysql_errno,
      constraint_catalog,
      constraint_schema,
      constraint_name,
      catalog_name,
      schema_name,
      table_name,
      column_name,
      cursor_name
    FROM diagnostics_info
    WHERE debug_id = @debug_id
    AND condition_number = in_condition_number
    INTO out_class_origin,
         out_subclass_origin,
         out_returned_sqlstate,
         out_message_text,
         out_mysql_errno,
         out_constraint_catalog,
         out_constraint_schema,
         out_constraint_name,
         out_catalog_name,
         out_schema_name,
         out_table_name,
         out_column_name,
         out_cursor_name;
  ELSE
    GET CURRENT DIAGNOSTICS CONDITION in_condition_number
    out_class_origin = CLASS_ORIGIN,
    out_subclass_origin = SUBCLASS_ORIGIN,
    out_returned_sqlstate = RETURNED_SQLSTATE,
    out_message_text = MESSAGE_TEXT,
    out_mysql_errno = MYSQL_ERRNO,
    out_constraint_catalog = CONSTRAINT_CATALOG,
    out_constraint_schema = CONSTRAINT_SCHEMA,
    out_constraint_name = CONSTRAINT_NAME,
    out_catalog_name = CATALOG_NAME,
    out_schema_name = SCHEMA_NAME,
    out_table_name = TABLE_NAME,
    out_column_name = COLUMN_NAME,
    out_cursor_name = CURSOR_NAME;
  END IF;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `leave_module` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `leave_module`(IN in_stack_depth INTEGER)
    SQL SECURITY INVOKER
BEGIN
  IF (@debug_id > 0) THEN
    DELETE
      FROM callstack
      WHERE debug_id = @debug_id
        AND stack_depth > in_stack_depth;

    SET @stack_depth = in_stack_depth;
    UPDATE info
      SET stack_depth = in_stack_depth
      WHERE debug_id = @debug_id;

    IF (@stack_depth <= 0) THEN
      UPDATE info
        SET break_reason = 25
        WHERE debug_id = @debug_id;
    END IF;
  END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `remove_breakpoint` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `remove_breakpoint`(breakpoint_no INTEGER)
    SQL SECURITY INVOKER
BEGIN
  DELETE
    FROM breakpoints
    WHERE id = breakpoint_no;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `set_breakpoint` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `set_breakpoint`(IN in_module_name VARCHAR(300), IN in_module_owner VARCHAR(300), IN in_module_type INTEGER, IN in_line INTEGER, IN in_pos INTEGER, OUT out_br_no INTEGER)
    SQL SECURITY INVOKER
BEGIN
  DECLARE module_exists INTEGER DEFAULT -1;

  IF (in_module_type = 7 OR in_module_type = 8) THEN
    SELECT
      COUNT(routine_name)
    INTO module_exists
    FROM information_schema.routines
    WHERE routine_name = in_module_name
      AND routine_schema = in_module_owner;
  ELSEIF (in_module_type = 12) THEN
    SELECT
      COUNT(trigger_name)
    INTO module_exists
    FROM information_schema.triggers
    WHERE trigger_name = in_module_name
      AND trigger_schema = in_module_owner;
  END IF;

  SET out_br_no := -1;
  IF (module_exists <> 0) THEN
    DELETE
      FROM breakpoints
      WHERE module_name = in_module_name
        AND module_owner = in_module_owner
        AND module_type = in_module_type
        AND line = in_line
        AND pos = in_pos
        AND debug_id = @debug_id;
    INSERT INTO breakpoints (module_name, module_owner, module_type, line, pos, debug_id)
      VALUES (in_module_name, in_module_owner, in_module_type, in_line, in_pos, @debug_id);
    SELECT
      LAST_INSERT_ID()
    INTO out_br_no;
  END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `set_diagnostics` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `set_diagnostics`()
BEGIN

  IF (@debug_id > 0) THEN
  BEGIN
    DECLARE fields_delimeter NCHAR DEFAULT '♪';
    DECLARE lines_delimeter NCHAR DEFAULT '♫';
    DECLARE di_number INT;
    DECLARE di_class_origin VARCHAR(64);
    DECLARE di_subclass_origin VARCHAR(64);
    DECLARE di_returned_sqlstate CHAR(5);
    DECLARE di_message_text TEXT;
    DECLARE di_mysql_errno INT;
    DECLARE di_constraint_catalog VARCHAR(64);
    DECLARE di_constraint_schema VARCHAR(64);
    DECLARE di_constraint_name VARCHAR(64);
    DECLARE di_catalog_name VARCHAR(64);
    DECLARE di_schema_name VARCHAR(64);
    DECLARE di_table_name VARCHAR(64);
    DECLARE di_column_name VARCHAR(64);
    DECLARE di_cursor_name VARCHAR(64);
    DECLARE all_data NVARCHAR(8192);
    DECLARE line_data NVARCHAR(1024);

    SET all_data = '';
    GET CURRENT DIAGNOSTICS di_number = NUMBER;
    WHILE di_number > 0 DO
      GET CURRENT DIAGNOSTICS CONDITION di_number
      di_class_origin = CLASS_ORIGIN,
      di_subclass_origin = SUBCLASS_ORIGIN,
      di_returned_sqlstate = RETURNED_SQLSTATE,
      di_message_text = MESSAGE_TEXT,
      di_mysql_errno = MYSQL_ERRNO,
      di_constraint_catalog = CONSTRAINT_CATALOG,
      di_constraint_schema = CONSTRAINT_SCHEMA,
      di_constraint_name = CONSTRAINT_NAME,
      di_catalog_name = CATALOG_NAME,
      di_schema_name = SCHEMA_NAME,
      di_table_name = TABLE_NAME,
      di_column_name = COLUMN_NAME,
      di_cursor_name = CURSOR_NAME;

      SET line_data = CONCAT_WS(fields_delimeter, di_number, di_class_origin, di_subclass_origin, di_returned_sqlstate, di_message_text,
      di_mysql_errno, di_constraint_catalog, di_constraint_schema, di_constraint_name,
      di_catalog_name, di_schema_name, di_table_name, di_column_name, di_cursor_name);

      IF all_data = '' THEN
        SET all_data = line_data;
      ELSE
        SET all_data = CONCAT(all_data, lines_delimeter, line_data);
      END IF;

      SET di_number = di_number - 1;
    END WHILE;

    IF all_data != '' THEN
    BEGIN
      DECLARE data_length INT DEFAULT LENGTH(all_data);
      DECLARE fields_count INT DEFAULT 14;
      DECLARE start_pos INT DEFAULT 0;
      DECLARE end_pos INT DEFAULT 0;
      DECLARE line_start_pos INT DEFAULT 0;
      DECLARE line_end_pos INT DEFAULT 0;
      DECLARE current_field INT;
      DECLARE temp_value TEXT;

      WHILE start_pos < data_length DO
        SET start_pos = start_pos + 1;
        SET end_pos = LOCATE(lines_delimeter, all_data, start_pos);
        IF end_pos = 0 THEN
          SET end_pos = data_length;
        END IF;

        SET line_data = SUBSTRING(all_data, start_pos, end_pos - start_pos);
        SET start_pos = end_pos;

        SET current_field = 0;
        WHILE current_field < fields_count DO
          SET line_start_pos = line_start_pos + 1;
          SET line_end_pos = LOCATE(fields_delimeter, line_data, line_start_pos);
          SET temp_value = SUBSTRING(line_data, line_start_pos, line_end_pos - line_start_pos);
          SET line_start_pos = line_end_pos;
          SET current_field = current_field + 1;

          IF current_field = 1 THEN
            SET di_number = CAST(temp_value AS UNSIGNED INTEGER);
          ELSEIF current_field = 2 THEN
            SET di_class_origin = temp_value;
          ELSEIF current_field = 3 THEN
            SET di_subclass_origin = temp_value;
          ELSEIF current_field = 4 THEN
            SET di_returned_sqlstate = temp_value;
          ELSEIF current_field = 5 THEN
            SET di_message_text = temp_value;
          ELSEIF current_field = 6 THEN
            SET di_mysql_errno = CAST(temp_value AS UNSIGNED INTEGER);
          ELSEIF current_field = 7 THEN
            SET di_constraint_catalog = temp_value;
          ELSEIF current_field = 8 THEN
            SET di_constraint_schema = temp_value;
          ELSEIF current_field = 9 THEN
            SET di_constraint_name = temp_value;
          ELSEIF current_field = 10 THEN
            SET di_catalog_name = temp_value;
          ELSEIF current_field = 11 THEN
            SET di_schema_name = temp_value;
          ELSEIF current_field = 12 THEN
            SET di_table_name = temp_value;
          ELSEIF current_field = 13 THEN
            SET di_column_name = temp_value;
          ELSEIF current_field = 14 THEN
            SET di_cursor_name = temp_value;
          END IF;
        END WHILE;


        INSERT diagnostics_info (debug_id,
                                 condition_number,
                                 class_origin,
                                 subclass_origin,
                                 returned_sqlstate,
                                 message_text,
                                 mysql_errno,
                                 constraint_catalog,
                                 constraint_schema,
                                 constraint_name,
                                 catalog_name,
                                 schema_name,
                                 table_name,
                                 column_name,
                                 cursor_name)
          VALUES (@debug_id,
                  di_number,
                  di_class_origin,
                  di_subclass_origin,
                  di_returned_sqlstate,
                  di_message_text,
                  di_mysql_errno,
                  di_constraint_catalog,
                  di_constraint_schema,
                  di_constraint_name,
                  di_catalog_name,
                  di_schema_name,
                  di_table_name,
                  di_column_name,
                  di_cursor_name);

      END WHILE;
    END;
    END IF;
  END;
  END IF;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `switch_locks` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `switch_locks`(IN is_target TINYINT)
BEGIN
  DECLARE lock1 VARCHAR(200) DEFAULT @debug_id;
  DECLARE lock2 VARCHAR(200) DEFAULT CONCAT(@debug_id, 'second');
  DECLARE timeout INT;
  DECLARE to_lock,
          to_release VARCHAR(200);

  IF (is_target > 0) THEN
    SET timeout = 3600;
  ELSE
    SET timeout = 10;
  END IF;

  IF (IS_USED_LOCK(lock1) = CONNECTION_ID()) THEN
    SET to_lock = lock2;
    SET to_release = lock1;
  ELSE
    SET to_lock = lock1;
    SET to_release = lock2;
  END IF;

  IF (is_target > 0) THEN
    DO RELEASE_LOCK(to_release);
  END IF;

  DO GET_LOCK(to_lock, timeout);

  IF (is_target = 0) THEN
    DO RELEASE_LOCK(to_release);
  END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `synchronize` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `synchronize`(OUT out_unit_name VARCHAR(300), OUT out_module_name VARCHAR(300), OUT out_module_owner VARCHAR(300), OUT out_module_type INTEGER, OUT out_stack_depth INTEGER, OUT out_start_line INTEGER, OUT out_end_line INTEGER, OUT out_start_pos INTEGER, OUT out_end_pos INTEGER, OUT out_break_reason INTEGER)
    SQL SECURITY INVOKER
BEGIN
  DECLARE second_lock VARCHAR(200);
  DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET out_break_reason = 0;

  IF (IS_USED_LOCK(@debug_id) = CONNECTION_ID()) THEN
    SET second_lock = CONCAT(@debug_id, 'second');
  ELSE
    SET second_lock = @debug_id;
  END IF;

  IF (IS_FREE_LOCK(second_lock) > 0) THEN
    SELECT
      unit_name,
      module_name,
      module_owner,
      module_type,
      c.stack_depth,
      start_line,
      end_line,
      start_pos,
      end_pos,
      break_reason
    FROM callstack c,
         debuggings d,
         info i
    WHERE c.debug_id = @debug_id
      AND d.id = @debug_id
      AND i.debug_id = @debug_id
      AND c.stack_depth = i.stack_depth
    INTO out_unit_name, out_module_name, out_module_owner, out_module_type, out_stack_depth, out_start_line, out_end_line, out_start_pos,
    out_end_pos, out_break_reason;
  ELSE
    SELECT
      break_reason
    FROM info
    WHERE debug_id = @debug_id
    INTO out_break_reason;
  END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `trace` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `trace`(IN in_start_line INTEGER, IN in_end_line INTEGER, IN in_start_pos INTEGER, IN in_end_pos INTEGER, IN in_stack_depth INTEGER)
    SQL SECURITY INVOKER
Trace:
BEGIN
  DECLARE step_kind,
          estimated_depth INTEGER DEFAULT -1;
  DECLARE cnt INT DEFAULT 0;

  IF (@debug_id > 0) THEN
    IF (in_stack_depth < @stack_depth) THEN
      CALL leave_module(in_stack_depth);
    END IF;

    UPDATE callstack
      SET start_line = in_start_line,
          end_line = in_end_line,
          start_pos = in_start_pos,
          end_pos = in_end_pos
      WHERE debug_id = @debug_id
        AND stack_depth = @stack_depth;

    SET step_kind := get_step_kind();

    IF (step_kind = 1100) THEN
      UPDATE info
        SET break_reason = 25
        WHERE debug_id = @debug_id;
      UPDATE debuggings
        SET cr_debug_terminated = 1
        WHERE id = @debug_id;
    END IF;

    IF (check_version_compatibility(@stack_depth) != 0) THEN
      LEAVE Trace;
    END IF;

    IF (step_kind = 2 OR step_kind = 3) THEN
      SELECT
        d.estimated_depth
      FROM debuggings d
      WHERE id = @debug_id
      INTO estimated_depth;

      IF (@stack_depth > estimated_depth AND check_breakpoint() = 0) THEN
        LEAVE Trace;
      END IF;

    ELSEIF (step_kind = 4 AND check_breakpoint() = 0) THEN
      LEAVE Trace;
    END IF;

    IF check_breakpoint() != 0 THEN
      UPDATE info
        SET break_reason = 22
        WHERE debug_id = @debug_id;
    ELSEIF step_kind IN (1, 2, 3) THEN
      UPDATE info
        SET break_reason = 21
        WHERE debug_id = @debug_id;
    ELSEIF step_kind = 4 THEN
      UPDATE info
        SET break_reason = 25
        WHERE debug_id = @debug_id;
    END IF;

    CALL switch_locks(1);
  END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `update_system_calls` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `update_system_calls`(IN in_query_type INTEGER)
BEGIN
  IF (in_query_type = 101) THEN
    SET @debug_found_rows := FOUND_ROWS();
  ELSEIF (in_query_type = 102) THEN
    SET @debug_row_count := ROW_COUNT();
    SET @debug_last_insert_id := LAST_INSERT_ID();
  ELSEIF (in_query_type = 103 OR in_query_type = 104) THEN
    SET @debug_row_count := ROW_COUNT();
  ELSE
    SET @debug_row_count := ROW_COUNT();
    SET @debug_found_rows := FOUND_ROWS();
    SET @debug_last_insert_id := LAST_INSERT_ID();
  END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `update_watch2` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `update_watch2`(IN in_watch_name VARCHAR(200), IN in_watch_value VARCHAR(65535), IN in_stack_depth INTEGER)
    SQL SECURITY INVOKER
BEGIN
  CALL update_watch3(in_watch_name, in_watch_value, '', in_stack_depth);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `update_watch3` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `update_watch3`(IN in_watch_name VARCHAR(200), IN in_watch_value VARCHAR(65535), IN in_watch_type VARCHAR(200), IN in_stack_depth INTEGER)
    SQL SECURITY INVOKER
BEGIN
  DECLARE watch_id INT DEFAULT -1;
  IF (@debug_id > 0) THEN

    SELECT
      id
    INTO watch_id
    FROM watches
    WHERE watch_name = in_watch_name
      AND stack_depth = in_stack_depth
      AND debug_id = @debug_id;

    IF (watch_id < 0) THEN
      INSERT INTO watches (watch_name, watch_value, watch_type, stack_depth, debug_id)
        VALUES (in_watch_name, in_watch_value, in_watch_type, in_stack_depth, @debug_id);
    ELSE
      UPDATE watches
        SET watch_name = in_watch_name,
            watch_value = in_watch_value,
            debug_id = @debug_id
        WHERE id = watch_id;
    END IF;
  END IF;
END ;;
DELIMITER ;

--
-- Current Database: `ftpusers`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `ftpusers` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `ftpusers`;

--
-- Table structure for table `admin`
--

CREATE TABLE `admin` (
  `Username` varchar(35) NOT NULL DEFAULT '',
  `Password` char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  PRIMARY KEY (`Username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `User` varchar(16) NOT NULL DEFAULT '',
  `Password` varchar(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `Uid` int(11) NOT NULL DEFAULT '14',
  `Gid` int(11) NOT NULL DEFAULT '5',
  `Dir` varchar(128) NOT NULL DEFAULT '',
  `QuotaFiles` int(10) NOT NULL DEFAULT '500',
  `QuotaSize` int(10) NOT NULL DEFAULT '30',
  `ULBandwidth` int(10) NOT NULL DEFAULT '80',
  `DLBandwidth` int(10) NOT NULL DEFAULT '80',
  `Ipaddress` varchar(15) NOT NULL DEFAULT '*',
  `Comment` tinytext,
  `Status` enum('0','1') NOT NULL DEFAULT '1',
  `ULRatio` smallint(5) NOT NULL DEFAULT '1',
  `DLRatio` smallint(5) NOT NULL DEFAULT '1',
  PRIMARY KEY (`User`),
  UNIQUE KEY `User` (`User`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping routines for database 'ftpusers'
--

--
-- Current Database: `intranet`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `intranet` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `intranet`;

--
-- Table structure for table `wp_commentmeta`
--

CREATE TABLE `wp_commentmeta` (
  `meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `comment_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meta_value` longtext COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`meta_id`),
  KEY `comment_id` (`comment_id`),
  KEY `meta_key` (`meta_key`(191))
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `wp_comments`
--

CREATE TABLE `wp_comments` (
  `comment_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `comment_post_ID` bigint(20) unsigned NOT NULL DEFAULT '0',
  `comment_author` tinytext COLLATE utf8mb4_unicode_ci NOT NULL,
  `comment_author_email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `comment_author_url` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `comment_author_IP` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `comment_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `comment_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `comment_content` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `comment_karma` int(11) NOT NULL DEFAULT '0',
  `comment_approved` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1',
  `comment_agent` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `comment_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `comment_parent` bigint(20) unsigned NOT NULL DEFAULT '0',
  `user_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`comment_ID`),
  KEY `comment_post_ID` (`comment_post_ID`),
  KEY `comment_approved_date_gmt` (`comment_approved`,`comment_date_gmt`),
  KEY `comment_date_gmt` (`comment_date_gmt`),
  KEY `comment_parent` (`comment_parent`),
  KEY `comment_author_email` (`comment_author_email`(10))
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `wp_eventscalendar_main`
--

CREATE TABLE `wp_eventscalendar_main` (
  `id` mediumint(9) NOT NULL AUTO_INCREMENT,
  `eventTitle` varchar(255) CHARACTER SET utf8 NOT NULL,
  `eventDescription` text CHARACTER SET utf8 NOT NULL,
  `eventLocation` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
  `eventLinkout` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
  `eventStartDate` date NOT NULL,
  `eventStartTime` time DEFAULT NULL,
  `eventEndDate` date NOT NULL,
  `eventEndTime` time DEFAULT NULL,
  `accessLevel` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT 'public',
  `postID` mediumint(9) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `wp_incarnate_avatars`
--

CREATE TABLE `wp_incarnate_avatars` (
  `commentid` bigint(11) NOT NULL,
  `avatar` tinytext NOT NULL,
  UNIQUE KEY `commentid` (`commentid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `wp_links`
--

CREATE TABLE `wp_links` (
  `link_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `link_url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `link_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `link_image` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `link_target` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `link_description` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `link_visible` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Y',
  `link_owner` bigint(20) unsigned NOT NULL DEFAULT '1',
  `link_rating` int(11) NOT NULL DEFAULT '0',
  `link_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `link_rel` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `link_notes` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `link_rss` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`link_id`),
  KEY `link_visible` (`link_visible`)
) ENGINE=MyISAM AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `wp_options`
--

CREATE TABLE `wp_options` (
  `option_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `option_name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `option_value` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `autoload` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'yes',
  PRIMARY KEY (`option_id`),
  UNIQUE KEY `option_name` (`option_name`)
) ENGINE=MyISAM AUTO_INCREMENT=21489 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `wp_ot_faq_categories`
--

CREATE TABLE `wp_ot_faq_categories` (
  `id` mediumint(9) NOT NULL AUTO_INCREMENT,
  `category` varchar(50) NOT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Table structure for table `wp_ot_faq_questions`
--

CREATE TABLE `wp_ot_faq_questions` (
  `id` mediumint(9) NOT NULL AUTO_INCREMENT,
  `category` int(9) NOT NULL DEFAULT '0',
  `question` text NOT NULL,
  `answer` text NOT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `wp_postmeta`
--

CREATE TABLE `wp_postmeta` (
  `meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `post_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meta_value` longtext COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`meta_id`),
  KEY `post_id` (`post_id`),
  KEY `meta_key` (`meta_key`(191))
) ENGINE=MyISAM AUTO_INCREMENT=854 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `wp_posts`
--

CREATE TABLE `wp_posts` (
  `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `post_author` bigint(20) unsigned NOT NULL DEFAULT '0',
  `post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `post_content` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `post_title` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `post_excerpt` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `post_status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'publish',
  `comment_status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',
  `ping_status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',
  `post_password` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `post_name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `to_ping` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `pinged` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `post_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `post_modified_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `post_content_filtered` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `post_parent` bigint(20) unsigned NOT NULL DEFAULT '0',
  `guid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `menu_order` int(11) NOT NULL DEFAULT '0',
  `post_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'post',
  `post_mime_type` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `comment_count` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`),
  KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`),
  KEY `post_parent` (`post_parent`),
  KEY `post_author` (`post_author`),
  KEY `post_name` (`post_name`(191))
) ENGINE=MyISAM AUTO_INCREMENT=1263 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `wp_term_relationships`
--

CREATE TABLE `wp_term_relationships` (
  `object_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `term_taxonomy_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `term_order` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`object_id`,`term_taxonomy_id`),
  KEY `term_taxonomy_id` (`term_taxonomy_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `wp_term_taxonomy`
--

CREATE TABLE `wp_term_taxonomy` (
  `term_taxonomy_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `term_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `taxonomy` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `description` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `parent` bigint(20) unsigned NOT NULL DEFAULT '0',
  `count` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`term_taxonomy_id`),
  UNIQUE KEY `term_id_taxonomy` (`term_id`,`taxonomy`),
  KEY `taxonomy` (`taxonomy`)
) ENGINE=MyISAM AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `wp_termmeta`
--

CREATE TABLE `wp_termmeta` (
  `meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `term_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meta_value` longtext COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`meta_id`),
  KEY `term_id` (`term_id`),
  KEY `meta_key` (`meta_key`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `wp_terms`
--

CREATE TABLE `wp_terms` (
  `term_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `slug` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `term_group` bigint(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`term_id`),
  KEY `slug` (`slug`(191)),
  KEY `name` (`name`(191))
) ENGINE=MyISAM AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `wp_usermeta`
--

CREATE TABLE `wp_usermeta` (
  `umeta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meta_value` longtext COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`umeta_id`),
  KEY `user_id` (`user_id`),
  KEY `meta_key` (`meta_key`(191))
) ENGINE=MyISAM AUTO_INCREMENT=126 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `wp_users`
--

CREATE TABLE `wp_users` (
  `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_login` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `user_pass` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `user_nicename` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `user_email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `user_url` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `user_registered` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `user_activation_key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `user_status` int(11) NOT NULL DEFAULT '0',
  `display_name` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`ID`),
  KEY `user_login_key` (`user_login`),
  KEY `user_nicename` (`user_nicename`),
  KEY `user_email` (`user_email`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping routines for database 'intranet'
--

--
-- Current Database: `mainpress_network`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mainpress_network` /*!40100 DEFAULT CHARACTER SET utf8 */;

USE `mainpress_network`;

--
-- Table structure for table `asset`
--

CREATE TABLE `asset` (
  `assetId` int(11) NOT NULL AUTO_INCREMENT,
  `type` varchar(25) DEFAULT NULL,
  `brand` varchar(25) DEFAULT NULL,
  `networkname` varchar(25) DEFAULT NULL,
  `model` varchar(25) DEFAULT NULL,
  `note` text,
  `MAC` varchar(20) DEFAULT NULL,
  `OS` varchar(25) DEFAULT NULL,
  `Active` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`assetId`)
) ENGINE=MyISAM AUTO_INCREMENT=87 DEFAULT CHARSET=utf8;

--
-- Table structure for table `asset_wallport`
--

CREATE TABLE `asset_wallport` (
  `assetId` int(11) NOT NULL,
  `wallportId` int(11) NOT NULL,
  PRIMARY KEY (`assetId`,`wallportId`),
  UNIQUE KEY `assetId` (`assetId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `location`
--

CREATE TABLE `location` (
  `locationId` int(11) NOT NULL AUTO_INCREMENT,
  `floor` varchar(15) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  UNIQUE KEY `locationId` (`locationId`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC;

--
-- Table structure for table `switch`
--

CREATE TABLE `switch` (
  `switchId` int(11) NOT NULL AUTO_INCREMENT,
  `stack` tinyint(4) NOT NULL DEFAULT '1',
  `port` int(11) NOT NULL,
  `description` text NOT NULL,
  PRIMARY KEY (`switchId`),
  UNIQUE KEY `stack` (`stack`,`port`)
) ENGINE=MyISAM AUTO_INCREMENT=193 DEFAULT CHARSET=utf8;

--
-- Table structure for table `switch_wallport`
--

CREATE TABLE `switch_wallport` (
  `switchId` int(11) NOT NULL,
  `wallportId` int(11) NOT NULL,
  PRIMARY KEY (`switchId`,`wallportId`),
  UNIQUE KEY `switchId` (`switchId`),
  UNIQUE KEY `wallportId` (`wallportId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `user`
--

CREATE TABLE `user` (
  `userId` int(11) NOT NULL AUTO_INCREMENT,
  `naam` varchar(25) DEFAULT NULL,
  `toestel` varbinary(25) DEFAULT NULL,
  `actief` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`userId`)
) ENGINE=MyISAM AUTO_INCREMENT=42 DEFAULT CHARSET=utf8;

--
-- Table structure for table `user_asset`
--

CREATE TABLE `user_asset` (
  `assetId` int(11) NOT NULL,
  `pId` int(11) NOT NULL,
  PRIMARY KEY (`assetId`),
  UNIQUE KEY `assetId` (`assetId`),
  KEY `pId` (`pId`),
  CONSTRAINT `user_asset_ibfk_1` FOREIGN KEY (`pId`) REFERENCES `Mainpress`.`personeel` (`persId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `user_asset_copy`
--

CREATE TABLE `user_asset_copy` (
  `userId` int(11) NOT NULL,
  `assetId` int(11) NOT NULL,
  PRIMARY KEY (`userId`,`assetId`),
  UNIQUE KEY `assetId` (`assetId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Temporary table structure for view `v_network`
--

/*!50001 DROP VIEW IF EXISTS `v_network`*/;
/*!50001 CREATE TABLE `v_network` (
  `type` tinyint NOT NULL,
  `brand` tinyint NOT NULL,
  `networkname` tinyint NOT NULL,
  `model` tinyint NOT NULL,
  `wallport` tinyint NOT NULL,
  `panel` tinyint NOT NULL,
  `floor` tinyint NOT NULL,
  `name` tinyint NOT NULL,
  `naam` tinyint NOT NULL,
  `assetId` tinyint NOT NULL,
  `wallportId` tinyint NOT NULL,
  `locationId` tinyint NOT NULL,
  `persId` tinyint NOT NULL,
  `switchId` tinyint NOT NULL,
  `stack` tinyint NOT NULL,
  `switchport` tinyint NOT NULL,
  `switchportdescription` tinyint NOT NULL,
  `switchportstring` tinyint NOT NULL,
  `active` tinyint NOT NULL,
  `assetNote` tinyint NOT NULL,
  `os` tinyint NOT NULL
) ENGINE=MyISAM */;

--
-- Temporary table structure for view `v_wallport`
--

/*!50001 DROP VIEW IF EXISTS `v_wallport`*/;
/*!50001 CREATE TABLE `v_wallport` (
  `wallportId` tinyint NOT NULL,
  `wallport` tinyint NOT NULL,
  `wallportname` tinyint NOT NULL,
  `locationId` tinyint NOT NULL
) ENGINE=MyISAM */;

--
-- Table structure for table `wallport`
--

CREATE TABLE `wallport` (
  `wallportId` int(11) NOT NULL AUTO_INCREMENT,
  `wallport` varchar(10) DEFAULT NULL,
  `panel` int(3) DEFAULT NULL,
  `port` int(3) DEFAULT NULL,
  `locationId` int(11) DEFAULT NULL,
  `patched` tinyint(1) NOT NULL DEFAULT '0',
  `phone` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`wallportId`)
) ENGINE=MyISAM AUTO_INCREMENT=241 DEFAULT CHARSET=utf8;

--
-- Dumping routines for database 'mainpress_network'
--

--
-- Current Database: `mysql`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysql` /*!40100 DEFAULT CHARACTER SET utf8 */;

USE `mysql`;

--
-- Table structure for table `column_stats`
--

CREATE TABLE `column_stats` (
  `db_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `column_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `min_value` varbinary(255) DEFAULT NULL,
  `max_value` varbinary(255) DEFAULT NULL,
  `nulls_ratio` decimal(12,4) DEFAULT NULL,
  `avg_length` decimal(12,4) DEFAULT NULL,
  `avg_frequency` decimal(12,4) DEFAULT NULL,
  `hist_size` tinyint(3) unsigned DEFAULT NULL,
  `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') COLLATE utf8_bin DEFAULT NULL,
  `histogram` varbinary(255) DEFAULT NULL,
  PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns';

--
-- Table structure for table `columns_priv`
--

CREATE TABLE `columns_priv` (
  `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
  `User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Table_name` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Column_name` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 NOT NULL DEFAULT '',
  PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Column privileges';

--
-- Table structure for table `db`
--

CREATE TABLE `db` (
  `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
  `User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Event_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  PRIMARY KEY (`Host`,`Db`,`User`),
  KEY `User` (`User`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Database privileges';

--
-- Table structure for table `event`
--

CREATE TABLE `event` (
  `db` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  `name` char(64) NOT NULL DEFAULT '',
  `body` longblob NOT NULL,
  `definer` char(141) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  `execute_at` datetime DEFAULT NULL,
  `interval_value` int(11) DEFAULT NULL,
  `interval_field` enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') DEFAULT NULL,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `last_executed` datetime DEFAULT NULL,
  `starts` datetime DEFAULT NULL,
  `ends` datetime DEFAULT NULL,
  `status` enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL DEFAULT 'ENABLED',
  `on_completion` enum('DROP','PRESERVE') NOT NULL DEFAULT 'DROP',
  `sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NOT NULL DEFAULT '',
  `comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  `originator` int(10) unsigned NOT NULL,
  `time_zone` char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM',
  `character_set_client` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `collation_connection` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `body_utf8` longblob,
  PRIMARY KEY (`db`,`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Events';

--
-- Table structure for table `func`
--

CREATE TABLE `func` (
  `name` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
  `ret` tinyint(1) NOT NULL DEFAULT '0',
  `dl` char(128) COLLATE utf8_bin NOT NULL DEFAULT '',
  `type` enum('function','aggregate') CHARACTER SET utf8 NOT NULL,
  PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User defined functions';

--
-- Table structure for table `gtid_slave_pos`
--

CREATE TABLE `gtid_slave_pos` (
  `domain_id` int(10) unsigned NOT NULL,
  `sub_id` bigint(20) unsigned NOT NULL,
  `server_id` int(10) unsigned NOT NULL,
  `seq_no` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`domain_id`,`sub_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Replication slave GTID position';

--
-- Table structure for table `help_category`
--

CREATE TABLE `help_category` (
  `help_category_id` smallint(5) unsigned NOT NULL,
  `name` char(64) NOT NULL,
  `parent_category_id` smallint(5) unsigned DEFAULT NULL,
  `url` text NOT NULL,
  PRIMARY KEY (`help_category_id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='help categories';

--
-- Table structure for table `help_keyword`
--

CREATE TABLE `help_keyword` (
  `help_keyword_id` int(10) unsigned NOT NULL,
  `name` char(64) NOT NULL,
  PRIMARY KEY (`help_keyword_id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='help keywords';

--
-- Table structure for table `help_relation`
--

CREATE TABLE `help_relation` (
  `help_topic_id` int(10) unsigned NOT NULL,
  `help_keyword_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`help_keyword_id`,`help_topic_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='keyword-topic relation';

--
-- Table structure for table `help_topic`
--

CREATE TABLE `help_topic` (
  `help_topic_id` int(10) unsigned NOT NULL,
  `name` char(64) NOT NULL,
  `help_category_id` smallint(5) unsigned NOT NULL,
  `description` text NOT NULL,
  `example` text NOT NULL,
  `url` text NOT NULL,
  PRIMARY KEY (`help_topic_id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='help topics';

--
-- Table structure for table `host`
--

CREATE TABLE `host` (
  `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  PRIMARY KEY (`Host`,`Db`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Host privileges;  Merged with database privileges';

--
-- Table structure for table `index_stats`
--

CREATE TABLE `index_stats` (
  `db_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `index_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `prefix_arity` int(11) unsigned NOT NULL,
  `avg_frequency` decimal(12,4) DEFAULT NULL,
  PRIMARY KEY (`db_name`,`table_name`,`index_name`,`prefix_arity`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes';

--
-- Table structure for table `innodb_index_stats`
--

CREATE TABLE `innodb_index_stats` (
  `database_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `index_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `stat_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `stat_value` bigint(20) unsigned NOT NULL,
  `sample_size` bigint(20) unsigned DEFAULT NULL,
  `stat_description` varchar(1024) COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;

--
-- Table structure for table `innodb_table_stats`
--

CREATE TABLE `innodb_table_stats` (
  `database_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `n_rows` bigint(20) unsigned NOT NULL,
  `clustered_index_size` bigint(20) unsigned NOT NULL,
  `sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`database_name`,`table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;

--
-- Table structure for table `ndb_binlog_index`
--

CREATE TABLE `ndb_binlog_index` (
  `Position` bigint(20) unsigned NOT NULL,
  `File` varchar(255) NOT NULL,
  `epoch` bigint(20) unsigned NOT NULL,
  `inserts` bigint(20) unsigned NOT NULL,
  `updates` bigint(20) unsigned NOT NULL,
  `deletes` bigint(20) unsigned NOT NULL,
  `schemaops` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`epoch`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `plugin`
--

CREATE TABLE `plugin` (
  `name` varchar(64) NOT NULL DEFAULT '',
  `dl` varchar(128) NOT NULL DEFAULT '',
  PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL plugins';

--
-- Table structure for table `proc`
--

CREATE TABLE `proc` (
  `db` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  `name` char(64) NOT NULL DEFAULT '',
  `type` enum('FUNCTION','PROCEDURE') NOT NULL,
  `specific_name` char(64) NOT NULL DEFAULT '',
  `language` enum('SQL') NOT NULL DEFAULT 'SQL',
  `sql_data_access` enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA') NOT NULL DEFAULT 'CONTAINS_SQL',
  `is_deterministic` enum('YES','NO') NOT NULL DEFAULT 'NO',
  `security_type` enum('INVOKER','DEFINER') NOT NULL DEFAULT 'DEFINER',
  `param_list` blob NOT NULL,
  `returns` longblob NOT NULL,
  `body` longblob NOT NULL,
  `definer` char(141) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NOT NULL DEFAULT '',
  `comment` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `character_set_client` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `collation_connection` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `body_utf8` longblob,
  PRIMARY KEY (`db`,`name`,`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stored Procedures';

--
-- Table structure for table `procs_priv`
--

CREATE TABLE `procs_priv` (
  `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
  `User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Routine_name` char(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `Routine_type` enum('FUNCTION','PROCEDURE') COLLATE utf8_bin NOT NULL,
  `Grantor` char(141) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Proc_priv` set('Execute','Alter Routine','Grant') CHARACTER SET utf8 NOT NULL DEFAULT '',
  `Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`Host`,`Db`,`User`,`Routine_name`,`Routine_type`),
  KEY `Grantor` (`Grantor`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Procedure privileges';

--
-- Table structure for table `proxies_priv`
--

CREATE TABLE `proxies_priv` (
  `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
  `User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Proxied_host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Proxied_user` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
  `With_grant` tinyint(1) NOT NULL DEFAULT '0',
  `Grantor` char(141) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`Host`,`User`,`Proxied_host`,`Proxied_user`),
  KEY `Grantor` (`Grantor`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User proxy privileges';

--
-- Table structure for table `roles_mapping`
--

CREATE TABLE `roles_mapping` (
  `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
  `User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Role` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Admin_option` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  UNIQUE KEY `Host` (`Host`,`User`,`Role`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Granted roles';

--
-- Table structure for table `servers`
--

CREATE TABLE `servers` (
  `Server_name` char(64) NOT NULL DEFAULT '',
  `Host` char(64) NOT NULL DEFAULT '',
  `Db` char(64) NOT NULL DEFAULT '',
  `Username` char(80) NOT NULL DEFAULT '',
  `Password` char(64) NOT NULL DEFAULT '',
  `Port` int(4) NOT NULL DEFAULT '0',
  `Socket` char(64) NOT NULL DEFAULT '',
  `Wrapper` char(64) NOT NULL DEFAULT '',
  `Owner` char(64) NOT NULL DEFAULT '',
  PRIMARY KEY (`Server_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table';

--
-- Table structure for table `table_stats`
--

CREATE TABLE `table_stats` (
  `db_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
  `cardinality` bigint(21) unsigned DEFAULT NULL,
  PRIMARY KEY (`db_name`,`table_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Tables';

--
-- Table structure for table `tables_priv`
--

CREATE TABLE `tables_priv` (
  `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
  `User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Table_name` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Grantor` char(141) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `Table_priv` set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') CHARACTER SET utf8 NOT NULL DEFAULT '',
  `Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 NOT NULL DEFAULT '',
  PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
  KEY `Grantor` (`Grantor`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Table privileges';

--
-- Table structure for table `time_zone`
--

CREATE TABLE `time_zone` (
  `Time_zone_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Use_leap_seconds` enum('Y','N') NOT NULL DEFAULT 'N',
  PRIMARY KEY (`Time_zone_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1740 DEFAULT CHARSET=utf8 COMMENT='Time zones';

--
-- Table structure for table `time_zone_leap_second`
--

CREATE TABLE `time_zone_leap_second` (
  `Transition_time` bigint(20) NOT NULL,
  `Correction` int(11) NOT NULL,
  PRIMARY KEY (`Transition_time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Leap seconds information for time zones';

--
-- Table structure for table `time_zone_name`
--

CREATE TABLE `time_zone_name` (
  `Name` char(64) NOT NULL,
  `Time_zone_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`Name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Time zone names';

--
-- Table structure for table `time_zone_transition`
--

CREATE TABLE `time_zone_transition` (
  `Time_zone_id` int(10) unsigned NOT NULL,
  `Transition_time` bigint(20) NOT NULL,
  `Transition_type_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`Time_zone_id`,`Transition_time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Time zone transitions';

--
-- Table structure for table `time_zone_transition_type`
--

CREATE TABLE `time_zone_transition_type` (
  `Time_zone_id` int(10) unsigned NOT NULL,
  `Transition_type_id` int(10) unsigned NOT NULL,
  `Offset` int(11) NOT NULL DEFAULT '0',
  `Is_DST` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `Abbreviation` char(8) NOT NULL DEFAULT '',
  PRIMARY KEY (`Time_zone_id`,`Transition_type_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Time zone transition types';

--
-- Table structure for table `user`
--

CREATE TABLE `user` (
  `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
  `User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
  `Password` char(41) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Reload_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Shutdown_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Process_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `File_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Show_db_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Super_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Repl_slave_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Repl_client_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_user_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Event_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `Create_tablespace_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `ssl_type` enum('','ANY','X509','SPECIFIED') CHARACTER SET utf8 NOT NULL DEFAULT '',
  `ssl_cipher` blob NOT NULL,
  `x509_issuer` blob NOT NULL,
  `x509_subject` blob NOT NULL,
  `max_questions` int(11) unsigned NOT NULL DEFAULT '0',
  `max_updates` int(11) unsigned NOT NULL DEFAULT '0',
  `max_connections` int(11) unsigned NOT NULL DEFAULT '0',
  `max_user_connections` int(11) NOT NULL DEFAULT '0',
  `plugin` char(64) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `authentication_string` text COLLATE utf8_bin NOT NULL,
  `password_expired` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `is_role` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
  `default_role` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
  `max_statement_time` decimal(12,6) NOT NULL DEFAULT '0.000000',
  PRIMARY KEY (`Host`,`User`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges';

--
-- Table structure for table `user_info`
--

CREATE TABLE `user_info` (
  `User` varchar(16) COLLATE utf8_bin NOT NULL,
  `Full_name` varchar(60) COLLATE utf8_bin DEFAULT NULL,
  `Description` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `Email` varchar(80) COLLATE utf8_bin DEFAULT NULL,
  `Contact_information` text COLLATE utf8_bin,
  `Icon` blob,
  PRIMARY KEY (`User`),
  KEY `user_info_Full_name` (`Full_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Stores additional user information';

--
-- Dumping routines for database 'mysql'
--

--
-- Table structure for table `general_log`
--

CREATE TABLE IF NOT EXISTS `general_log` (
  `event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  `user_host` mediumtext NOT NULL,
  `thread_id` int(11) NOT NULL,
  `server_id` int(10) unsigned NOT NULL,
  `command_type` varchar(64) NOT NULL,
  `argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';

--
-- Table structure for table `slow_log`
--

CREATE TABLE IF NOT EXISTS `slow_log` (
  `start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  `user_host` mediumtext NOT NULL,
  `query_time` time(6) NOT NULL,
  `lock_time` time(6) NOT NULL,
  `rows_sent` int(11) NOT NULL,
  `rows_examined` int(11) NOT NULL,
  `db` varchar(512) NOT NULL,
  `last_insert_id` int(11) NOT NULL,
  `insert_id` int(11) NOT NULL,
  `server_id` int(10) unsigned NOT NULL,
  `sql_text` mediumtext NOT NULL,
  `thread_id` bigint(21) unsigned NOT NULL,
  `rows_affected` int(11) NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';

--
-- Current Database: `northwind`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `northwind` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `northwind`;

--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `CategoryID` int(11) NOT NULL AUTO_INCREMENT,
  `CategoryName` varchar(15) NOT NULL,
  `Description` text,
  `Picture` longblob,
  PRIMARY KEY (`CategoryID`),
  UNIQUE KEY `CategoryName` (`CategoryName`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;

--
-- Table structure for table `customers`
--

CREATE TABLE `customers` (
  `CustomerID` varchar(5) NOT NULL,
  `CompanyName` varchar(40) NOT NULL,
  `ContactName` varchar(30) DEFAULT NULL,
  `ContactTitle` varchar(30) DEFAULT NULL,
  `Address` varchar(60) DEFAULT NULL,
  `City` varchar(15) DEFAULT NULL,
  `Region` varchar(15) DEFAULT NULL,
  `PostalCode` varchar(10) DEFAULT NULL,
  `Country` varchar(15) DEFAULT NULL,
  `Phone` varchar(24) DEFAULT NULL,
  `Fax` varchar(24) DEFAULT NULL,
  PRIMARY KEY (`CustomerID`),
  KEY `City` (`City`),
  KEY `CompanyName` (`CompanyName`),
  KEY `PostalCode` (`PostalCode`),
  KEY `Region` (`Region`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `employees`
--

CREATE TABLE `employees` (
  `EmployeeID` int(11) NOT NULL AUTO_INCREMENT,
  `LastName` varchar(20) NOT NULL,
  `FirstName` varchar(10) NOT NULL,
  `Title` varchar(30) DEFAULT NULL,
  `TitleOfCourtesy` varchar(25) DEFAULT NULL,
  `BirthDate` datetime DEFAULT NULL,
  `HireDate` datetime DEFAULT NULL,
  `Address` varchar(60) DEFAULT NULL,
  `City` varchar(15) DEFAULT NULL,
  `Region` varchar(15) DEFAULT NULL,
  `PostalCode` varchar(10) DEFAULT NULL,
  `Country` varchar(15) DEFAULT NULL,
  `HomePhone` varchar(24) DEFAULT NULL,
  `Extension` varchar(4) DEFAULT NULL,
  `Photo` varchar(255) DEFAULT NULL,
  `Notes` text,
  `ReportsTo` int(11) DEFAULT NULL,
  PRIMARY KEY (`EmployeeID`),
  KEY `LastName` (`LastName`),
  KEY `PostalCode` (`PostalCode`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

--
-- Table structure for table `order_details`
--

CREATE TABLE `order_details` (
  `OrderID` int(11) NOT NULL,
  `ProductID` int(11) NOT NULL,
  `UnitPrice` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `Quantity` int(11) NOT NULL DEFAULT '1',
  `Discount` float NOT NULL DEFAULT '0',
  PRIMARY KEY (`OrderID`,`ProductID`),
  KEY `OrderID` (`OrderID`),
  KEY `ProductID` (`ProductID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `orders`
--

CREATE TABLE `orders` (
  `OrderID` int(11) NOT NULL AUTO_INCREMENT,
  `CustomerID` varchar(5) DEFAULT NULL,
  `EmployeeID` int(11) DEFAULT NULL,
  `OrderDate` datetime DEFAULT NULL,
  `RequiredDate` datetime DEFAULT NULL,
  `ShippedDate` datetime DEFAULT NULL,
  `ShipVia` int(11) DEFAULT NULL,
  `Freight` decimal(19,4) DEFAULT '0.0000',
  `ShipName` varchar(40) DEFAULT NULL,
  `ShipAddress` varchar(60) DEFAULT NULL,
  `ShipCity` varchar(15) DEFAULT NULL,
  `ShipRegion` varchar(15) DEFAULT NULL,
  `ShipPostalCode` varchar(10) DEFAULT NULL,
  `ShipCountry` varchar(15) DEFAULT NULL,
  PRIMARY KEY (`OrderID`),
  KEY `CustomerID` (`CustomerID`),
  KEY `EmployeeID` (`EmployeeID`),
  KEY `OrderDate` (`OrderDate`),
  KEY `ShippedDate` (`ShippedDate`),
  KEY `ShipPostalCode` (`ShipPostalCode`)
) ENGINE=MyISAM AUTO_INCREMENT=11078 DEFAULT CHARSET=utf8;

--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `ProductID` int(11) NOT NULL AUTO_INCREMENT,
  `ProductName` varchar(40) NOT NULL,
  `SupplierID` int(11) DEFAULT NULL,
  `CategoryID` int(11) DEFAULT NULL,
  `QuantityPerUnit` varchar(20) DEFAULT NULL,
  `UnitPrice` decimal(19,4) DEFAULT '0.0000',
  `UnitsInStock` int(11) DEFAULT '0',
  `UnitsOnOrder` int(11) DEFAULT '0',
  `ReorderLevel` int(11) DEFAULT '0',
  `Discontinued` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`ProductID`),
  KEY `CategoryID` (`CategoryID`),
  KEY `ProductName` (`ProductName`),
  KEY `SupplierID` (`SupplierID`)
) ENGINE=MyISAM AUTO_INCREMENT=78 DEFAULT CHARSET=utf8;

--
-- Table structure for table `shippers`
--

CREATE TABLE `shippers` (
  `ShipperID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyName` varchar(40) NOT NULL,
  `Phone` varchar(24) DEFAULT NULL,
  PRIMARY KEY (`ShipperID`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Table structure for table `suppliers`
--

CREATE TABLE `suppliers` (
  `SupplierID` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyName` varchar(40) NOT NULL,
  `ContactName` varchar(30) DEFAULT NULL,
  `ContactTitle` varchar(30) DEFAULT NULL,
  `Address` varchar(60) DEFAULT NULL,
  `City` varchar(15) DEFAULT NULL,
  `Region` varchar(15) DEFAULT NULL,
  `PostalCode` varchar(10) DEFAULT NULL,
  `Country` varchar(15) DEFAULT NULL,
  `Phone` varchar(24) DEFAULT NULL,
  `Fax` varchar(24) DEFAULT NULL,
  `HomePage` text,
  PRIMARY KEY (`SupplierID`),
  KEY `CompanyName` (`CompanyName`),
  KEY `PostalCode` (`PostalCode`)
) ENGINE=MyISAM AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;

--
-- Dumping routines for database 'northwind'
--

--
-- Current Database: `percona`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `percona` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `percona`;

--
-- Table structure for table `checksums`
--

CREATE TABLE `checksums` (
  `db` char(64) NOT NULL,
  `tbl` char(64) NOT NULL,
  `chunk` int(11) NOT NULL,
  `chunk_time` float DEFAULT NULL,
  `chunk_index` varchar(200) DEFAULT NULL,
  `lower_boundary` text,
  `upper_boundary` text,
  `this_crc` char(40) NOT NULL,
  `this_cnt` int(11) NOT NULL,
  `master_crc` char(40) DEFAULT NULL,
  `master_cnt` int(11) DEFAULT NULL,
  `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`db`,`tbl`,`chunk`),
  KEY `ts_db_tbl` (`ts`,`db`,`tbl`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `dsns`
--

CREATE TABLE `dsns` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `parent_id` int(11) DEFAULT NULL,
  `dsn` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Dumping routines for database 'percona'
--

--
-- Current Database: `php_sessions`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `php_sessions` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `php_sessions`;

--
-- Table structure for table `comjur`
--

CREATE TABLE `comjur` (
  `sessionID` varchar(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
  `sessionExpirationTS` int(10) unsigned NOT NULL,
  `sessionData` longtext COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`sessionID`),
  KEY `sessionExpirationTS` (`sessionExpirationTS`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `mgtboek`
--

CREATE TABLE `mgtboek` (
  `sessionID` varchar(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
  `sessionExpirationTS` int(10) unsigned NOT NULL,
  `sessionData` longtext COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`sessionID`),
  KEY `sessionExpirationTS` (`sessionExpirationTS`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tblSession`
--

CREATE TABLE `tblSession` (
  `vchName` varchar(255) NOT NULL DEFAULT '',
  `uxtExpires` int(10) unsigned NOT NULL DEFAULT '0',
  `txtData` longtext,
  PRIMARY KEY (`vchName`),
  KEY `idxExpires` (`uxtExpires`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=COMPRESSED;

--
-- Dumping routines for database 'php_sessions'
--

--
-- Current Database: `sbtest`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `sbtest` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `sbtest`;

--
-- Table structure for table `sbtest`
--

CREATE TABLE `sbtest` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `k` int(10) unsigned NOT NULL DEFAULT '0',
  `c` char(120) NOT NULL DEFAULT '',
  `pad` char(60) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `k` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=latin1;

--
-- Dumping routines for database 'sbtest'
--

--
-- Current Database: `test`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET utf8 */;

USE `test`;

--
-- Table structure for table `BestellingenSander`
--

CREATE TABLE `BestellingenSander` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Auteurnaam` varchar(200) CHARACTER SET utf8 DEFAULT NULL,
  `Aantal` int(11) DEFAULT NULL,
  `Prijs` int(11) DEFAULT NULL,
  `Bestellingid` int(11) DEFAULT NULL,
  `Ean` varchar(13) DEFAULT NULL,
  `Omschrijving` varchar(200) CHARACTER SET utf8 DEFAULT NULL,
  `Geexporteerd` tinyint(4) NOT NULL DEFAULT '0',
  `KortingPercentage` decimal(4,2) NOT NULL DEFAULT '0.00',
  `IsPromo` int(11) NOT NULL DEFAULT '0',
  `KortingReden` char(3) CHARACTER SET utf8 DEFAULT NULL,
  `KortingMP` int(11) DEFAULT '0',
  `KostenMP` decimal(4,2) DEFAULT '0.00',
  `DTOrderregel` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `VastePrijs` decimal(6,2) DEFAULT '0.00',
  `ActiePrijs` decimal(6,2) DEFAULT '0.00',
  `BTWTarief` decimal(3,1) DEFAULT '0.0',
  `BTWCode` char(1) DEFAULT '0',
  `AantalBackorder` int(11) DEFAULT '0',
  `BackorderOrigineel` int(11) DEFAULT NULL,
  `BackorderReden` int(11) DEFAULT NULL,
  `BriefCode` varchar(20) DEFAULT NULL,
  `DTExactExport` datetime DEFAULT NULL,
  `KortingBedrag` decimal(10,2) NOT NULL DEFAULT '0.00',
  `KortingBedragExBtw` decimal(10,2) DEFAULT '0.00',
  `PrijsExBtwExKorting` decimal(10,2) DEFAULT '0.00',
  `PrijsExBtwIncKorting` decimal(10,2) DEFAULT '0.00',
  `BedragExBtwExKorting` decimal(10,2) DEFAULT '0.00',
  `BedragIncBtwExKorting` decimal(10,2) DEFAULT '0.00',
  `BedragIncBtwIncKorting` decimal(10,2) DEFAULT '0.00',
  `BedragExBtwIncKorting` decimal(10,2) DEFAULT '0.00',
  `BedragBTW` decimal(10,2) DEFAULT '0.00',
  `LineNr` int(11) NOT NULL DEFAULT '0',
  `Geannuleerd` tinyint(4) DEFAULT '0',
  `Bijdrage` decimal(10,2) NOT NULL DEFAULT '0.00',
  `OmzetExBtwExKorting` decimal(10,2) NOT NULL DEFAULT '0.00',
  `OmzetExBtwIncKorting` decimal(10,2) NOT NULL DEFAULT '0.00',
  `OmzetIncBtwExKorting` decimal(10,2) NOT NULL DEFAULT '0.00',
  `OmzetIncBtwIncKorting` decimal(10,2) NOT NULL DEFAULT '0.00',
  `StatusId` tinyint(4) DEFAULT '0',
  `FactuurId` int(11) DEFAULT NULL,
  `RegelReferentie` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
  `RegelKostenplaats` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
  `RegelOrganisatieID` int(11) NOT NULL DEFAULT '0',
  `RegelAfleverdebiteur` int(11) NOT NULL DEFAULT '0' COMMENT 'Yes, really. :-(',
  `BoekStatusBijBestelling` tinyint(4) DEFAULT NULL,
  `PrijsInkoop` decimal(10,2) NOT NULL DEFAULT '0.00',
  `ICL` tinyint(1) DEFAULT '0',
  `AantalGeleverd` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `Bestellingid` (`Bestellingid`),
  KEY `Artikelcode` (`Ean`),
  KEY `NewIndex1` (`Id`,`BackorderOrigineel`),
  KEY `NewIndex2` (`AantalBackorder`),
  KEY `backorder` (`BackorderOrigineel`),
  KEY `NewIndex3` (`StatusId`),
  KEY `FactuurId` (`FactuurId`),
  KEY `IsPromo` (`IsPromo`),
  KEY `Delete` (`Bestellingid`,`IsPromo`),
  KEY `BesteldVoor` (`RegelAfleverdebiteur`)
) ENGINE=InnoDB AUTO_INCREMENT=50383805 DEFAULT CHARSET=latin1;

--
-- Table structure for table `Voorraad`
--

CREATE TABLE `Voorraad` (
  `EAN` char(13) NOT NULL,
  `ExactID` int(11) NOT NULL,
  `PeriodeID` int(11) NOT NULL,
  `Voorraad` int(11) NOT NULL,
  `Forecast` int(11) NOT NULL,
  PRIMARY KEY (`EAN`,`ExactID`,`PeriodeID`),
  KEY `PeriodeID` (`PeriodeID`),
  KEY `FK_Voorraad_Personen` (`ExactID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC;
ALTER DATABASE `test` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`sander`@`%`*/ /*!50003 TRIGGER `insvooraad` AFTER INSERT ON `Voorraad` FOR EACH ROW BEGIN
	INSERT INTO tt ( initials, `action`, ean, exactid, DT, oud, nieuw )  VALUES ( @initials, 'insert', NEW.EAN, NEW.ExactID, NOW(), 0, NEW.Voorraad );
    END */;;
DELIMITER ;
ALTER DATABASE `test` CHARACTER SET utf8 COLLATE utf8_general_ci ;
ALTER DATABASE `test` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`sander`@`%`*/ /*!50003 TRIGGER `voorraadwijziging` AFTER UPDATE ON `Voorraad` FOR EACH ROW BEGIN
	INSERT INTO tt ( initials, `action`, ean, exactid, DT, oud, nieuw )  VALUES ( @initials, 'update', NEW.EAN, NEW.ExactID, NOW(), OLD.Voorraad, NEW.Voorraad );
    END */;;
DELIMITER ;
ALTER DATABASE `test` CHARACTER SET utf8 COLLATE utf8_general_ci ;
ALTER DATABASE `test` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`sander`@`%`*/ /*!50003 TRIGGER `delvoorraad` AFTER DELETE ON `Voorraad` FOR EACH ROW BEGIN
	INSERT INTO tt ( initials, `action`, ean, exactid, DT, oud, nieuw )  VALUES ( @initials, 'delete', OLD.EAN, OLD.ExactID, NOW(), OLD.Voorraad, 0 );
    END */;;
DELIMITER ;
ALTER DATABASE `test` CHARACTER SET utf8 COLLATE utf8_general_ci ;

--
-- Table structure for table `a`
--

CREATE TABLE `a` (
  `boe` varchar(3) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `checksum`
--

CREATE TABLE `checksum` (
  `db` char(64) NOT NULL,
  `tbl` char(64) NOT NULL,
  `chunk` int(11) NOT NULL,
  `chunk_time` float DEFAULT NULL,
  `chunk_index` varchar(200) DEFAULT NULL,
  `lower_boundary` text,
  `upper_boundary` text,
  `this_crc` char(40) NOT NULL,
  `this_cnt` int(11) NOT NULL,
  `master_crc` char(40) DEFAULT NULL,
  `master_cnt` int(11) DEFAULT NULL,
  `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`db`,`tbl`,`chunk`),
  KEY `ts_db_tbl` (`ts`,`db`,`tbl`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `deadlocks`
--

CREATE TABLE `deadlocks` (
  `server` char(20) NOT NULL,
  `ts` datetime NOT NULL,
  `thread` int(10) unsigned NOT NULL,
  `txn_id` bigint(20) unsigned NOT NULL,
  `txn_time` smallint(5) unsigned NOT NULL,
  `user` char(16) NOT NULL,
  `hostname` char(20) NOT NULL,
  `ip` char(15) NOT NULL,
  `db` char(64) NOT NULL,
  `tbl` char(64) NOT NULL,
  `idx` char(64) NOT NULL,
  `lock_type` char(16) NOT NULL,
  `lock_mode` char(1) NOT NULL,
  `wait_hold` char(1) NOT NULL,
  `victim` tinyint(3) unsigned NOT NULL,
  `query` text NOT NULL,
  PRIMARY KEY (`server`,`ts`,`thread`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `s1`
--

CREATE TABLE `s1` (
  `x` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `sandertest_categories`
--

CREATE TABLE `sandertest_categories` (
  `cat_ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `cat_name` varchar(55) NOT NULL DEFAULT '',
  `category_nicename` varchar(200) NOT NULL DEFAULT '',
  `category_description` longtext NOT NULL,
  `category_parent` bigint(20) NOT NULL DEFAULT '0',
  `category_count` bigint(20) NOT NULL DEFAULT '0',
  `link_count` bigint(20) NOT NULL DEFAULT '0',
  `posts_private` tinyint(1) NOT NULL DEFAULT '0',
  `links_private` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`cat_ID`),
  KEY `category_nicename` (`category_nicename`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sandertest_comments`
--

CREATE TABLE `sandertest_comments` (
  `comment_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `comment_post_ID` int(11) NOT NULL DEFAULT '0',
  `comment_author` tinytext NOT NULL,
  `comment_author_email` varchar(100) NOT NULL DEFAULT '',
  `comment_author_url` varchar(200) NOT NULL DEFAULT '',
  `comment_author_IP` varchar(100) NOT NULL DEFAULT '',
  `comment_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `comment_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `comment_content` text NOT NULL,
  `comment_karma` int(11) NOT NULL DEFAULT '0',
  `comment_approved` enum('0','1','spam') NOT NULL DEFAULT '1',
  `comment_agent` varchar(255) NOT NULL DEFAULT '',
  `comment_type` varchar(20) NOT NULL DEFAULT '',
  `comment_parent` bigint(20) NOT NULL DEFAULT '0',
  `user_id` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`comment_ID`),
  KEY `comment_approved` (`comment_approved`),
  KEY `comment_post_ID` (`comment_post_ID`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sandertest_link2cat`
--

CREATE TABLE `sandertest_link2cat` (
  `rel_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `link_id` bigint(20) NOT NULL DEFAULT '0',
  `category_id` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`rel_id`),
  KEY `link_id` (`link_id`,`category_id`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sandertest_links`
--

CREATE TABLE `sandertest_links` (
  `link_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `link_url` varchar(255) NOT NULL DEFAULT '',
  `link_name` varchar(255) NOT NULL DEFAULT '',
  `link_image` varchar(255) NOT NULL DEFAULT '',
  `link_target` varchar(25) NOT NULL DEFAULT '',
  `link_category` bigint(20) NOT NULL DEFAULT '0',
  `link_description` varchar(255) NOT NULL DEFAULT '',
  `link_visible` enum('Y','N') NOT NULL DEFAULT 'Y',
  `link_owner` int(11) NOT NULL DEFAULT '1',
  `link_rating` int(11) NOT NULL DEFAULT '0',
  `link_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `link_rel` varchar(255) NOT NULL DEFAULT '',
  `link_notes` mediumtext NOT NULL,
  `link_rss` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`link_id`),
  KEY `link_category` (`link_category`),
  KEY `link_visible` (`link_visible`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sandertest_options`
--

CREATE TABLE `sandertest_options` (
  `option_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `blog_id` int(11) NOT NULL DEFAULT '0',
  `option_name` varchar(64) NOT NULL DEFAULT '',
  `option_can_override` enum('Y','N') NOT NULL DEFAULT 'Y',
  `option_type` int(11) NOT NULL DEFAULT '1',
  `option_value` longtext NOT NULL,
  `option_width` int(11) NOT NULL DEFAULT '20',
  `option_height` int(11) NOT NULL DEFAULT '8',
  `option_description` tinytext NOT NULL,
  `option_admin_level` int(11) NOT NULL DEFAULT '1',
  `autoload` enum('yes','no') NOT NULL DEFAULT 'yes',
  PRIMARY KEY (`option_id`,`blog_id`,`option_name`),
  KEY `option_name` (`option_name`)
) ENGINE=MyISAM AUTO_INCREMENT=75 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sandertest_post2cat`
--

CREATE TABLE `sandertest_post2cat` (
  `rel_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `post_id` bigint(20) NOT NULL DEFAULT '0',
  `category_id` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`rel_id`),
  KEY `post_id` (`post_id`,`category_id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sandertest_postmeta`
--

CREATE TABLE `sandertest_postmeta` (
  `meta_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `post_id` bigint(20) NOT NULL DEFAULT '0',
  `meta_key` varchar(255) DEFAULT NULL,
  `meta_value` longtext,
  PRIMARY KEY (`meta_id`),
  KEY `post_id` (`post_id`),
  KEY `meta_key` (`meta_key`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `sandertest_posts`
--

CREATE TABLE `sandertest_posts` (
  `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `post_author` bigint(20) NOT NULL DEFAULT '0',
  `post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `post_content` longtext NOT NULL,
  `post_title` text NOT NULL,
  `post_category` int(4) NOT NULL DEFAULT '0',
  `post_excerpt` text NOT NULL,
  `post_status` enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL DEFAULT 'publish',
  `comment_status` enum('open','closed','registered_only') NOT NULL DEFAULT 'open',
  `ping_status` enum('open','closed') NOT NULL DEFAULT 'open',
  `post_password` varchar(20) NOT NULL DEFAULT '',
  `post_name` varchar(200) NOT NULL DEFAULT '',
  `to_ping` text NOT NULL,
  `pinged` text NOT NULL,
  `post_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `post_modified_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `post_content_filtered` text NOT NULL,
  `post_parent` bigint(20) NOT NULL DEFAULT '0',
  `guid` varchar(255) NOT NULL DEFAULT '',
  `menu_order` int(11) NOT NULL DEFAULT '0',
  `post_type` varchar(20) NOT NULL DEFAULT 'post',
  `post_mime_type` varchar(100) NOT NULL DEFAULT '',
  `comment_count` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`),
  KEY `post_name` (`post_name`),
  KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sandertest_usermeta`
--

CREATE TABLE `sandertest_usermeta` (
  `umeta_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) NOT NULL DEFAULT '0',
  `meta_key` varchar(255) DEFAULT NULL,
  `meta_value` longtext,
  PRIMARY KEY (`umeta_id`),
  KEY `user_id` (`user_id`),
  KEY `meta_key` (`meta_key`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

--
-- Table structure for table `sandertest_users`
--

CREATE TABLE `sandertest_users` (
  `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_login` varchar(60) NOT NULL DEFAULT '',
  `user_pass` varchar(64) NOT NULL DEFAULT '',
  `user_nicename` varchar(50) NOT NULL DEFAULT '',
  `user_email` varchar(100) NOT NULL DEFAULT '',
  `user_url` varchar(100) NOT NULL DEFAULT '',
  `user_registered` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `user_activation_key` varchar(60) NOT NULL DEFAULT '',
  `user_status` int(11) NOT NULL DEFAULT '0',
  `display_name` varchar(250) NOT NULL DEFAULT '',
  PRIMARY KEY (`ID`),
  KEY `user_login_key` (`user_login`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Table structure for table `test`
--

CREATE TABLE `test` (
  `field` bigint(20) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `tt`
--

CREATE TABLE `tt` (
  `initials` char(2) DEFAULT NULL,
  `action` char(20) DEFAULT NULL,
  `ean` char(13) DEFAULT NULL,
  `exactid` int(11) DEFAULT NULL,
  `DT` datetime DEFAULT NULL,
  `oud` int(11) DEFAULT NULL,
  `nieuw` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping routines for database 'test'
--
/*!50003 DROP PROCEDURE IF EXISTS `herbereken_reserveringen_ean` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `herbereken_reserveringen_ean`( localEan CHAR(13) CHARACTER SET latin1 )
BEGIN
	DECLARE localReserveringen INT;
	IF localEan NOT IN ( 'PORTO', 'IDEAL', 'BONG', 'VOUCHER' ) THEN
		SELECT IFNULL( SUM( OpenAantal ), 0 ) INTO localReserveringen 
		   FROM open_orderregels
		   WHERE Ean = localEan AND niet_reserveren = 0;
		
		INSERT INTO Voorraadbeheer.`ReserveringenPerEan` SET Administratie = get_administratie(), Ean = localEan, Aantal = localReserveringen ON DUPLICATE KEY UPDATE Aantal = localReserveringen;
	END IF;
    END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `test_decl` */;
DELIMITER ;;
CREATE DEFINER=`thijs`@`%` PROCEDURE `test_decl`()
    READS SQL DATA
BEGIN
	
	DECLARE curEan CHAR( 13 ) CHARACTER SET LATIN1;
	
	select ean into curEan from Managementboek_Boeken.Boeken where ean = '9789052613109';
	
	select curEan;
	
    END ;;
DELIMITER ;

--
-- Current Database: `tmp`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `tmp` /*!40100 DEFAULT CHARACTER SET utf8 */;

USE `tmp`;

--
-- Table structure for table `AllesVerkocht`
--

CREATE TABLE `AllesVerkocht` (
  `Ean` varchar(13) DEFAULT NULL,
  `Aantal` bigint(21) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `BISAC`
--

CREATE TABLE `BISAC` (
  `_Value` varchar(255) DEFAULT NULL,
  `_Description` varchar(255) DEFAULT NULL,
  `rubriek` varchar(255) DEFAULT NULL,
  `rubriekman` varchar(255) DEFAULT NULL,
  `rubriekcom` varchar(255) DEFAULT NULL,
  `rubriekjur` varchar(255) DEFAULT NULL,
  `rubriekalg` varchar(255) DEFAULT NULL,
  `website` varchar(255) DEFAULT NULL,
  `NUR` double DEFAULT NULL,
  `extra_check` varchar(255) DEFAULT NULL,
  `plts` varchar(255) DEFAULT NULL,
  `level_0` varchar(255) DEFAULT NULL,
  `level_1` varchar(255) DEFAULT NULL,
  `level_2` varchar(255) DEFAULT NULL,
  `level_3` varchar(255) DEFAULT NULL,
  `level_4` varchar(255) DEFAULT NULL,
  `level_5` varchar(255) DEFAULT NULL,
  `level_6` varchar(255) DEFAULT NULL,
  `in_feed` varchar(255) DEFAULT NULL,
  `ranking` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `BMNK`
--

CREATE TABLE `BMNK` (
  `Id` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `BOOM2015`
--

CREATE TABLE `BOOM2015` (
  `Ean` char(13) NOT NULL,
  `ProductAvailability` tinyint(2) DEFAULT NULL,
  `Titel` varchar(255) NOT NULL DEFAULT '',
  `Imprint` varchar(255) DEFAULT NULL,
  `Bindwijze` varchar(50) NOT NULL,
  `Aantal` decimal(32,0) DEFAULT NULL,
  `Omzet` decimal(40,2) DEFAULT NULL,
  PRIMARY KEY (`Ean`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `BOOM2016`
--

CREATE TABLE `BOOM2016` (
  `Ean` char(13) NOT NULL,
  `ProductAvailability` tinyint(2) DEFAULT NULL,
  `Titel` varchar(255) NOT NULL DEFAULT '',
  `Imprint` varchar(255) DEFAULT NULL,
  `Bindwijze` varchar(50) NOT NULL,
  `Aantal` decimal(32,0) DEFAULT NULL,
  `Omzet` decimal(40,2) DEFAULT NULL,
  PRIMARY KEY (`Ean`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `BORegelsManagementboek_Klanten`
--

CREATE TABLE `BORegelsManagementboek_Klanten` (
  `Id` int(11) NOT NULL,
  `BestellingId` int(11) DEFAULT NULL,
  `DT` datetime DEFAULT NULL,
  `Ean` char(13) DEFAULT NULL,
  `BoekStatus` int(11) DEFAULT NULL,
  `Aantal` int(11) DEFAULT NULL,
  `AantalBackorder` int(11) DEFAULT NULL,
  `Geleverd` int(11) DEFAULT NULL,
  `Gereserveerd` int(11) DEFAULT NULL,
  `Leverbaar` int(11) DEFAULT NULL,
  `DeelLeverbaar` int(11) DEFAULT NULL,
  `Wacht` int(11) DEFAULT NULL,
  `VerstuurCompleteOrder` int(11) DEFAULT NULL,
  `BeschikbareVoorraad` int(11) DEFAULT NULL,
  `GereserveerdeVoorraad` int(11) DEFAULT NULL,
  `FysiekeVoorraad` int(11) DEFAULT NULL,
  `GeprinteVoorraad` int(11) DEFAULT NULL,
  `NogNietGeprint` int(11) DEFAULT NULL,
  `Bindwijze_voorraadartikel` int(11) DEFAULT NULL,
  `Bindwijze_evenement` int(11) DEFAULT NULL,
  `Voorafgaand` int(11) DEFAULT NULL,
  `GenoegVoorraad` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `BestellingId` (`BestellingId`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1;

--
-- Table structure for table `BackupAbonnementen`
--

CREATE TABLE `BackupAbonnementen` (
  `ID` int(11) NOT NULL,
  `EAN` char(13) NOT NULL,
  `AboPrijs` decimal(10,2) NOT NULL DEFAULT '0.00',
  `AboPrijsGoedgekeurd` tinyint(4) NOT NULL DEFAULT '0',
  `MarkupPercentage` decimal(10,2) NOT NULL DEFAULT '0.00',
  `MarkupBedrag` decimal(10,2) NOT NULL DEFAULT '0.00',
  `KlantID` int(11) NOT NULL,
  `Korting` decimal(5,2) unsigned NOT NULL DEFAULT '0.00',
  `DTBesteld` date DEFAULT NULL,
  `DTBesteldBevestigd` date DEFAULT NULL,
  `DTBesteldGereclameerd` date DEFAULT NULL,
  `DTIngang` date DEFAULT NULL,
  `DTEind` date DEFAULT NULL,
  `DTOpzegging` datetime DEFAULT NULL,
  `DTOpzeggingBevestigd` datetime DEFAULT NULL,
  `DTOpzeggingReminder` datetime DEFAULT NULL,
  `DTVerlengen` date DEFAULT NULL,
  `DTVerlengd` datetime DEFAULT NULL,
  `DTAdreswijziging` date DEFAULT NULL,
  `DTAdreswijzigingGemaild` date DEFAULT NULL,
  `DTAdreswijzigingBevestigd` date DEFAULT NULL,
  `DTAdreswijzigingGereclameerd` date DEFAULT NULL,
  `Referentie` varchar(255) DEFAULT NULL,
  `Kostenplaats` varchar(255) DEFAULT NULL,
  `FactuurKlantId` int(11) NOT NULL DEFAULT '0',
  `FactuurBedrijfsnaam` varchar(255) NOT NULL,
  `FactuurBedrijfsnaam2` varchar(255) NOT NULL,
  `FactuurAfdeling` varchar(255) NOT NULL,
  `FactuurGeslacht` varchar(5) NOT NULL,
  `FactuurInitialen` varchar(10) NOT NULL,
  `FactuurAchternaam` varchar(255) NOT NULL,
  `FactuurStraatnaam` varchar(255) NOT NULL,
  `FactuurHuisnummer` int(11) NOT NULL,
  `FactuurHuisnummerToevoeging` varchar(5) NOT NULL,
  `FactuurPostcode` varchar(7) NOT NULL,
  `FactuurPlaatsnaam` varchar(255) NOT NULL,
  `FactuurLand` varchar(50) NOT NULL,
  `AfwijkendVerzendAdres` tinyint(4) NOT NULL DEFAULT '0',
  `VerzendKlantId` int(11) NOT NULL DEFAULT '0',
  `VerzendBedrijfsnaam` varchar(255) NOT NULL,
  `VerzendBedrijfsnaam2` varchar(255) NOT NULL,
  `VerzendAfdeling` varchar(255) NOT NULL,
  `VerzendGeslacht` varchar(5) NOT NULL,
  `VerzendInitialen` varchar(10) NOT NULL,
  `VerzendAchternaam` varchar(255) NOT NULL,
  `VerzendStraatnaam` varchar(255) NOT NULL,
  `VerzendHuisnummer` int(11) NOT NULL,
  `VerzendHuisnummerToevoeging` varchar(5) NOT NULL,
  `VerzendPostcode` varchar(7) NOT NULL,
  `VerzendPlaatsnaam` varchar(255) NOT NULL,
  `VerzendLand` varchar(50) NOT NULL,
  `Emailadres` varchar(255) CHARACTER SET ascii DEFAULT NULL,
  `Circulatielijst` mediumtext,
  `Notities` mediumtext,
  `Website` varchar(255) NOT NULL,
  `UitgeversReferentie` varchar(255) DEFAULT NULL,
  `UitgeversKlantnummer` varchar(50) DEFAULT NULL,
  `AbonnementStatus` varchar(255) DEFAULT NULL,
  `PerDirectOpgezegd` tinyint(4) DEFAULT '0',
  `BesteldBijUitgever` tinyint(4) NOT NULL DEFAULT '0',
  `BevestigdDoorUitgever` tinyint(4) NOT NULL DEFAULT '0',
  `DTOpgezegdGemaild` date DEFAULT NULL,
  `DTOpgezegdBevestigd` date DEFAULT NULL,
  `DTOpgezegdGereclameerd` date DEFAULT NULL,
  `DTClaimGemaild` date DEFAULT NULL,
  `DTClaimBevestigd` date DEFAULT NULL,
  `DTClaimGereclameerd` date DEFAULT NULL,
  `DTVerlengingKlant` date DEFAULT NULL,
  `SiteId` int(11) DEFAULT '1005',
  `Abonneenummer_bij_uitgever` varchar(75) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `BackupPeriodieken`
--

CREATE TABLE `BackupPeriodieken` (
  `ID` int(11) NOT NULL,
  `EAN` char(13) NOT NULL,
  `AboPrijs` decimal(10,2) NOT NULL DEFAULT '0.00',
  `AboPrijsGoedgekeurd` tinyint(4) NOT NULL DEFAULT '0',
  `MarkupPercentage` decimal(10,2) NOT NULL DEFAULT '0.00',
  `MarkupBedrag` decimal(10,2) NOT NULL DEFAULT '0.00',
  `KlantID` int(11) NOT NULL,
  `Korting` decimal(5,2) unsigned NOT NULL DEFAULT '0.00',
  `DTBesteld` date DEFAULT NULL,
  `DTBesteldBevestigd` date DEFAULT NULL,
  `DTBesteldGereclameerd` date DEFAULT NULL,
  `DTIngang` date DEFAULT NULL,
  `DTEind` date DEFAULT NULL,
  `DTOpzegging` datetime DEFAULT NULL,
  `DTOpzeggingBevestigd` datetime DEFAULT NULL,
  `DTOpzeggingReminder` datetime DEFAULT NULL,
  `DTVerlengen` date DEFAULT NULL,
  `DTVerlengd` datetime DEFAULT NULL,
  `DTAdreswijziging` date DEFAULT NULL,
  `DTAdreswijzigingGemaild` date DEFAULT NULL,
  `DTAdreswijzigingBevestigd` date DEFAULT NULL,
  `DTAdreswijzigingGereclameerd` date DEFAULT NULL,
  `Referentie` varchar(255) DEFAULT NULL,
  `Kostenplaats` varchar(255) DEFAULT NULL,
  `FactuurKlantId` int(11) NOT NULL DEFAULT '0',
  `FactuurBedrijfsnaam` varchar(255) NOT NULL,
  `FactuurBedrijfsnaam2` varchar(255) NOT NULL,
  `FactuurAfdeling` varchar(255) NOT NULL,
  `FactuurGeslacht` varchar(5) NOT NULL,
  `FactuurInitialen` varchar(10) NOT NULL,
  `FactuurAchternaam` varchar(255) NOT NULL,
  `FactuurStraatnaam` varchar(255) NOT NULL,
  `FactuurHuisnummer` int(11) NOT NULL,
  `FactuurHuisnummerToevoeging` varchar(5) NOT NULL,
  `FactuurPostcode` varchar(7) NOT NULL,
  `FactuurPlaatsnaam` varchar(255) NOT NULL,
  `FactuurLand` varchar(50) NOT NULL,
  `AfwijkendVerzendAdres` tinyint(4) NOT NULL DEFAULT '0',
  `VerzendKlantId` int(11) NOT NULL DEFAULT '0',
  `VerzendBedrijfsnaam` varchar(255) NOT NULL,
  `VerzendBedrijfsnaam2` varchar(255) NOT NULL,
  `VerzendAfdeling` varchar(255) NOT NULL,
  `VerzendGeslacht` varchar(5) NOT NULL,
  `VerzendInitialen` varchar(10) NOT NULL,
  `VerzendAchternaam` varchar(255) NOT NULL,
  `VerzendStraatnaam` varchar(255) NOT NULL,
  `VerzendHuisnummer` int(11) NOT NULL,
  `VerzendHuisnummerToevoeging` varchar(5) NOT NULL,
  `VerzendPostcode` varchar(7) NOT NULL,
  `VerzendPlaatsnaam` varchar(255) NOT NULL,
  `VerzendLand` varchar(50) NOT NULL,
  `Emailadres` varchar(255) CHARACTER SET ascii DEFAULT NULL,
  `Circulatielijst` mediumtext,
  `Notities` mediumtext,
  `Website` varchar(255) NOT NULL,
  `UitgeversReferentie` varchar(255) DEFAULT NULL,
  `UitgeversKlantnummer` varchar(50) DEFAULT NULL,
  `AbonnementStatus` varchar(255) DEFAULT NULL,
  `PerDirectOpgezegd` tinyint(4) DEFAULT '0',
  `BesteldBijUitgever` tinyint(4) NOT NULL DEFAULT '0',
  `BevestigdDoorUitgever` tinyint(4) NOT NULL DEFAULT '0',
  `DTOpgezegdGemaild` date DEFAULT NULL,
  `DTOpgezegdBevestigd` date DEFAULT NULL,
  `DTOpgezegdGereclameerd` date DEFAULT NULL,
  `DTClaimGemaild` date DEFAULT NULL,
  `DTClaimBevestigd` date DEFAULT NULL,
  `DTClaimGereclameerd` date DEFAULT NULL,
  `SiteId` int(11) DEFAULT '1005'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `Bestellingen`
--

CREATE TABLE `Bestellingen` (
  `CbBestellingId` int(11) NOT NULL AUTO_INCREMENT,
  `DTBestelling` datetime NOT NULL,
  `DTGeplaatst` datetime DEFAULT NULL,
  `DTAfgehandeld` datetime NOT NULL,
  `IsGeplaatst` tinyint(4) NOT NULL,
  `IsAfgehandeld` tinyint(4) NOT NULL DEFAULT '0',
  `IsGeannuleerd` tinyint(4) NOT NULL DEFAULT '0',
  `DB` enum('Managementboek','Computerboek','CB') NOT NULL,
  `Leveringswijze` enum('DIO','DUD','E-mail','Overig') NOT NULL,
  `EmailAdres` varchar(255) DEFAULT NULL,
  `Email` mediumtext,
  `UitgeverNaam` varchar(255) DEFAULT NULL,
  `UitgeverId` int(11) DEFAULT NULL,
  `VoorNCOI` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`CbBestellingId`)
) ENGINE=InnoDB AUTO_INCREMENT=14039 DEFAULT CHARSET=latin1;

--
-- Table structure for table `Bobbe`
--

CREATE TABLE `Bobbe` (
  `boekstatus` int(11) DEFAULT NULL,
  `EAN` char(13) DEFAULT NULL,
  `artikelcode_uitgever` varchar(255) DEFAULT NULL,
  `titel` varchar(255) DEFAULT NULL,
  `looptijd` double DEFAULT NULL,
  `online_toegang` double DEFAULT NULL,
  `subtitel` varchar(255) DEFAULT NULL,
  `uitgever` varchar(255) DEFAULT NULL,
  `Rubriek` varchar(255) DEFAULT NULL,
  `verleng_abo_per` varchar(255) DEFAULT NULL,
  `Opzegtermijn` double DEFAULT NULL,
  `Min looptijd` double DEFAULT NULL,
  `prijs` decimal(7,2) DEFAULT NULL,
  `valuta` varchar(255) DEFAULT NULL,
  `Periodiek_issn` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `Bobbe2`
--

CREATE TABLE `Bobbe2` (
  `boekstatus` double DEFAULT NULL,
  `EAN` double DEFAULT NULL,
  `artikelcode_uitgever` varchar(255) DEFAULT NULL,
  `titel` varchar(255) DEFAULT NULL,
  `looptijd` double DEFAULT NULL,
  `bindwijze` varchar(255) DEFAULT NULL,
  `online_toegang` double DEFAULT NULL,
  `subtitel` varchar(255) DEFAULT NULL,
  `uitgever` varchar(255) DEFAULT NULL,
  `Rubriek` varchar(255) DEFAULT NULL,
  `verleng_abo_per` varchar(255) DEFAULT NULL,
  `Opzegtermijn` double DEFAULT NULL,
  `Min looptijd` double DEFAULT NULL,
  `prijs` double DEFAULT NULL,
  `valuta` varchar(255) DEFAULT NULL,
  `Periodiek_issn` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `BobbeAbos`
--

CREATE TABLE `BobbeAbos` (
  `volgnr` int(11) NOT NULL AUTO_INCREMENT,
  `sub_nr` varchar(255) DEFAULT NULL,
  `acct_name` varchar(255) DEFAULT NULL,
  `st_prop` varchar(255) DEFAULT NULL,
  `sbs_nr` varchar(255) DEFAULT NULL,
  `art_code` varchar(255) DEFAULT NULL,
  `adm_kst` varchar(255) DEFAULT NULL,
  `bezorg` varchar(255) DEFAULT NULL,
  `middag_bezorg` varchar(255) DEFAULT NULL,
  `art_desc1` varchar(255) DEFAULT NULL,
  `date_start` timestamp(6) NULL DEFAULT NULL,
  `b1_opmfac` timestamp(6) NULL DEFAULT NULL,
  `b1_klref` varchar(255) DEFAULT NULL,
  `comment2` varchar(255) DEFAULT NULL,
  `b1_adres` varchar(255) DEFAULT NULL,
  `b1_opmfac2` varchar(255) DEFAULT NULL,
  `cost_code` varchar(255) DEFAULT NULL,
  `date_end` timestamp(6) NULL DEFAULT NULL,
  `b1_gebr` varchar(255) DEFAULT NULL,
  `b1_ww` varchar(255) DEFAULT NULL,
  `b1_email` varchar(255) DEFAULT NULL,
  `b1_txt1` varchar(255) DEFAULT NULL,
  `b1_txt17` varchar(255) DEFAULT NULL,
  `b1_txt2` varchar(255) DEFAULT NULL,
  `b1_txt3` varchar(255) DEFAULT NULL,
  `b1_txt4` varchar(255) DEFAULT NULL,
  `b1_txt5` varchar(255) DEFAULT NULL,
  `b1_txt6` varchar(255) DEFAULT NULL,
  `b1_txt7` varchar(255) DEFAULT NULL,
  `b1_txt8` varchar(255) DEFAULT NULL,
  `b1_txt9` varchar(255) DEFAULT NULL,
  `b1_txt10` varchar(255) DEFAULT NULL,
  `b1_txt11` varchar(255) DEFAULT NULL,
  `b1_txt12` varchar(255) DEFAULT NULL,
  `b1_txt13` varchar(255) DEFAULT NULL,
  `b1_txt14` varchar(255) DEFAULT NULL,
  `b1_txt15` varchar(255) DEFAULT NULL,
  `b1_txt16` varchar(255) DEFAULT NULL,
  `b1_report` varchar(255) DEFAULT NULL,
  `cost_code9` varchar(255) DEFAULT NULL,
  `Klantid` int(11) DEFAULT NULL,
  `Gedaan` tinyint(1) NOT NULL DEFAULT '0',
  `AboID` int(11) DEFAULT NULL,
  PRIMARY KEY (`volgnr`)
) ENGINE=InnoDB AUTO_INCREMENT=503 DEFAULT CHARSET=utf8;

--
-- Table structure for table `BoekenExtra`
--

CREATE TABLE `BoekenExtra` (
  `Ean` char(13) NOT NULL DEFAULT '',
  `Extra` varchar(16) CHARACTER SET utf8 NOT NULL DEFAULT '',
  KEY `NewIndex1` (`Ean`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `BoekenNaarRamsj`
--

CREATE TABLE `BoekenNaarRamsj` (
  `Ean` char(13) CHARACTER SET latin1 NOT NULL,
  `Bindwijze` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
  `Achternaam` varchar(150) NOT NULL DEFAULT '',
  `Titel` varchar(255) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `NMB` smallint(6) DEFAULT NULL,
  `Invoer` varchar(10) DEFAULT NULL,
  `LaatstBesteld` varchar(10) DEFAULT NULL,
  `Voorr` int(11) NOT NULL DEFAULT '0',
  `Prijs` double(19,2) DEFAULT NULL,
  `Korting` decimal(10,0) DEFAULT NULL,
  `Aanbeveling` double(19,2) DEFAULT NULL,
  `Taalvermelding` varchar(10) CHARACTER SET latin1 DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `BoekenPerJaar`
--

CREATE TABLE `BoekenPerJaar` (
  `Jaar` int(4) DEFAULT NULL,
  `Ean` varchar(13) CHARACTER SET latin1 DEFAULT NULL,
  `Aantal` decimal(33,0) DEFAULT NULL,
  KEY `Ean` (`Ean`,`Jaar`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `Boekgekoppeldean`
--

CREATE TABLE `Boekgekoppeldean` (
  `Ean` char(13) NOT NULL,
  `Eangekoppeld` char(13) NOT NULL,
  PRIMARY KEY (`Ean`,`Eangekoppeld`),
  KEY `i1` (`Ean`),
  KEY `i2` (`Eangekoppeld`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `CID_porto`
--

CREATE TABLE `CID_porto` (
  `CID` bigint(20) DEFAULT NULL,
  `KlantID` int(11) DEFAULT NULL,
  `Porto` decimal(10,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `CPBAantallen`
--

CREATE TABLE `CPBAantallen` (
  `Ean` char(13) NOT NULL DEFAULT '',
  `Aantal` int(11) DEFAULT NULL,
  PRIMARY KEY (`Ean`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ClearUpdates`
--

CREATE TABLE `ClearUpdates` (
  `Variable` char(20) NOT NULL,
  `Date` datetime DEFAULT NULL,
  PRIMARY KEY (`Variable`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC;

--
-- Table structure for table `DennisIsGek`
--

CREATE TABLE `DennisIsGek` (
  `UitgeverID` double DEFAULT NULL,
  `Naamuitgever` varchar(255) DEFAULT NULL,
  `Omschrijving` text,
  `Kortingmp_a` double DEFAULT NULL,
  `Kortingmp_s` double DEFAULT NULL,
  `Kortingmp_w` double DEFAULT NULL,
  `Kortingmp_o` double DEFAULT NULL,
  `Kortingmp_g` double DEFAULT NULL,
  `F9` varchar(255) DEFAULT NULL,
  `F10` varchar(255) DEFAULT NULL,
  `F11` varchar(255) DEFAULT NULL,
  `F12` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `FeedBestelpunt`
--

CREATE TABLE `FeedBestelpunt` (
  `Ean` char(13) NOT NULL,
  `BestelpuntId` int(11) DEFAULT NULL,
  `KortingMP` decimal(8,2) DEFAULT NULL,
  `kortingscode` char(10) CHARACTER SET latin1 DEFAULT '',
  PRIMARY KEY (`Ean`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `FeedPrijzenExBtwNul`
--

CREATE TABLE `FeedPrijzenExBtwNul` (
  `PrijsId` int(11) NOT NULL DEFAULT '0',
  `FeedCode` char(8) NOT NULL,
  `Ean` char(13) NOT NULL,
  `IsAanbieding` tinyint(1) DEFAULT '0',
  `Prijs` decimal(8,2) DEFAULT '0.00',
  `PrijsExBtw` decimal(8,2) DEFAULT '0.00',
  `PrijsExBtw2` decimal(8,2) DEFAULT '0.00',
  `stock` int(11) DEFAULT '0',
  `inkoopkorting` decimal(8,2) DEFAULT '0.00',
  `Valuta` varchar(4) DEFAULT 'EUR',
  `BtwTarief` tinyint(2) DEFAULT NULL,
  `BtwTarief2` tinyint(2) DEFAULT NULL,
  `PrijsVanaf` date DEFAULT NULL,
  `PrijsTot` date DEFAULT NULL,
  `Laatstgewijzigd` datetime DEFAULT NULL COMMENT 'datum in .onx',
  `kortingscode` char(10) CHARACTER SET latin1 DEFAULT NULL,
  `kortingpercentage` decimal(8,0) DEFAULT NULL,
  `TIMESTAMP` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `GeprinteVoorraadRun`
--

CREATE TABLE `GeprinteVoorraadRun` (
  `DT` datetime DEFAULT NULL,
  `CI` char(3) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `JB_Vervangt`
--

CREATE TABLE `JB_Vervangt` (
  `nieuw` char(13) NOT NULL,
  `oud` char(13) NOT NULL,
  PRIMARY KEY (`nieuw`,`oud`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `Jaren`
--

CREATE TABLE `Jaren` (
  `Jaar` int(11) DEFAULT NULL,
  KEY `Jaar` (`Jaar`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `Jongbloed_Facturen`
--

CREATE TABLE `Jongbloed_Facturen` (
  `ID` double DEFAULT NULL,
  `Factuurrelatie id` double DEFAULT NULL,
  `Factuurrelatie naam` varchar(255) DEFAULT NULL,
  `Afleverrelatie id` double DEFAULT NULL,
  `Selectiecode` double DEFAULT NULL,
  `Afleverrelatie naam` varchar(255) DEFAULT NULL,
  `Afleveradres` varchar(255) DEFAULT NULL,
  `Factuurdatum` timestamp(6) NULL DEFAULT NULL,
  `Valuta omschrijving` varchar(255) DEFAULT NULL,
  `Status` varchar(255) DEFAULT NULL,
  `Administratie omschrijving` varchar(255) DEFAULT NULL,
  `Factuurperiode eenheid` varchar(255) DEFAULT NULL,
  `Afleverplaats` varchar(255) DEFAULT NULL,
  `F14` varchar(255) DEFAULT NULL,
  `Totaal` double DEFAULT NULL,
  `F16` varchar(255) DEFAULT NULL,
  `F17` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `Jongbloed_Relations`
--

CREATE TABLE `Jongbloed_Relations` (
  `ID` bigint(255) DEFAULT NULL,
  `Naam` varchar(255) DEFAULT NULL,
  `Additional address information 1` varchar(255) DEFAULT NULL,
  `Additional address information 2` varchar(255) DEFAULT NULL,
  `Naam 2` varchar(255) DEFAULT NULL,
  `Street` varchar(255) DEFAULT NULL,
  `House number` varchar(255) DEFAULT NULL,
  `City` varchar(255) DEFAULT NULL,
  `Postal code` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `KlantenMetAanbevelingen`
--

CREATE TABLE `KlantenMetAanbevelingen` (
  `Klantid` int(11) NOT NULL DEFAULT '0',
  `HeeftAanbevelingen` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Klantid`,`HeeftAanbevelingen`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `Kortingen`
--

CREATE TABLE `Kortingen` (
  `Id` int(11) NOT NULL DEFAULT '0',
  `KortingMP` int(11) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `LaatstVerkocht`
--

CREATE TABLE `LaatstVerkocht` (
  `Ean` char(13) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `DT` date DEFAULT NULL,
  PRIMARY KEY (`Ean`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `LockLogging`
--

CREATE TABLE `LockLogging` (
  `Requesting_transaction` varchar(18) NOT NULL,
  `Requesting_thread_id` bigint(4) NOT NULL,
  `Requesting_Query` text NOT NULL,
  `Wants_Lock` varchar(1024) NOT NULL,
  `Wants_Data` varchar(8192) DEFAULT NULL,
  `Wants_Mode` varchar(32) NOT NULL,
  `Blocking_Transaction` varchar(18) NOT NULL,
  `Blocking_thread_id` bigint(4) NOT NULL,
  `Blocking_Query` text NOT NULL,
  `Uses_Lock` varchar(1024) NOT NULL,
  `Uses_Data` varchar(8192) DEFAULT NULL,
  `Uses_Mode` varchar(32) NOT NULL,
  `Lock_Time` time DEFAULT NULL,
  `DT` datetime(3) DEFAULT NULL,
  PRIMARY KEY (`Requesting_transaction`,`Requesting_thread_id`,`Blocking_Transaction`,`Blocking_thread_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `MCBestellend`
--

CREATE TABLE `MCBestellend` (
  `Klantid` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `MCOud`
--

CREATE TABLE `MCOud` (
  `Klantid` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `MCOudMem`
--

CREATE TABLE `MCOudMem` (
  `Klantid` int(11) NOT NULL,
  PRIMARY KEY (`Klantid`)
) ENGINE=MEMORY DEFAULT CHARSET=utf8;

--
-- Table structure for table `MCSegment`
--

CREATE TABLE `MCSegment` (
  `Klantid` int(11) NOT NULL,
  PRIMARY KEY (`Klantid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `Managementboek_Klanten_Zonder_Optin`
--

CREATE TABLE `Managementboek_Klanten_Zonder_Optin` (
  `Klantid` int(11) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `ManpoBestelpunt`
--

CREATE TABLE `ManpoBestelpunt` (
  `Ean` char(13) NOT NULL,
  `Boekstatus` smallint(6) NOT NULL DEFAULT '0',
  `BestelpuntId` int(11) DEFAULT NULL,
  `KortingMP` double DEFAULT NULL,
  PRIMARY KEY (`Ean`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `ManpoVelden2016`
--

CREATE TABLE `ManpoVelden2016` (
  `EAN` char(13) NOT NULL,
  `Veldnaam` char(40) NOT NULL,
  `Feed` enum('CB') CHARACTER SET ascii NOT NULL DEFAULT 'CB',
  `DT` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `Manpo_Boekranking_Historie`
--

CREATE TABLE `Manpo_Boekranking_Historie` (
  `EAN` char(13) NOT NULL,
  `Website` enum('Managementboek','Computerboek','Juridischboek','Overig') NOT NULL,
  `Datum` date NOT NULL,
  `Ranking` int(10) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `MatchendeFacturen`
--

CREATE TABLE `MatchendeFacturen` (
  `Bestellingid` int(11) NOT NULL DEFAULT '0',
  `FactuurID` int(11) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `NCOIAantallen`
--

CREATE TABLE `NCOIAantallen` (
  `Ean` char(13) NOT NULL,
  `Aantal` int(11) DEFAULT NULL,
  PRIMARY KEY (`Ean`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `NCOIVoorraad`
--

CREATE TABLE `NCOIVoorraad` (
  `EAN` char(13) NOT NULL,
  `ExactID` int(11) NOT NULL,
  `Kostenplaats` int(11) NOT NULL,
  `Voorraad` int(11) NOT NULL,
  `Forecast` int(11) NOT NULL,
  `Afgesloten` enum('Neen','Ja') NOT NULL DEFAULT 'Neen',
  `LaatzienVanaf` timestamp NOT NULL DEFAULT '2008-07-31 22:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `OrderschermContext`
--

CREATE TABLE `OrderschermContext` (
  `ConnectionId` int(11) NOT NULL,
  `Context` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`ConnectionId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `OrderschermLog`
--

CREATE TABLE `OrderschermLog` (
  `DT` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
  `ConnectionId` int(11) DEFAULT NULL,
  `BlockingId` int(11) DEFAULT NULL,
  `OrderId` int(11) DEFAULT NULL,
  `Duration` decimal(5,2) DEFAULT '0.00',
  `Msg` varchar(255) DEFAULT NULL,
  `Context` varchar(255) DEFAULT NULL,
  KEY `DT` (`DT`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `OrderschermVoorraadBijLeveringLog`
--

CREATE TABLE `OrderschermVoorraadBijLeveringLog` (
  `Id` int(11) NOT NULL,
  `BestellingId` int(11) NOT NULL,
  `OrigineelBestellingId` int(11) NOT NULL,
  `DT` datetime DEFAULT NULL,
  `Ean` char(13) CHARACTER SET latin1 DEFAULT NULL,
  `BoekStatus` tinyint(4) NOT NULL DEFAULT '0',
  `Aantal` int(11) NOT NULL DEFAULT '0',
  `AantalBackorder` int(11) NOT NULL DEFAULT '0',
  `Geleverd` int(11) NOT NULL DEFAULT '0',
  `Gereserveerd` int(11) NOT NULL DEFAULT '0',
  `Leverbaar` tinyint(4) NOT NULL DEFAULT '0',
  `DeelLeverbaar` tinyint(4) NOT NULL DEFAULT '0',
  `Splitsbaar` tinyint(4) NOT NULL DEFAULT '0',
  `Wacht` tinyint(4) NOT NULL DEFAULT '0',
  `VerstuurCompleteOrder` tinyint(4) NOT NULL DEFAULT '0',
  `BeschikbareVoorraad` int(11) NOT NULL DEFAULT '0',
  `GereserveerdeVoorraad` int(11) NOT NULL DEFAULT '0',
  `FysiekeVoorraad` int(11) NOT NULL DEFAULT '0',
  `GeprinteVoorraad` int(11) NOT NULL DEFAULT '0',
  `NogNietGeprint` int(11) NOT NULL DEFAULT '0',
  `Bindwijze_voorraadartikel` tinyint(4) NOT NULL DEFAULT '0',
  `Bindwijze_evenement` tinyint(4) NOT NULL DEFAULT '0',
  `Voorafgaand` int(11) NOT NULL DEFAULT '0',
  `GenoegVoorraad` tinyint(4) NOT NULL DEFAULT '0',
  `CB24Leverbaar` int(11) NOT NULL DEFAULT '0',
  `CBLeverbaar` tinyint(4) NOT NULL DEFAULT '0',
  `FeedLeverbaar` tinyint(4) NOT NULL DEFAULT '0',
  `Bakje` char(15) NOT NULL DEFAULT 'nieuw',
  `BakjeReden` char(100) DEFAULT NULL,
  `Bron` char(10) NOT NULL DEFAULT 'onbekend',
  `NietReserveren` tinyint(4) DEFAULT '0',
  `Magazijn` tinyint(4) DEFAULT '0',
  `MagONE` tinyint(4) DEFAULT '0',
  `AantalOnderweg` int(11) DEFAULT '0',
  `OnderwegSinds` datetime DEFAULT NULL,
  `Risico_Geaccepteerd` tinyint(4) DEFAULT '0',
  `Adres_Geaccepteerd` tinyint(4) DEFAULT '0',
  `LeverenMB` int(11) DEFAULT '0',
  `LeverenCB` int(11) DEFAULT '0',
  `LeverenNiet` int(11) DEFAULT '0',
  `LeverenPad` char(40) DEFAULT NULL,
  `PromoBoek` mediumint(4) NOT NULL DEFAULT '0',
  `PromoReden` tinyint(4) NOT NULL DEFAULT '0',
  `DTVerwacht` date DEFAULT NULL,
  `bakje_proto_magazijn` tinyint(1) NOT NULL DEFAULT '0',
  `bakje_vink_open` tinyint(1) NOT NULL DEFAULT '0',
  `Gewist` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `P_GeprintAantal` int(11) NOT NULL DEFAULT '0',
  `P_NogNietGeprint` int(11) NOT NULL DEFAULT '0',
  `VB_Fysiek` int(11) NOT NULL DEFAULT '0',
  `VB_Gereserveerd` int(11) NOT NULL DEFAULT '0',
  `DTLog` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `ReeksVanKees`
--

CREATE TABLE `ReeksVanKees` (
  `FactuurId` int(11) NOT NULL,
  PRIMARY KEY (`FactuurId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `SanderTestMagWeg`
--

CREATE TABLE `SanderTestMagWeg` (
  `FeedCode` char(8) NOT NULL COMMENT 'Feed code. BV ''wiley''',
  `Ean` char(13) NOT NULL COMMENT 'EAN',
  `NaamUitgever` varchar(50) DEFAULT NULL COMMENT 'Tekstuele naam uitgever',
  `Imprint` varchar(50) DEFAULT NULL,
  `CommercieleImprint` varchar(50) DEFAULT NULL,
  `UitgeverFeedId` int(11) DEFAULT NULL COMMENT 'Feed-specifieke ID uitgever',
  `Enanderen` smallint(6) NOT NULL DEFAULT '0' COMMENT 'Als er '', e.a.'' getoond moet worden',
  `Titel` varchar(255) NOT NULL DEFAULT '' COMMENT 'Titel van product',
  `Ondertitel` varchar(255) DEFAULT NULL COMMENT 'Ondertitel van product',
  `Naamserie` varchar(255) DEFAULT NULL COMMENT 'Naam van de serie. BV ''Voor Dummies''',
  `Titelserie` varchar(255) DEFAULT NULL COMMENT 'Titel in de serie. BV ''Deel 8''',
  `Reeksnummer` int(11) DEFAULT NULL COMMENT 'Reeksnummer in de serie, BV 8',
  `ReeksnummerTxt` char(10) DEFAULT NULL,
  `Editie` varchar(100) DEFAULT NULL COMMENT '1e druk, etc.',
  `Editieversie` varchar(100) DEFAULT NULL,
  `Bindwijze` varchar(50) NOT NULL DEFAULT 'paperback' COMMENT 'Een door ons goedgekeurde bindwijze',
  `onixbindwijze` char(2) NOT NULL DEFAULT '',
  `InclusiefProdukt` varchar(50) NOT NULL,
  `Aantalblz` smallint(6) DEFAULT NULL,
  `Abstract` text,
  `Samenvatting` text,
  `Inhoudsopgave` text,
  `Aanmaakdatum` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Laatstgewijzigd` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Taalvermelding` varchar(2) DEFAULT NULL,
  `Hoogte` double DEFAULT NULL,
  `Breedte` double DEFAULT NULL,
  `Dikte` double DEFAULT NULL,
  `Gewicht` double DEFAULT NULL,
  `Verschijningsdatum` date DEFAULT '0000-00-00',
  `Herdrukdatum` date DEFAULT NULL,
  `VerwachteVerschijningsdatum` date DEFAULT '0000-00-00',
  `Uitverkochtdatum` date DEFAULT '0000-00-00',
  `CBstatus` varchar(50) DEFAULT NULL,
  `Boekstatus` smallint(6) NOT NULL DEFAULT '1' COMMENT 'Mainpress boekstatus',
  `PublishingStatus` tinyint(2) DEFAULT '0' COMMENT 'Zie ONIX',
  `ProductAvailability` char(2) DEFAULT NULL COMMENT 'Zie ONIX',
  `PublishingStatusTxt` char(25) DEFAULT NULL,
  `ProductAvailabilityTxt` varchar(50) DEFAULT NULL,
  `Vervangt` char(13) DEFAULT NULL,
  `Vervangen_door` char(13) DEFAULT NULL,
  `Levertijd` tinyint(2) DEFAULT NULL,
  `Fysiek_boek` char(13) NOT NULL COMMENT 'Indien ebook, ean van fysiek boek',
  `ebook` char(13) NOT NULL,
  `eanebook` char(13) NOT NULL,
  `InkoopKorting` tinyint(4) NOT NULL COMMENT 'De korting die wij krijgen. 0 indien niet bekend.',
  `CoverURL` varchar(255) DEFAULT NULL,
  `BackcoverURL` varchar(255) DEFAULT NULL,
  `PDFURL` varchar(255) DEFAULT NULL,
  `BestandLaatsteWijziging` varchar(255) DEFAULT NULL COMMENT 'Bestandsnaam van bestand dat laatste wijziging bevat',
  `InAssortiment` tinyint(1) DEFAULT NULL COMMENT '1 Als het getoond word op de website(s)',
  `BestandsGrootte` varchar(50) DEFAULT NULL,
  `TIMESTAMP` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`FeedCode`,`Ean`),
  UNIQUE KEY `i1` (`Ean`,`InAssortiment`),
  KEY `i2` (`NaamUitgever`),
  KEY `i15` (`Naamserie`),
  KEY `i16` (`Titelserie`),
  KEY `Laatstgewijzigd` (`Laatstgewijzigd`),
  KEY `Publicatiestatus_code` (`ProductAvailability`,`PublishingStatus`,`Taalvermelding`,`Bindwijze`),
  KEY `Uitgever_cbid` (`UitgeverFeedId`),
  KEY `CBstatus_code` (`PublishingStatus`,`ProductAvailability`),
  KEY `Producten_ibfk_2` (`FeedCode`,`UitgeverFeedId`),
  KEY `InAssortiment` (`InAssortiment`),
  KEY `Bindwijze` (`Bindwijze`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED;

--
-- Table structure for table `Test`
--

CREATE TABLE `Test` (
  `Ean` char(13) NOT NULL,
  `7d` int(10) NOT NULL DEFAULT '0',
  `30d` int(10) NOT NULL DEFAULT '0',
  `60d` int(10) NOT NULL DEFAULT '0',
  `90d` int(10) NOT NULL DEFAULT '0',
  `year` int(10) NOT NULL DEFAULT '0',
  `lastyear` int(10) NOT NULL DEFAULT '0',
  `ever` int(10) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `TotaalCounter`
--

CREATE TABLE `TotaalCounter` (
  `cnt` int(11) NOT NULL AUTO_INCREMENT,
  `entry` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`cnt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `VBM579`
--

CREATE TABLE `VBM579` (
  `klantid` double DEFAULT NULL,
  `verzamel` double DEFAULT NULL,
  `voorblad` double DEFAULT NULL,
  `siteID` double DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `bedrijfsnaam` varchar(255) DEFAULT NULL,
  `2e regel` varchar(255) DEFAULT NULL,
  `adres` varchar(255) DEFAULT NULL,
  `huisnummer` double DEFAULT NULL,
  `postcode` varchar(255) DEFAULT NULL,
  `woonplaats` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `Valutas`
--

CREATE TABLE `Valutas` (
  `Soort` varchar(4) NOT NULL DEFAULT '',
  `Omschrijving` varchar(100) NOT NULL DEFAULT '',
  `Formuleconstante` double NOT NULL DEFAULT '0',
  `Formulevariabele` double NOT NULL DEFAULT '0',
  KEY `Soort` (`Soort`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `VerkopenPerJaar`
--

CREATE TABLE `VerkopenPerJaar` (
  `Ean` char(13) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `Jaar` int(11) NOT NULL DEFAULT '0',
  `Aantal` int(11) DEFAULT NULL,
  PRIMARY KEY (`Ean`,`Jaar`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `VoorafgaandComputerboek_Klanten`
--

CREATE TABLE `VoorafgaandComputerboek_Klanten` (
  `Id` int(11) NOT NULL,
  `Voorafgaand` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=MEMORY DEFAULT CHARSET=utf8;

--
-- Table structure for table `VoorafgaandJuridischboek_Klanten`
--

CREATE TABLE `VoorafgaandJuridischboek_Klanten` (
  `Id` int(11) NOT NULL,
  `Voorafgaand` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=MEMORY DEFAULT CHARSET=utf8;

--
-- Table structure for table `VoorafgaandManagementboek_Klanten`
--

CREATE TABLE `VoorafgaandManagementboek_Klanten` (
  `Id` int(11) NOT NULL,
  `Voorafgaand` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1;

--
-- Table structure for table `VoorraadMutaties`
--

CREATE TABLE `VoorraadMutaties` (
  `Ean` char(13) NOT NULL,
  `DTMutatie` datetime NOT NULL,
  `Mutatie` int(11) NOT NULL,
  PRIMARY KEY (`Ean`,`DTMutatie`),
  KEY `DTMutatie` (`DTMutatie`),
  CONSTRAINT `VoorraadMutaties_ibfk_1` FOREIGN KEY (`Ean`) REFERENCES `Voorraad` (`Ean`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 DELAY_KEY_WRITE=1 ROW_FORMAT=COMPRESSED;

--
-- Table structure for table `WelkomstActieKlanten1302`
--

CREATE TABLE `WelkomstActieKlanten1302` (
  `Klantid` int(11) NOT NULL,
  `Actieid` int(11) NOT NULL,
  `DT` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `WelkomstActieKlanten1502`
--

CREATE TABLE `WelkomstActieKlanten1502` (
  `Klantid` int(11) NOT NULL,
  `Actieid` int(11) NOT NULL,
  `DT` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `XY`
--

CREATE TABLE `XY` (
  `Id` int(11) NOT NULL,
  `aangemaakt` tinyint(4) NOT NULL DEFAULT '0',
  `bevestigd` tinyint(4) NOT NULL DEFAULT '0',
  `gefactureerd` tinyint(4) NOT NULL DEFAULT '0',
  `is_geparkeerd` tinyint(4) NOT NULL DEFAULT '0',
  `factuurnummer_toegewezen` tinyint(4) NOT NULL DEFAULT '0',
  `exact_export` tinyint(4) NOT NULL DEFAULT '0',
  `exact_controle` tinyint(4) NOT NULL DEFAULT '0',
  `exact_factuur_verwerkt` tinyint(4) NOT NULL DEFAULT '0',
  `etiket_geprint` tinyint(4) NOT NULL DEFAULT '0',
  `ingepakt` tinyint(4) NOT NULL DEFAULT '0',
  `geannuleerd` tinyint(4) NOT NULL DEFAULT '0',
  `factuur_geprint` tinyint(4) NOT NULL DEFAULT '0',
  `pakketlabel_geprint` tinyint(4) NOT NULL DEFAULT '0',
  `brieflabel_geprint` tinyint(4) NOT NULL DEFAULT '0',
  `betaald_via_ideal` tinyint(4) NOT NULL DEFAULT '0',
  `betaald` tinyint(4) NOT NULL DEFAULT '0',
  `openstaande_post_aangemaakt` tinyint(4) NOT NULL DEFAULT '0',
  `in_backorder_gezet` tinyint(4) NOT NULL DEFAULT '0',
  `oud_handmatig_verwerkt` tinyint(4) NOT NULL DEFAULT '0',
  `automatisch_geclassificeerd` tinyint(4) NOT NULL DEFAULT '0',
  `handmatig_geclassificeerd` tinyint(4) NOT NULL DEFAULT '0',
  `gecrediteerd` tinyint(4) NOT NULL DEFAULT '0',
  `volledig_geleverd_backorder` tinyint(4) NOT NULL DEFAULT '0',
  `samengevoegd_met_eerdere_order` tinyint(4) NOT NULL DEFAULT '0',
  `niet_inpakken` tinyint(4) NOT NULL DEFAULT '0',
  `afgesloten` tinyint(4) NOT NULL DEFAULT '0',
  `factuur_per_mail_verzonden` tinyint(4) NOT NULL DEFAULT '0',
  `pdf_factuur_gecontroleerd` tinyint(4) NOT NULL DEFAULT '0',
  `voorgemeld_bij_postnl` tinyint(4) NOT NULL DEFAULT '0',
  `pakket_afgeleverd_volgens_postnl` tinyint(4) NOT NULL DEFAULT '0',
  `kan_gedownload_worden` tinyint(4) NOT NULL DEFAULT '0',
  `pakbon_geprint` tinyint(4) NOT NULL DEFAULT '0',
  `uit_backorder_gehaald` tinyint(4) NOT NULL DEFAULT '0',
  `factuur_sturen_niet_nodig` tinyint(4) NOT NULL DEFAULT '0',
  `hoeft_niet_betaald_te_worden` tinyint(4) NOT NULL DEFAULT '0',
  `uitgevoerd_naar_exact_via_mari` tinyint(4) NOT NULL DEFAULT '0',
  `wacht_op_compleet` tinyint(4) NOT NULL DEFAULT '0',
  `inpakbevestiging_verzonden` tinyint(4) NOT NULL DEFAULT '0',
  `niet_reserveren` tinyint(4) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `openbestelling` (`bevestigd`,`ingepakt`,`geannuleerd`,`gecrediteerd`,`niet_inpakken`,`afgesloten`,`uit_backorder_gehaald`,`niet_reserveren`),
  KEY `afgesloten` (`afgesloten`),
  KEY `factuur_geprint` (`afgesloten`,`factuur_geprint`),
  KEY `klantenservice` (`bevestigd`,`afgesloten`,`exact_export`,`gefactureerd`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `bic`
--

CREATE TABLE `bic` (
  `_Value` char(10) NOT NULL,
  `_Description` varchar(255) DEFAULT NULL,
  `rubriek` char(50) DEFAULT NULL,
  `rubriekman` varchar(50) DEFAULT NULL,
  `rubriekcom` varchar(50) DEFAULT NULL,
  `rubriekjur` varchar(50) DEFAULT NULL,
  `rubriekalg` varchar(50) DEFAULT NULL,
  `website` varchar(50) DEFAULT NULL,
  `NUR` int(11) DEFAULT NULL,
  `extra_check` varchar(3) NOT NULL,
  `plts` varchar(45) DEFAULT NULL,
  `done` varchar(1) DEFAULT NULL,
  `level_1` varchar(255) DEFAULT NULL,
  `level_2` varchar(255) DEFAULT NULL,
  `level_3` varchar(255) DEFAULT NULL,
  `level_4` varchar(255) DEFAULT NULL,
  `level_5` varchar(255) DEFAULT NULL,
  `level_6` varchar(255) DEFAULT NULL,
  `old_value` varchar(64) DEFAULT NULL,
  `in_feed` varchar(2) DEFAULT NULL,
  `ranking` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `bisac`
--

CREATE TABLE `bisac` (
  `_Value` varchar(9) NOT NULL,
  `_Description` varchar(255) DEFAULT NULL,
  `rubriek` varchar(50) DEFAULT NULL,
  `rubriekman` varchar(50) DEFAULT NULL,
  `rubriekcom` varchar(50) DEFAULT NULL,
  `rubriekjur` varchar(50) DEFAULT NULL,
  `rubriekalg` varchar(50) DEFAULT NULL,
  `website` varchar(20) DEFAULT NULL,
  `NUR` int(11) DEFAULT NULL,
  `extra_check` varchar(3) DEFAULT NULL,
  `plts` varchar(255) DEFAULT NULL,
  `level_0` varchar(255) DEFAULT NULL,
  `level_1` varchar(255) DEFAULT NULL,
  `level_2` varchar(255) DEFAULT NULL,
  `level_3` varchar(255) DEFAULT NULL,
  `level_4` varchar(255) DEFAULT NULL,
  `level_5` varchar(255) DEFAULT NULL,
  `level_6` varchar(255) DEFAULT NULL,
  `in_feed` varchar(2) DEFAULT NULL,
  `ranking` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `bq`
--

CREATE TABLE `bq` (
  `quoteId` int(11) NOT NULL AUTO_INCREMENT,
  `Ean` char(13) CHARACTER SET latin1 DEFAULT NULL,
  `quote` text,
  PRIMARY KEY (`quoteId`)
) ENGINE=InnoDB AUTO_INCREMENT=958 DEFAULT CHARSET=utf8;

--
-- Table structure for table `computerboek_uitgevers_csv`
--

CREATE TABLE `computerboek_uitgevers_csv` (
  `UitgeverID` int(10) DEFAULT NULL,
  `Crediteurnummer` int(10) DEFAULT NULL,
  `Klantnummer` int(10) DEFAULT NULL,
  `Magazijnlocatienummer` int(10) DEFAULT NULL,
  `MagazijnlocatienummerBulk` int(10) DEFAULT NULL,
  `NaamUitgever` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `deadlocks`
--

CREATE TABLE `deadlocks` (
  `server` char(20) NOT NULL,
  `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `thread` int(10) unsigned NOT NULL,
  `txn_id` bigint(20) unsigned NOT NULL,
  `txn_time` smallint(5) unsigned NOT NULL,
  `user` char(16) NOT NULL,
  `hostname` char(20) NOT NULL,
  `ip` char(15) NOT NULL,
  `db` char(64) NOT NULL,
  `tbl` char(64) NOT NULL,
  `idx` char(64) NOT NULL,
  `lock_type` char(16) NOT NULL,
  `lock_mode` char(1) NOT NULL,
  `wait_hold` char(1) NOT NULL,
  `victim` tinyint(3) unsigned NOT NULL,
  `query` text NOT NULL,
  PRIMARY KEY (`server`,`ts`,`thread`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `dubbelGeplaatst`
--

CREATE TABLE `dubbelGeplaatst` (
  `CbRegelId` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `fitware_to_cid`
--

CREATE TABLE `fitware_to_cid` (
  `fitware` bigint(20) NOT NULL DEFAULT '0',
  `cid` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`fitware`,`cid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `fw_klanten`
--

CREATE TABLE `fw_klanten` (
  `CID` bigint(20) DEFAULT NULL,
  `Fitware-debiteur` char(36) DEFAULT NULL,
  `Emailadres` varchar(300) DEFAULT NULL,
  `Klantid` int(11) DEFAULT NULL,
  KEY `Emailadres` (`Emailadres`(255))
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `innodb_lock_monitor`
--

CREATE TABLE `innodb_lock_monitor` (
  `a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `items`
--

CREATE TABLE `items` (
  `lego_id` int(13) unsigned NOT NULL,
  `datum` date NOT NULL,
  `index` int(13) unsigned NOT NULL,
  `type` enum('ean','image','auteur','spreker','html','boekblog') NOT NULL DEFAULT 'ean',
  `fallback` tinyint(2) NOT NULL DEFAULT '3',
  `data` blob NOT NULL,
  PRIMARY KEY (`lego_id`,`datum`,`index`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `jer`
--

CREATE TABLE `jer` (
  `exemplaarId` int(11) NOT NULL,
  PRIMARY KEY (`exemplaarId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `jongbloed_abo_klanten`
--

CREATE TABLE `jongbloed_abo_klanten` (
  `CID` bigint(20) NOT NULL,
  `KlantID` int(11) DEFAULT NULL,
  `Factuur_klantid` int(11) DEFAULT NULL,
  `Orig_klantid` int(11) DEFAULT NULL,
  PRIMARY KEY (`CID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Temporary table structure for view `jongbloed_abobestand_naw_tbv_import`
--

/*!50001 DROP VIEW IF EXISTS `jongbloed_abobestand_naw_tbv_import`*/;
/*!50001 CREATE TABLE `jongbloed_abobestand_naw_tbv_import` (
  `CID` tinyint NOT NULL,
  `KlantID` tinyint NOT NULL,
  `Bedrijfsnaam` tinyint NOT NULL,
  `Afdeling` tinyint NOT NULL,
  `Straatnaam` tinyint NOT NULL,
  `Huisnummer` tinyint NOT NULL,
  `Huisnummertoevoeging` tinyint NOT NULL,
  `Postcode` tinyint NOT NULL,
  `Plaats` tinyint NOT NULL,
  `Land` tinyint NOT NULL,
  `Factuur_klantid` tinyint NOT NULL
) ENGINE=MyISAM */;

--
-- Table structure for table `jongbloed_abos_verzend`
--

CREATE TABLE `jongbloed_abos_verzend` (
  `CID` bigint(20) NOT NULL,
  `KlantID` int(11) DEFAULT NULL,
  `Bedrijfsnaam` varchar(100) DEFAULT NULL,
  `Afdeling` varchar(100) DEFAULT NULL,
  `Straatnaam` varchar(100) DEFAULT NULL,
  `Huisnummer` int(11) DEFAULT NULL,
  `Huisnummertoevoeging` varchar(5) DEFAULT NULL,
  `Postcode` varchar(10) DEFAULT NULL,
  `Plaats` varchar(100) DEFAULT NULL,
  `Land` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`CID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `jongbloedseries`
--

CREATE TABLE `jongbloedseries` (
  `Titelserie` varchar(150) NOT NULL,
  PRIMARY KEY (`Titelserie`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `kml`
--

CREATE TABLE `kml` (
  `DT` datetime NOT NULL,
  `KlantId` int(11) NOT NULL DEFAULT '0',
  `Email` varchar(255) NOT NULL,
  `Mailinglistid` int(11) NOT NULL DEFAULT '0',
  `Subscribe` tinyint(4) DEFAULT '0',
  `Sync` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`DT`,`KlantId`,`Email`,`Mailinglistid`),
  KEY `DT` (`DT`),
  KEY `Sync` (`Sync`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `serieduplicaten_te_factureren`
--

CREATE TABLE `serieduplicaten_te_factureren` (
  `KlantID` int(11) NOT NULL,
  `Titelserie` varchar(100) NOT NULL,
  `EAN` char(13) CHARACTER SET latin1 NOT NULL,
  `Postcode` varchar(200) DEFAULT NULL,
  `Huisnummer` varchar(200) DEFAULT NULL,
  `Huisnummertoevoeging` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`KlantID`,`EAN`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `thijs_log`
--

CREATE TABLE `thijs_log` (
  `DT` datetime(6) NOT NULL,
  `Message` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `tmpPeriodieken`
--

CREATE TABLE `tmpPeriodieken` (
  `volgnummer` int(13) NOT NULL AUTO_INCREMENT,
  `bron` varchar(255) DEFAULT NULL,
  `id` varchar(255) DEFAULT NULL,
  `importeren?` double DEFAULT NULL,
  `titel` varchar(255) DEFAULT NULL,
  `Rubriek Jur` varchar(255) DEFAULT NULL,
  `afkorting` varchar(255) DEFAULT NULL,
  `Contributie` varchar(255) DEFAULT NULL,
  `online_toegang` double DEFAULT NULL,
  `uitgever` varchar(255) DEFAULT NULL,
  `uitgeverID` double DEFAULT NULL,
  `productcode_uitgever` double DEFAULT NULL,
  `boekstatus` double DEFAULT NULL,
  `verschijningsfrequentie` double DEFAULT NULL,
  `taal` varchar(255) DEFAULT NULL,
  `nur` double DEFAULT NULL,
  `omschrijving` text,
  `aanvullende_info` varchar(255) DEFAULT NULL,
  `internetsite` varchar(255) DEFAULT NULL,
  `minimum_looptijd` double DEFAULT NULL,
  `opzegtermijn` double DEFAULT NULL,
  `looptijd` double DEFAULT NULL,
  `verborgenboek` double DEFAULT NULL,
  PRIMARY KEY (`volgnummer`)
) ENGINE=InnoDB AUTO_INCREMENT=835 DEFAULT CHARSET=utf8;

--
-- Dumping routines for database 'tmp'
--
/*!50003 DROP FUNCTION IF EXISTS `EAN` */;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `EAN`(_ean VARCHAR(12)) RETURNS varchar(13) CHARSET latin1
    READS SQL DATA
BEGIN
DECLARE _correct_ean TINYINT;
DECLARE _even_sum SMALLINT;
DECLARE _odd_sum SMALLINT;
DECLARE _check_digit SMALLINT;
DECLARE _check_number SMALLINT;
IF NOT _ean REGEXP '^[0-9]+$' THEN RETURN NULL; END IF;
CASE LENGTH(_ean)
WHEN 12 THEN
SELECT SUBSTR(_ean, 2, 1)+SUBSTR(_ean, 4, 1)+SUBSTR(_ean, 6, 1)+SUBSTR(_ean, 8, 1)+SUBSTR(_ean, 10, 1)+SUBSTR(_ean, 12, 1) INTO _even_sum;
SELECT SUBSTR(_ean, 1, 1)+SUBSTR(_ean, 3, 1)+SUBSTR(_ean, 5, 1)+SUBSTR(_ean, 7, 1)+SUBSTR(_ean, 9, 1)+SUBSTR(_ean, 11, 1) INTO _odd_sum;
WHEN 7 THEN
SELECT SUBSTR(_ean, 2, 1)+SUBSTR(_ean, 4, 1)+SUBSTR(_ean, 6, 1) INTO _even_sum;
SELECT SUBSTR(_ean, 1, 1)+SUBSTR(_ean, 3, 1)+SUBSTR(_ean, 5, 1)+SUBSTR(_ean, 7, 1) INTO _odd_sum;
ELSE RETURN NULL;
END CASE;
SELECT ( (10-(3*_even_sum + _odd_sum)%10)%10 ) INTO _check_digit;
RETURN concat(_ean,_check_digit);
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `url_decode` */;
ALTER DATABASE `tmp` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` FUNCTION `url_decode`(original_text text) RETURNS text CHARSET latin1
    DETERMINISTIC
BEGIN
       declare new_text text default null;
       declare pointer int default 1;
       set new_text = replace(original_text,'+',' ');
       while (LOCATE("%",new_text,pointer) <> 0 )&& (pointer < length(new_text)) do
             set pointer = LOCATE("%",new_text,pointer);
             set new_text = concat(left(new_text,pointer-1),char(conv(mid(new_text,pointer+1,2),16,10)),right(new_text,length(new_text)-(pointer+2)));
             set pointer = pointer + 1;
       end while;
       return new_text; 
END ;;
DELIMITER ;
ALTER DATABASE `tmp` CHARACTER SET utf8 COLLATE utf8_general_ci ;
/*!50003 DROP PROCEDURE IF EXISTS `ClearAllSearch` */;
ALTER DATABASE `tmp` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `ClearAllSearch`()
    DETERMINISTIC
BEGIN
	DECLARE done INT DEFAULT 0;
	DECLARE tname CHAR(255);
	DECLARE cur1 CURSOR FOR SELECT `name` FROM tmp.SearchTables;	
	DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = TRUE; 
	IF GET_LOCK( 'searchtables', 1 ) THEN
		OPEN cur1;
		REPEAT
			FETCH cur1 INTO tname;
			
			SET @s = CONCAT( "DROP TABLE IF EXISTS tmp.", tname );
			PREPARE stmt FROM @s;
			EXECUTE stmt;
			SET @s = CONCAT( "DELETE FROM tmp.SearchTables WHERE `name` = '", tname, "'" );
			PREPARE stmt FROM @s;
			EXECUTE stmt;
			
			REPLACE INTO tmp.ClearUpdates VALUES ( 'update', NOW() );
		UNTIL done END REPEAT;
		
		SELECT RELEASE_LOCK( 'searchtables' );
	END IF;
    END ;;
DELIMITER ;
ALTER DATABASE `tmp` CHARACTER SET utf8 COLLATE utf8_general_ci ;
/*!50003 DROP PROCEDURE IF EXISTS `ClearSearch` */;
ALTER DATABASE `tmp` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
DELIMITER ;;
CREATE DEFINER=`sander`@`%` PROCEDURE `ClearSearch`()
    DETERMINISTIC
BEGIN
	DECLARE done INT DEFAULT 0;
	DECLARE tname CHAR(255);
	DECLARE cur1 CURSOR FOR SELECT `name` FROM tmp.SearchTables WHERE DT < DATE_SUB( NOW(), INTERVAL 5 MINUTE ) AND NOT `name` IS NULL;	
	DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = TRUE; 
	IF GET_LOCK( 'searchtables', 1 ) THEN
		OPEN cur1;
		REPEAT
			FETCH cur1 INTO tname;
			
			SET @s = CONCAT( "DROP TABLE IF EXISTS tmp.", tname );
			PREPARE stmt FROM @s;
			EXECUTE stmt;
			SET @s = CONCAT( "DELETE FROM tmp.SearchTables WHERE `name` = '", tname, "'" );
			PREPARE stmt FROM @s;
			EXECUTE stmt;
		
		UNTIL done END REPEAT;
		REPLACE INTO tmp.ClearUpdates VALUES ( 'update', NOW() );
		SELECT RELEASE_LOCK( 'searchtables' );
	END IF;		
    END ;;
DELIMITER ;
ALTER DATABASE `tmp` CHARACTER SET utf8 COLLATE utf8_general_ci ;

--
-- Current Database: `AdWords`
--

USE `AdWords`;

--
-- Final view structure for view `OmzetInAnalytics`
--

/*!50001 DROP TABLE IF EXISTS `OmzetInAnalytics`*/;
/*!50001 DROP VIEW IF EXISTS `OmzetInAnalytics`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `OmzetInAnalytics` AS select cast(`B`.`DT` as date) AS `DT`,`BIA`.`AdGroupId` AS `AdgroupId`,count(distinct `BIA`.`BestellingId`) AS `Conversies`,sum(`B`.`OmzetExBtwIncKorting`) AS `Omzet`,sum(`B`.`Bijdrage`) AS `Bijdrage` from (`AdWords`.`BestellingenInAnalytics` `BIA` join `Managementboek_Klanten`.`Bestellingen_voor_omzet` `B` on((`BIA`.`BestellingId` = `B`.`Bestellingid`))) group by cast(`B`.`DT` as date),`BIA`.`AdGroupId` having (`AdgroupId` > 0) */;

--
-- Final view structure for view `OmzetPerAdGroup`
--

/*!50001 DROP TABLE IF EXISTS `OmzetPerAdGroup`*/;
/*!50001 DROP VIEW IF EXISTS `OmzetPerAdGroup`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `OmzetPerAdGroup` AS select `SA`.`adgroupid` AS `adgroupid`,count(distinct `CL`.`gclid`) AS `AantalClicks`,count(distinct `BA`.`SessionId`) AS `AantalBestellingen`,ifnull(sum(`BN`.`Bijdrage`),0) AS `Bijdrage`,ifnull(sum(`BN`.`BedragIncBtwIncKorting`),0) AS `Omzet`,ifnull(round((sum(`BN`.`Bijdrage`) / count(distinct `BA`.`Bestellingid`)),2),0) AS `BijdragePerVisit`,ifnull(round((sum(`BN`.`BedragIncBtwIncKorting`) / count(distinct `BA`.`Bestellingid`)),2),0) AS `OmzetPerVisit`,cast(`CL`.`dt` as date) AS `dt` from ((((`AdWords`.`ClickLog` `CL` left join `AdWords`.`StructureAds` `SA` on((`CL`.`adid` = `SA`.`adid`))) left join `Managementboek_Klanten`.`SessionGclid` `SG` on((`CL`.`gclid` = `SG`.`Gclid`))) left join `Managementboek_Klanten`.`BestellingAll` `BA` on(((`BA`.`Afgerond` = 1) and (`BA`.`Geannuleerd` = 0) and (`BA`.`SessionId` = `SG`.`SessionId`) and (`BA`.`DT` > '2013-1-1')))) left join `Managementboek_Klanten`.`Bestellingen` `BN` on(((`BA`.`Bestellingid` = `BN`.`Bestellingid`) and (`BN`.`Geannuleerd` = 0) and isnull(`BN`.`BackorderOrigineel`)))) where (`SA`.`adgroupid` > 0) group by `SA`.`adgroupid`,cast(`CL`.`dt` as date) order by `CL`.`dt` desc */;

--
-- Final view structure for view `OmzetPerAdGroup3`
--

/*!50001 DROP TABLE IF EXISTS `OmzetPerAdGroup3`*/;
/*!50001 DROP VIEW IF EXISTS `OmzetPerAdGroup3`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `OmzetPerAdGroup3` AS select `BIA`.`AdGroupId` AS `adgroupid`,ifnull(`CIA`.`clicks`,0) AS `AantalClicks`,count(distinct `BIA`.`BestellingId`) AS `AantalBestellingen`,sum(distinct `BVO`.`Bijdrage`) AS `Bijdrage`,sum(distinct `BVO`.`OmzetExBtwIncKorting`) AS `Omzet`,0 AS `BijdragePerVisit`,(sum(distinct `BVO`.`OmzetExBtwIncKorting`) / ifnull(`CIA`.`clicks`,0)) AS `OmzetPerVisit`,ifnull(cast(`BVO`.`DT` as date),0) AS `dt`,`SAG`.`clicks` AS `SAGClicks` from (((`AdWords`.`BestellingenInAnalytics` `BIA` join `Managementboek_Klanten`.`Bestellingen_voor_omzet` `BVO` on((`BIA`.`BestellingId` = `BVO`.`Bestellingid`))) left join `AdWords`.`ClicksInAnalytics` `CIA` on(((`CIA`.`dt` = cast(`BVO`.`DT` as date)) and (`CIA`.`adgroupid` = `BIA`.`AdGroupId`)))) left join `AdWords`.`StatsAdgroup` `SAG` on(((`SAG`.`dt` = `CIA`.`dt`) and (`SAG`.`adgroupid` = `CIA`.`adgroupid`)))) group by `BIA`.`AdGroupId`,cast(`BVO`.`DT` as date) */;

--
-- Final view structure for view `OmzetPerAdgroupTotaal`
--

/*!50001 DROP TABLE IF EXISTS `OmzetPerAdgroupTotaal`*/;
/*!50001 DROP VIEW IF EXISTS `OmzetPerAdgroupTotaal`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `OmzetPerAdgroupTotaal` AS select `OmzetPerAdGroup`.`adgroupid` AS `adgroupid`,`AdWords`.`StructureAdGroup`.`campaignid` AS `campaignid`,`AdWords`.`StructureAdGroup`.`adgroup` AS `adgroup`,`AdWords`.`StructureAdGroup`.`agStatus` AS `status`,`OmzetPerAdGroup`.`dt` AS `dt`,`OmzetPerAdGroup`.`AantalClicks` AS `site_clicks`,`OmzetPerAdGroup`.`AantalBestellingen` AS `site_bestellingen`,`OmzetPerAdGroup`.`Bijdrage` AS `site_bijdrage`,`OmzetPerAdGroup`.`Omzet` AS `site_omzet`,`OmzetPerAdGroup`.`BijdragePerVisit` AS `site_bijdrage_per_visit`,`OmzetPerAdGroup`.`OmzetPerVisit` AS `site_omzet_per_visit`,(`OmzetPerAdGroup`.`Bijdrage` - ifnull(`AdWords`.`StatsAdgroup`.`cost`,0)) AS `site_bijdrage_minus_kosten`,`AdWords`.`StatsAdgroup`.`imps` AS `google_impressions`,`AdWords`.`StatsAdgroup`.`clicks` AS `google_clicks`,`AdWords`.`StatsAdgroup`.`cost` AS `google_cost`,`AdWords`.`StatsAdgroup`.`conversions` AS `google_conversions`,`AdWords`.`StatsAdgroup`.`conversionvalue` AS `google_conversionvalue`,`AdWords`.`StatsAdgroup`.`averagecpc` AS `google_avg_cpc`,`AdWords`.`StructureAdGroup`.`adGroupMaxCpc` AS `google_max_cpc`,ifnull(`BK`.`HuidigeEuroPrijs`,0) AS `prijs` from (((`AdWords`.`StatsAdgroup` left join `AdWords`.`OmzetPerAdGroup` on(((`OmzetPerAdGroup`.`adgroupid` = `AdWords`.`StatsAdgroup`.`adgroupid`) and (`OmzetPerAdGroup`.`dt` = `AdWords`.`StatsAdgroup`.`dt`)))) left join `AdWords`.`StructureAdGroup` on((`OmzetPerAdGroup`.`adgroupid` = `AdWords`.`StructureAdGroup`.`adgroupid`))) left join `Managementboek_Boeken`.`Boeken_met_prijs` `BK` on((`BK`.`Ean` = substr(`AdWords`.`StructureAdGroup`.`adgroup`,1,13)))) */;

--
-- Final view structure for view `OmzetPerAdgroupTotaal2`
--

/*!50001 DROP TABLE IF EXISTS `OmzetPerAdgroupTotaal2`*/;
/*!50001 DROP VIEW IF EXISTS `OmzetPerAdgroupTotaal2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `OmzetPerAdgroupTotaal2` AS select `AdWords`.`StructureAdGroup`.`adgroupid` AS `adgroupid`,`AdWords`.`StructureAdGroup`.`campaignid` AS `campaignid`,`AdWords`.`StructureAdGroup`.`adgroup` AS `adgroup`,`AdWords`.`StructureAdGroup`.`agStatus` AS `status`,`AdWords`.`StatsAdgroup`.`dt` AS `dt`,`OmzetPerAdGroup`.`AantalClicks` AS `site_clicks`,`OmzetPerAdGroup`.`AantalBestellingen` AS `site_bestellingen`,`OmzetPerAdGroup`.`Bijdrage` AS `site_bijdrage`,`OmzetPerAdGroup`.`Omzet` AS `site_omzet`,`OmzetPerAdGroup`.`BijdragePerVisit` AS `site_bijdrage_per_visit`,`OmzetPerAdGroup`.`OmzetPerVisit` AS `site_omzet_per_visit`,(`OmzetPerAdGroup`.`Bijdrage` - ifnull(`AdWords`.`StatsAdgroup`.`cost`,0)) AS `site_bijdrage_minus_kosten`,ifnull(`AdWords`.`StatsAdgroup`.`imps`,0) AS `google_impressions`,ifnull(`AdWords`.`StatsAdgroup`.`clicks`,0) AS `google_clicks`,ifnull(`AdWords`.`StatsAdgroup`.`cost`,0) AS `google_cost`,ifnull(`AdWords`.`StatsAdgroup`.`conversions`,0) AS `google_conversions`,ifnull(`AdWords`.`StatsAdgroup`.`conversionvalue`,0) AS `google_conversionvalue`,ifnull(`AdWords`.`StatsAdgroup`.`averagecpc`,0) AS `google_avg_cpc`,ifnull(`AdWords`.`StructureAdGroup`.`adGroupMaxCpc`,0) AS `google_max_cpc`,ifnull(`BK`.`HuidigeEuroPrijs`,0) AS `prijs` from ((((`AdWords`.`StructureCampaigns` left join `AdWords`.`StructureAdGroup` on((`AdWords`.`StructureCampaigns`.`campaignid` = `AdWords`.`StructureAdGroup`.`campaignid`))) left join `AdWords`.`StatsAdgroup` on((`AdWords`.`StructureAdGroup`.`adgroupid` = `AdWords`.`StatsAdgroup`.`adgroupid`))) left join `AdWords`.`OmzetPerAdGroup` on(((`OmzetPerAdGroup`.`adgroupid` = `AdWords`.`StatsAdgroup`.`adgroupid`) and (`OmzetPerAdGroup`.`dt` = `AdWords`.`StatsAdgroup`.`dt`)))) left join `Managementboek_Boeken`.`Boeken_met_prijs` `BK` on((`BK`.`Ean` = substr(`AdWords`.`StructureAdGroup`.`adgroup`,1,13)))) where (`AdWords`.`StructureCampaigns`.`campaignid` = 99973038) */;

--
-- Current Database: `Admin`
--

USE `Admin`;

--
-- Current Database: `AdminSettings`
--

USE `AdminSettings`;

--
-- Final view structure for view `AllSettings`
--

/*!50001 DROP TABLE IF EXISTS `AllSettings`*/;
/*!50001 DROP VIEW IF EXISTS `AllSettings`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`tvdijk`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `AllSettings` AS select `AdminSettings`.`Users`.`UserID` AS `UserID`,`AdminSettings`.`SettingGroups`.`ShortName` AS `Group`,`AdminSettings`.`Settings`.`ShortName` AS `ShortName`,`AdminSettings`.`Settings`.`DataType` AS `DataType`,if((`AdminSettings`.`Settings`.`DataType` = 'Boolean'),ifnull(`AdminSettings`.`UserSettings`.`Boolean`,convert((select `AdminSettings`.`ProphileSettings`.`Boolean` AS `Boolean` from `ProphileSettings` where ((`AdminSettings`.`ProphileSettings`.`SettingID` = `AdminSettings`.`Settings`.`SettingID`) and ((select count(0) AS `count(*)` from `ProphileUsers` `PU` where ((`PU`.`UserID` = `AdminSettings`.`Users`.`UserID`) and (`PU`.`ProphileID` = `AdminSettings`.`ProphileSettings`.`ProphileID`))) > 0)) order by (select `PU`.`Order` AS `Order` from `ProphileUsers` `PU` where ((`PU`.`UserID` = `AdminSettings`.`Users`.`UserID`) and (`PU`.`ProphileID` = `AdminSettings`.`ProphileSettings`.`ProphileID`))) limit 1) using utf8)),NULL) AS `Boolean`,if((`AdminSettings`.`Settings`.`DataType` = 'Integer'),ifnull(`AdminSettings`.`UserSettings`.`Integer`,(select `AdminSettings`.`ProphileSettings`.`Integer` AS `Integer` from `ProphileSettings` where ((`AdminSettings`.`ProphileSettings`.`SettingID` = `AdminSettings`.`Settings`.`SettingID`) and ((select count(0) AS `count(*)` from `ProphileUsers` `PU` where ((`PU`.`UserID` = `AdminSettings`.`Users`.`UserID`) and (`PU`.`ProphileID` = `AdminSettings`.`ProphileSettings`.`ProphileID`))) > 0)) order by (select `PU`.`Order` AS `Order` from `ProphileUsers` `PU` where ((`PU`.`UserID` = `AdminSettings`.`Users`.`UserID`) and (`PU`.`ProphileID` = `AdminSettings`.`ProphileSettings`.`ProphileID`))) limit 1)),NULL) AS `Integer`,if((`AdminSettings`.`Settings`.`DataType` = 'String'),ifnull(`AdminSettings`.`UserSettings`.`String`,convert((select `AdminSettings`.`ProphileSettings`.`String` AS `String` from `ProphileSettings` where ((`AdminSettings`.`ProphileSettings`.`SettingID` = `AdminSettings`.`Settings`.`SettingID`) and ((select count(0) AS `count(*)` from `ProphileUsers` `PU` where ((`PU`.`UserID` = `AdminSettings`.`Users`.`UserID`) and (`PU`.`ProphileID` = `AdminSettings`.`ProphileSettings`.`ProphileID`))) > 0)) order by (select `PU`.`Order` AS `Order` from `ProphileUsers` `PU` where ((`PU`.`UserID` = `AdminSettings`.`Users`.`UserID`) and (`PU`.`ProphileID` = `AdminSettings`.`ProphileSettings`.`ProphileID`))) limit 1) using utf8)),NULL) AS `String` from (((`Users` join `Settings` on(1)) left join `SettingGroups` on((`AdminSettings`.`SettingGroups`.`SettingGroupID` = `AdminSettings`.`Settings`.`SettingGroupID`))) left join `UserSettings` on(((`AdminSettings`.`UserSettings`.`UserID` = `AdminSettings`.`Users`.`UserID`) and (`AdminSettings`.`UserSettings`.`SettingID` = `AdminSettings`.`Settings`.`SettingID`)))) order by `AdminSettings`.`Users`.`UserID`,`AdminSettings`.`Settings`.`SettingID` */;

--
-- Current Database: `BTW`
--

USE `BTW`;

--
-- Current Database: `Boekcover`
--

USE `Boekcover`;

--
-- Final view structure for view `ArtikelMetIntro`
--

/*!50001 DROP TABLE IF EXISTS `ArtikelMetIntro`*/;
/*!50001 DROP VIEW IF EXISTS `ArtikelMetIntro`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`thijs`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `ArtikelMetIntro` AS select `a`.`ArtikelID` AS `ArtikelID`,`a`.`texttitel` AS `Titel`,if(isnull(`a`.`texttitelkort`),`a`.`texttitel`,`a`.`texttitelkort`) AS `Titelkort`,`a`.`DTPublicatie` AS `DTPublicatie`,`a`.`DTWijziging` AS `DTWijziging`,`a`.`Naam` AS `Auteur`,`a`.`GastAuteur` AS `GastAuteur`,`a`.`Magazine` AS `Magazine`,`ad1`.`TextValue` AS `Intro`,`ad2`.`TextValue` AS `Introkort`,`aq`.`SEURL` AS `SEURL`,`aq`.`Template` AS `Template`,`rubriek`(`aq`.`Template`) AS `rubriek_op_site` from (((`Boekcover`.`Artikelen` `aq` left join `Boekcover`.`ArtikelData` `ad1` on(((`ad1`.`ArtikelID` = `aq`.`ArtikelID`) and (`ad1`.`Key` = 'textintro')))) left join `Boekcover`.`ArtikelData` `ad2` on(((`ad2`.`ArtikelID` = `aq`.`ArtikelID`) and (`ad2`.`Key` = 'textintrokort')))) left join `Boekcover`.`v_artikelen` `a` on((`a`.`ArtikelID` = `aq`.`ArtikelID`))) where ((`aq`.`Gepubliceerd` = 1) and (`aq`.`Geautoriseerd` = 1) and (`aq`.`DTPublicatie` <= now())) order by `aq`.`DTPublicatie` desc */;

--
-- Final view structure for view `v_artikelen`
--

/*!50001 DROP TABLE IF EXISTS `v_artikelen`*/;
/*!50001 DROP VIEW IF EXISTS `v_artikelen`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`thijs`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `v_artikelen` AS select `a`.`ArtikelID` AS `ArtikelID`,`a`.`Template` AS `Template`,`a`.`SEURL` AS `SEURL`,`a`.`Hoofdartikel` AS `Hoofdartikel`,`a`.`SkipHomepage` AS `SkipHomepage`,`a`.`opMgtboek` AS `opMgtboek`,`rubriek`(`a`.`Template`) AS `rubriek_op_site`,`a`.`DTPublicatie` AS `DTPublicatie`,`a`.`UserID` AS `UserId`,`a`.`Magazine` AS `Magazine`,`ad2`.`TextValue` AS `texttitel`,`ad`.`TextValue` AS `texttitelkort`,`Boekcover`.`Users`.`Naam` AS `Naam`,`ad3`.`TextValue` AS `GastAuteur`,`a`.`Gepubliceerd` AS `Gepubliceerd`,`a`.`DTWijziging` AS `DTWijziging`,`a`.`Geautoriseerd` AS `Geautoriseerd`,`ad4`.`TextValue` AS `textintro`,`ad5`.`TextValue` AS `textintrokort`,`ad6`.`TextValue` AS `textbody`,`ad7`.`TextValue` AS `mp3bestand`,`ad8`.`TextValue` AS `textcolumnist`,`aut`.`VolledigeNaam` AS `Auteurnaam`,`aut`.`Auteurid` AS `Auteurid` from (((((((((((`Boekcover`.`Artikelen` `a` left join `Boekcover`.`Users` on((`a`.`UserID` = `Boekcover`.`Users`.`UserID`))) left join `Boekcover`.`ArtikelBoekAuteurs` `bat` on(((`bat`.`ArtikelID` = `a`.`ArtikelID`) and (`bat`.`EersteAuteur` = 1)))) left join `Manpo`.`Auteurs_met_naam` `aut` on((`aut`.`Auteurid` = `bat`.`AuteurID`))) left join `Boekcover`.`ArtikelData` `ad` on(((`a`.`ArtikelID` = `ad`.`ArtikelID`) and (`ad`.`Key` = 'texttitelkort')))) left join `Boekcover`.`ArtikelData` `ad2` on(((`a`.`ArtikelID` = `ad2`.`ArtikelID`) and (`ad2`.`Key` = 'texttitel')))) left join `Boekcover`.`ArtikelData` `ad3` on(((`a`.`ArtikelID` = `ad3`.`ArtikelID`) and (`ad3`.`Key` = 'textgastauteur')))) left join `Boekcover`.`ArtikelData` `ad4` on(((`a`.`ArtikelID` = `ad4`.`ArtikelID`) and (`ad4`.`Key` = 'textintro')))) left join `Boekcover`.`ArtikelData` `ad5` on(((`a`.`ArtikelID` = `ad5`.`ArtikelID`) and (`ad5`.`Key` = 'textintrokort')))) left join `Boekcover`.`ArtikelData` `ad6` on(((`a`.`ArtikelID` = `ad6`.`ArtikelID`) and (`ad6`.`Key` = 'textbody')))) left join `Boekcover`.`ArtikelData` `ad7` on(((`a`.`ArtikelID` = `ad7`.`ArtikelID`) and (`ad7`.`Key` = 'mp3bestand')))) left join `Boekcover`.`ArtikelData` `ad8` on(((`a`.`ArtikelID` = `ad8`.`ArtikelID`) and (`ad8`.`Key` = 'textcolumnist')))) */;

--
-- Final view structure for view `v_artikelen_old`
--

/*!50001 DROP TABLE IF EXISTS `v_artikelen_old`*/;
/*!50001 DROP VIEW IF EXISTS `v_artikelen_old`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`dennis`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `v_artikelen_old` AS (select `a`.`ArtikelID` AS `ArtikelID`,`a`.`Template` AS `Template`,`a`.`DTPublicatie` AS `DTPublicatie`,(select `ArtikelData`.`TextValue` AS `TextValue` from `ArtikelData` where ((`ArtikelData`.`ArtikelID` = `a`.`ArtikelID`) and (`ArtikelData`.`Key` = 'texttitelkort'))) AS `texttitelkort`,`Users`.`Naam` AS `Naam` from (`Artikelen` `a` join `Users` on((`Users`.`UserID` = `a`.`UserID`))) group by `a`.`DTPublicatie` desc) */;

--
-- Current Database: `BoekenTmp`
--

USE `BoekenTmp`;

--
-- Current Database: `CMS`
--

USE `CMS`;

--
-- Current Database: `CMS2011`
--

USE `CMS2011`;

--
-- Final view structure for view `view_artikel`
--

/*!50001 DROP TABLE IF EXISTS `view_artikel`*/;
/*!50001 DROP VIEW IF EXISTS `view_artikel`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`thijs`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `view_artikel` AS select `A`.`ArtikelId` AS `ArtikelId`,`A`.`ProjectId` AS `ProjectId`,`A`.`UserName` AS `UserName`,`A`.`AuteurName` AS `AuteurName`,`A`.`Gepubliceerd` AS `Gepubliceerd`,`A`.`Geautoriseerd` AS `Geautoriseerd`,`A`.`DTWijziging` AS `DTWijziging`,`A`.`DTPublicatie` AS `DTPublicatie`,`A`.`Titel` AS `Titel`,`A`.`SEURL` AS `SEURL`,`A`.`Template` AS `Template`,`A`.`IsHoofdartikel` AS `IsHoofdartikel`,`A`.`SkipHomepage` AS `SkipHomepage`,`A`.`OpMgtboek` AS `OpMgtboek`,`A`.`MgtRubriek` AS `MgtRubriek`,`T_textcontent`.`DataValue` AS `Textcontent`,`T_youtubeurl`.`DataValue` AS `Youtubeurl` from ((`Artikelen` `A` left join `ArtikelData` `T_textcontent` on(((`A`.`ArtikelId` = `T_textcontent`.`ArtikelId`) and (`T_textcontent`.`DataKey` = 'textcontent')))) left join `ArtikelData` `T_youtubeurl` on(((`A`.`ArtikelId` = `T_youtubeurl`.`ArtikelId`) and (`T_youtubeurl`.`DataKey` = 'youtubeurl')))) */;

--
-- Final view structure for view `view_managementboek_nl_video`
--

/*!50001 DROP TABLE IF EXISTS `view_managementboek_nl_video`*/;
/*!50001 DROP VIEW IF EXISTS `view_managementboek_nl_video`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`site`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `view_managementboek_nl_video` AS select `A`.`ArtikelId` AS `ArtikelId`,`A`.`ProjectId` AS `ProjectId`,`A`.`UserName` AS `UserName`,`A`.`AuteurName` AS `AuteurName`,`A`.`Gepubliceerd` AS `Gepubliceerd`,`A`.`Geautoriseerd` AS `Geautoriseerd`,`A`.`DTWijziging` AS `DTWijziging`,`A`.`DTPublicatie` AS `DTPublicatie`,`A`.`Titel` AS `Titel`,`A`.`SEURL` AS `SEURL`,`A`.`Template` AS `Template`,`A`.`IsHoofdartikel` AS `IsHoofdartikel`,`A`.`SkipHomepage` AS `SkipHomepage`,`A`.`OpMgtboek` AS `OpMgtboek`,`A`.`MgtRubriek` AS `MgtRubriek`,`T_flashfile`.`DataValue` AS `Flashfile`,`T_image`.`DataValue` AS `Image`,`T_covertext1`.`DataValue` AS `Covertext1`,`T_covertext2`.`DataValue` AS `Covertext2`,`T_youtubeurl`.`DataValue` AS `Youtubeurl`,`T_vimeourl`.`DataValue` AS `vimeourl` from ((((((`Artikelen` `A` join `ArtikelData` `T_flashfile` on(((`A`.`ArtikelId` = `T_flashfile`.`ArtikelId`) and (`T_flashfile`.`DataKey` = 'flashfile')))) join `ArtikelData` `T_image` on(((`A`.`ArtikelId` = `T_image`.`ArtikelId`) and (`T_image`.`DataKey` = 'image')))) join `ArtikelData` `T_covertext1` on(((`A`.`ArtikelId` = `T_covertext1`.`ArtikelId`) and (`T_covertext1`.`DataKey` = 'covertext1')))) join `ArtikelData` `T_covertext2` on(((`A`.`ArtikelId` = `T_covertext2`.`ArtikelId`) and (`T_covertext2`.`DataKey` = 'covertext2')))) join `ArtikelData` `T_youtubeurl` on(((`A`.`ArtikelId` = `T_youtubeurl`.`ArtikelId`) and (`T_youtubeurl`.`DataKey` = 'youtubeurl')))) join `ArtikelData` `T_vimeourl` on(((`A`.`ArtikelId` = `T_vimeourl`.`ArtikelId`) and (`T_vimeourl`.`DataKey` = 'vimeourl')))) */;

--
-- Final view structure for view `view_slow_management_artikel`
--

/*!50001 DROP TABLE IF EXISTS `view_slow_management_artikel`*/;
/*!50001 DROP VIEW IF EXISTS `view_slow_management_artikel`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`site`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `view_slow_management_artikel` AS select `A`.`ArtikelId` AS `ArtikelId`,`A`.`ProjectId` AS `ProjectId`,`A`.`UserName` AS `UserName`,`A`.`AuteurName` AS `AuteurName`,`A`.`Gepubliceerd` AS `Gepubliceerd`,`A`.`Geautoriseerd` AS `Geautoriseerd`,`A`.`DTWijziging` AS `DTWijziging`,`A`.`DTPublicatie` AS `DTPublicatie`,`A`.`Titel` AS `Titel`,`A`.`SEURL` AS `SEURL`,`A`.`Template` AS `Template`,`A`.`IsHoofdartikel` AS `IsHoofdartikel`,`A`.`SkipHomepage` AS `SkipHomepage`,`A`.`OpMgtboek` AS `OpMgtboek`,`A`.`MgtRubriek` AS `MgtRubriek`,`T_textkortetitel`.`DataValue` AS `Textkortetitel`,`T_editie`.`DataValue` AS `Editie`,`T_artikeltype`.`DataValue` AS `Artikeltype`,`T_textintro`.`DataValue` AS `Textintro`,`T_textcontent`.`DataValue` AS `Textcontent`,`T_textquote`.`DataValue` AS `Textquote`,`T_thumbnail`.`DataValue` AS `Thumbnail`,`T_afbeelding`.`DataValue` AS `Afbeelding`,`T_hfd-thumbnail`.`DataValue` AS `Hfd-thumbnail`,`T_auteur`.`DataValue` AS `Auteur` from ((((((((((`Artikelen` `A` join `ArtikelData` `T_textkortetitel` on(((`A`.`ArtikelId` = `T_textkortetitel`.`ArtikelId`) and (`T_textkortetitel`.`DataKey` = 'textkortetitel')))) join `ArtikelData` `T_editie` on(((`A`.`ArtikelId` = `T_editie`.`ArtikelId`) and (`T_editie`.`DataKey` = 'editie')))) join `ArtikelData` `T_artikeltype` on(((`A`.`ArtikelId` = `T_artikeltype`.`ArtikelId`) and (`T_artikeltype`.`DataKey` = 'artikeltype')))) join `ArtikelData` `T_textintro` on(((`A`.`ArtikelId` = `T_textintro`.`ArtikelId`) and (`T_textintro`.`DataKey` = 'textintro')))) join `ArtikelData` `T_textcontent` on(((`A`.`ArtikelId` = `T_textcontent`.`ArtikelId`) and (`T_textcontent`.`DataKey` = 'textcontent')))) join `ArtikelData` `T_textquote` on(((`A`.`ArtikelId` = `T_textquote`.`ArtikelId`) and (`T_textquote`.`DataKey` = 'textquote')))) join `ArtikelData` `T_thumbnail` on(((`A`.`ArtikelId` = `T_thumbnail`.`ArtikelId`) and (`T_thumbnail`.`DataKey` = 'thumbnail')))) join `ArtikelData` `T_afbeelding` on(((`A`.`ArtikelId` = `T_afbeelding`.`ArtikelId`) and (`T_afbeelding`.`DataKey` = 'afbeelding')))) join `ArtikelData` `T_hfd-thumbnail` on(((`A`.`ArtikelId` = `T_hfd-thumbnail`.`ArtikelId`) and (`T_hfd-thumbnail`.`DataKey` = 'hfd-thumbnail')))) join `ArtikelData` `T_auteur` on(((`A`.`ArtikelId` = `T_auteur`.`ArtikelId`) and (`T_auteur`.`DataKey` = 'auteur')))) */;

--
-- Current Database: `CbBestellingen`
--

USE `CbBestellingen`;

--
-- Final view structure for view `OpenBestellingenPerEan`
--

/*!50001 DROP TABLE IF EXISTS `OpenBestellingenPerEan`*/;
/*!50001 DROP VIEW IF EXISTS `OpenBestellingenPerEan`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `OpenBestellingenPerEan` AS select `OrderRegels`.`Ean` AS `Ean`,sum(`OrderRegels`.`OpenAantal`) AS `Aantal`,max(`Bestellingen`.`DTBestelling`) AS `DT` from (`Bestellingen` join `OrderRegels` on((`Bestellingen`.`CbBestellingId` = `OrderRegels`.`CbBestellingId`))) where ((`OrderRegels`.`IsGeannuleerd` = 0) and (`Bestellingen`.`IsGeannuleerd` = 0) and (`Bestellingen`.`VoorNCOI` = 0) and (`OrderRegels`.`IsAfgesloten` = 0)) group by `OrderRegels`.`Ean` */;

--
-- Final view structure for view `OpenBestellingenPerEanNCOI`
--

/*!50001 DROP TABLE IF EXISTS `OpenBestellingenPerEanNCOI`*/;
/*!50001 DROP VIEW IF EXISTS `OpenBestellingenPerEanNCOI`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `OpenBestellingenPerEanNCOI` AS select `OrderRegels`.`Ean` AS `Ean`,sum(`OrderRegels`.`OpenAantal`) AS `Aantal`,max(`Bestellingen`.`DTBestelling`) AS `DT` from (`Bestellingen` join `OrderRegels` on((`Bestellingen`.`CbBestellingId` = `OrderRegels`.`CbBestellingId`))) where ((`OrderRegels`.`IsGeannuleerd` = 0) and (`Bestellingen`.`IsGeannuleerd` = 0) and (`Bestellingen`.`VoorNCOI` = 1) and (`OrderRegels`.`IsAfgesloten` = 0)) group by `OrderRegels`.`Ean` */;

--
-- Final view structure for view `OpenNCOIBestellingen`
--

/*!50001 DROP TABLE IF EXISTS `OpenNCOIBestellingen`*/;
/*!50001 DROP VIEW IF EXISTS `OpenNCOIBestellingen`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `OpenNCOIBestellingen` AS select `A`.`CbBestellingId` AS `CbBestellingId`,`A`.`CbRegelId` AS `CbRegelId`,`A`.`Ean` AS `Ean`,`A`.`Aantal` AS `Aantal`,`A`.`OpenAantal` AS `OpenAantal`,`A`.`Referentie` AS `Referentie`,`A`.`IsBesteld` AS `IsBesteld`,`B`.`Leveringswijze` AS `Leveringswijze`,`B`.`DTBestelling` AS `DTBestelling`,`B`.`DTGeplaatst` AS `DTGeplaatst` from (`OrderRegels` `A` join `Bestellingen` `B` on((`A`.`CbBestellingId` = `B`.`CbBestellingId`))) where ((`B`.`VoorNCOI` = 1) and (`A`.`IsAfgesloten` = 0) and (`A`.`IsGeannuleerd` = 0) and (`B`.`IsGeannuleerd` = 0) and (`A`.`OpenAantal` > 0)) */;

--
-- Current Database: `CbBoeken`
--

USE `CbBoeken`;

--
-- Final view structure for view `ActueleVoorraad`
--

/*!50001 DROP TABLE IF EXISTS `ActueleVoorraad`*/;
/*!50001 DROP VIEW IF EXISTS `ActueleVoorraad`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `ActueleVoorraad` AS (select `Voorraad`.`Ean` AS `Ean`,`Voorraad`.`Voorraad` AS `Voorraad`,`Voorraad`.`MainpressMutatie` AS `MainpressMutatie`,(`Voorraad`.`Voorraad` + `Voorraad`.`MainpressMutatie`) AS `BeschikbareCBVoorraad` from `Voorraad` where (`Voorraad`.`LaatsteMutatie` = 1)) */;

--
-- Final view structure for view `Boek_met_auteur`
--

/*!50001 DROP TABLE IF EXISTS `Boek_met_auteur`*/;
/*!50001 DROP VIEW IF EXISTS `Boek_met_auteur`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`dennis`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Boek_met_auteur` AS (select `b`.`Ean` AS `Ean`,`b`.`Uitgever` AS `Uitgever`,`b`.`Uitgever_cbid` AS `Uitgever_cbid`,`b`.`Enanderen` AS `Enanderen`,`b`.`Titel` AS `Titel`,`b`.`Ondertitel` AS `Ondertitel`,`b`.`Naamserie` AS `Naamserie`,`b`.`Titelserie` AS `Titelserie`,`b`.`Reeksnummer` AS `Reeksnummer`,`b`.`Editie` AS `Editie`,`b`.`Editieversie` AS `Editieversie`,`b`.`Bindwijze` AS `Bindwijze`,`b`.`onixbindwijze` AS `onixbindwijze`,`b`.`Aantalblz` AS `Aantalblz`,`b`.`Samenvatting` AS `Samenvatting`,`b`.`Inhoudsopgave` AS `Inhoudsopgave`,`b`.`Aanmaakdatum` AS `Aanmaakdatum`,`b`.`Laatstgewijzigd` AS `Laatstgewijzigd`,`b`.`Taalvermelding` AS `Taalvermelding`,`b`.`Hoogte` AS `Hoogte`,`b`.`Breedte` AS `Breedte`,`b`.`Dikte` AS `Dikte`,`b`.`Gewicht` AS `Gewicht`,`b`.`Verschijningsdatum` AS `Verschijningsdatum`,`b`.`Herdrukdatum` AS `Herdrukdatum`,`b`.`VerwachteVerschijningsdatum` AS `VerwachteVerschijningsdatum`,`b`.`ProductAvailability` AS `ProductAvailability`,`b`.`PublishingStatus` AS `PublishingStatus`,`b`.`CBstatus` AS `CBstatus`,`b`.`Vervangt` AS `Vervangt`,`b`.`Vervangen_door` AS `Vervangen_door`,`b`.`Levertijd` AS `Levertijd`,`b`.`Fysiek_boek` AS `Fysiek_boek`,`b`.`KortingMP` AS `KortingMP`,`b`.`Boekstatus` AS `Boekstatus`,`b`.`Cover` AS `Cover`,`b`.`Backcover` AS `Backcover`,`b`.`PDF` AS `PDF`,`b`.`BestandLaatsteWijziging` AS `BestandLaatsteWijziging`,`b`.`Imprint` AS `Imprint`,`b`.`CommercieleImprint` AS `CommercieleImprint`,`b`.`Nummer_in_serie` AS `Nummer_in_serie`,`a`.`AuteurVolledigenaam` AS `Auteur`,`a`.`AuteurVoornaam` AS `AuteurVoornaam`,`a`.`AuteurTussenvoegsels` AS `AuteurTussenvoegsels`,`a`.`AuteurAchternaam` AS `AuteurAchternaam` from (`Boeken` `b` left join `BoekAuteurs` `a` on((`b`.`Ean` = `a`.`Ean`)))) */;

--
-- Final view structure for view `Boeken_ongefilterd`
--

/*!50001 DROP TABLE IF EXISTS `Boeken_ongefilterd`*/;
/*!50001 DROP VIEW IF EXISTS `Boeken_ongefilterd`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`thijs`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Boeken_ongefilterd` AS select `b`.`Ean` AS `Ean`,`b`.`Uitgever` AS `Uitgever`,`b`.`Uitgever_cbid` AS `Uitgever_cbid`,`b`.`Enanderen` AS `Enanderen`,`b`.`Titel` AS `Titel`,`b`.`Ondertitel` AS `Ondertitel`,`b`.`Naamserie` AS `Naamserie`,`b`.`Titelserie` AS `Titelserie`,`b`.`Editie` AS `Editie`,`b`.`Editieversie` AS `Editieversie`,`b`.`Bindwijze` AS `Bindwijze`,`b`.`Aantalblz` AS `Aantalblz`,`b`.`Samenvatting` AS `Samenvatting`,`b`.`Inhoudsopgave` AS `Inhoudsopgave`,`b`.`Aanmaakdatum` AS `Aanmaakdatum`,`b`.`Laatstgewijzigd` AS `Laatstgewijzigd`,if((`b`.`Taalvermelding` = 'dut'),'NL',`b`.`Taalvermelding`) AS `Taalvermelding`,year(`b`.`Verschijningsdatum`) AS `jaaruitgifte`,`b`.`Editie` AS `Druk`,`b`.`Hoogte` AS `Hoogte`,`b`.`Breedte` AS `Breedte`,`b`.`Dikte` AS `Dikte`,`b`.`Gewicht` AS `Gewicht`,`b`.`Verschijningsdatum` AS `Verschijningsdatum`,`b`.`VerwachteVerschijningsdatum` AS `verwachteVerschijningsdatum`,`b`.`PublishingStatus` AS `PublishingStatus`,`b`.`CBstatus` AS `CBstatus`,`b`.`Vervangt` AS `Vervangt`,`b`.`Vervangen_door` AS `Vervangen_door`,`P`.`Boeksoort` AS `Boeksoort`,`b`.`Levertijd` AS `Levertijd`,`b`.`Fysiek_boek` AS `fysiek_boek`,`P`.`VastePrijs` AS `VastePrijs`,`P`.`VastePrijsExBtw` AS `VastePrijsExBtw`,`P`.`AanbiedingsPrijs` AS `Aanbiedingsprijs`,`P`.`AanbiedingsPrijsExBtw` AS `AanbiedingsPrijsExBtw`,`P`.`Aanbiedingvanaf` AS `Aanbiedingvanaf`,`P`.`Aanbiedingtotenmet` AS `Aanbiedingtotenmet`,`P`.`IsAanbieding` AS `IsAanbieding`,if(`P`.`IsAanbieding`,`P`.`AanbiedingsPrijs`,`P`.`VastePrijs`) AS `HuidigeEuroPrijs`,`P`.`BTWCode` AS `BTWCode`,1 AS `Bindwijze_Inpakken`,`b`.`KortingMP` AS `KortingMP`,`b`.`Boekstatus` AS `Boekstatus`,min(`BNUR`.`NUR`) AS `Nur`,min(`NUR`.`Rubriek`) AS `Rubriek` from (((`Boeken` `b` join `DagPrijzen` `P` on((`b`.`Ean` = `P`.`Ean`))) join `BoekNUR` `BNUR` on((`b`.`Ean` = `BNUR`.`Ean`))) join `NUR` on((`BNUR`.`NUR` = `NUR`.`Nur`))) where (length(`b`.`Titel`) > 0) group by `b`.`Ean` */;

--
-- Final view structure for view `EbooksMgt`
--

/*!50001 DROP TABLE IF EXISTS `EbooksMgt`*/;
/*!50001 DROP VIEW IF EXISTS `EbooksMgt`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `EbooksMgt` AS select `B`.`DT` AS `BestellingDatum`,`Bn`.`Id` AS `Id`,`Bn`.`Auteurnaam` AS `Auteurnaam`,`Bn`.`Aantal` AS `Aantal`,`Bn`.`Prijs` AS `Prijs`,`Bn`.`Bestellingid` AS `Bestellingid`,`Bn`.`Ean` AS `Ean`,`Bn`.`Omschrijving` AS `Omschrijving`,`Bn`.`Geexporteerd` AS `Geexporteerd`,`Bn`.`KortingPercentage` AS `KortingPercentage`,`Bn`.`IsPromo` AS `IsPromo`,`Bn`.`KortingReden` AS `KortingReden`,`Bn`.`KortingMP` AS `KortingMP`,`Bn`.`KostenMP` AS `KostenMP`,`Bn`.`DTOrderregel` AS `DTOrderregel`,`Bn`.`VastePrijs` AS `VastePrijs`,`Bn`.`ActiePrijs` AS `ActiePrijs`,`Bn`.`BTWTarief` AS `BTWTarief`,`Bn`.`BTWCode` AS `BTWCode`,`Bn`.`AantalBackorder` AS `AantalBackorder`,`Bn`.`BackorderOrigineel` AS `BackorderOrigineel`,`Bn`.`BackorderReden` AS `BackorderReden`,`Bn`.`BriefCode` AS `BriefCode`,`Bn`.`DTExactExport` AS `DTExactExport`,`Bn`.`KortingBedrag` AS `KortingBedrag`,`Bn`.`KortingBedragExBtw` AS `KortingBedragExBtw`,`Bn`.`PrijsExBtwExKorting` AS `PrijsExBtwExKorting`,`Bn`.`PrijsExBtwIncKorting` AS `PrijsExBtwIncKorting`,`Bn`.`BedragExBtwExKorting` AS `BedragExBtwExKorting`,`Bn`.`BedragIncBtwExKorting` AS `BedragIncBtwExKorting`,`Bn`.`BedragIncBtwIncKorting` AS `BedragIncBtwIncKorting`,`Bn`.`BedragExBtwIncKorting` AS `BedragExBtwIncKorting`,`Bn`.`BedragBTW` AS `BedragBTW`,`Bn`.`LineNr` AS `LineNr`,`Bn`.`Geannuleerd` AS `Geannuleerd`,`Bn`.`Bijdrage` AS `Bijdrage`,`Bn`.`OmzetExBtwExKorting` AS `OmzetExBtwExKorting`,`Bn`.`OmzetExBtwIncKorting` AS `OmzetExBtwIncKorting`,`Bn`.`OmzetIncBtwExKorting` AS `OmzetIncBtwExKorting`,`Bn`.`OmzetIncBtwIncKorting` AS `OmzetIncBtwIncKorting`,`Bn`.`StatusId` AS `StatusId`,`Bn`.`FactuurId` AS `FactuurId`,`Bn`.`RegelReferentie` AS `RegelReferentie`,`Bn`.`BoekStatusBijBestelling` AS `BoekStatusBijBestelling`,`U`.`Uitgeverid` AS `UitgeverId`,`U`.`Naamuitgever` AS `NaamUitgever`,`U`.`Rapportageviacb` AS `Rapportageviacb`,`U`.`Automatisch_rapporteren` AS `Automatisch_rapporteren`,ifnull(`R`.`Verzonden`,0) AS `Verzonden`,ifnull(`R`.`Gerapporteerd`,0) AS `Gerapporteerd`,`R`.`DTRapportage` AS `DTRapportage`,`U`.`Kortingmp_e` AS `InkoopKorting`,round(((0.01 * (100 - `Bn`.`KortingMP`)) * `Bn`.`OmzetExBtwExKorting`),2) AS `InkoopPrijs`,round((((`Bn`.`Prijs` * 0.0001) * (100 - `Bn`.`KortingMP`)) / ((100 + `Bn`.`BTWTarief`) / 100)),2) AS `NettoPrijsPerStuk` from (((((`Managementboek_Boeken`.`Boeken` `B` join `Managementboek_Boeken`.`Bindwijze` `BW` on((`B`.`Bindwijze` = `BW`.`Bindwijze`))) join `Managementboek_Boeken`.`Uitgevers` `U` on((`U`.`Uitgeverid` = `B`.`Uitgever`))) join `Managementboek_Klanten`.`Bestellingen` `Bn` on((`B`.`Ean` = `Bn`.`Ean`))) join `Managementboek_Klanten`.`Bestelling` `B` on((`Bn`.`Bestellingid` = `B`.`Bestellingid`))) left join `CbBoeken`.`EbookRapportageMgt` `R` on((`Bn`.`Id` = `R`.`Id`))) where ((`B`.`DT` > '2012-12-01') and (`BW`.`Productsoort` = 'ebook ') and (`U`.`Rapportageviacb` = 1) and (`Bn`.`OmzetIncBtwIncKorting` <> 0) and (`Bn`.`Geannuleerd` = 0) and (`U`.`Uitgevers_rapportagevanaf` < `B`.`DT`)) */;

--
-- Final view structure for view `LaatsteVoorraad`
--

/*!50001 DROP TABLE IF EXISTS `LaatsteVoorraad`*/;
/*!50001 DROP VIEW IF EXISTS `LaatsteVoorraad`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `LaatsteVoorraad` AS (select `Voorraad`.`Ean` AS `Ean`,`Voorraad`.`Voorraad` AS `Voorraad`,`Voorraad`.`DTMutatie` AS `DTMutatie`,`Voorraad`.`LaatsteMutatie` AS `LaatsteMutatie`,`Voorraad`.`MainpressMutatie` AS `MainpressMutatie`,(`Voorraad`.`Voorraad` + `Voorraad`.`MainpressMutatie`) AS `BeschibareCBVoorraad` from `Voorraad` where (`Voorraad`.`LaatsteMutatie` = 1)) */;

--
-- Final view structure for view `Uitgever_mapping_met_naam`
--

/*!50001 DROP TABLE IF EXISTS `Uitgever_mapping_met_naam`*/;
/*!50001 DROP VIEW IF EXISTS `Uitgever_mapping_met_naam`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Uitgever_mapping_met_naam` AS select `U`.`Naam` AS `Naam`,`W`.`cb_id` AS `cb_id`,`W`.`Uitgeverid` AS `Uitgeverid`,`Manpo`.`Uitgevers`.`Naamuitgever` AS `Naamuitgever` from ((`CbBoeken`.`Uitgevers` `U` left join `CbBoeken`.`Uitgevers_cb_mb` `W` on((`U`.`cb_id` = `W`.`cb_id`))) left join `Manpo`.`Uitgevers` on((`W`.`Uitgeverid` = `Manpo`.`Uitgevers`.`UitgeverID`))) */;

--
-- Final view structure for view `Uitgevers_met_korting`
--

/*!50001 DROP TABLE IF EXISTS `Uitgevers_met_korting`*/;
/*!50001 DROP VIEW IF EXISTS `Uitgevers_met_korting`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Uitgevers_met_korting` AS select `M`.`Uitgeverid` AS `Uitgeverid`,`CBU`.`cb_id` AS `cb_id`,`CBU`.`Naam` AS `CBNaam`,`M`.`Naamuitgever` AS `MGTNaam`,`M`.`Kortingmp_a` AS `Kortingmp_a`,`M`.`Kortingmp_e` AS `Kortingmp_e`,`M`.`Kortingmp_o` AS `Kortingmp_o`,`M`.`Kortingmp_s` AS `Kortingmp_s`,`M`.`Kortingmp_w` AS `Kortingmp_w` from ((`CbBoeken`.`Uitgevers` `CBU` left join `CbBoeken`.`Uitgevers_cb_mb` `CB` on((`CBU`.`cb_id` = `CB`.`cb_id`))) left join `Managementboek_Boeken`.`Uitgevers` `M` on((ifnull(`CB`.`Uitgeverid`,596) = `M`.`Uitgeverid`))) */;

--
-- Final view structure for view `Union_Alle_Feeds`
--

/*!50001 DROP TABLE IF EXISTS `Union_Alle_Feeds`*/;
/*!50001 DROP VIEW IF EXISTS `Union_Alle_Feeds`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Union_Alle_Feeds` AS select `Boeken`.`Ean` AS `Ean`,`Boeken`.`Uitgever` AS `Uitgever`,`Boeken`.`Uitgever_cbid` AS `Uitgever_cbid`,`Boeken`.`Enanderen` AS `Enanderen`,`Boeken`.`Titel` AS `Titel`,`Boeken`.`Ondertitel` AS `Ondertitel`,`Boeken`.`Naamserie` AS `Naamserie`,`Boeken`.`Titelserie` AS `Titelserie`,`Boeken`.`Reeksnummer` AS `Reeksnummer`,`Boeken`.`Editie` AS `Editie`,`Boeken`.`Editieversie` AS `Editieversie`,`Boeken`.`Bindwijze` AS `Bindwijze`,`Boeken`.`onixbindwijze` AS `onixbindwijze`,`Boeken`.`Aantalblz` AS `Aantalblz`,`Boeken`.`Samenvatting` AS `Samenvatting`,`Boeken`.`Inhoudsopgave` AS `Inhoudsopgave`,`Boeken`.`Aanmaakdatum` AS `Aanmaakdatum`,`Boeken`.`Laatstgewijzigd` AS `Laatstgewijzigd`,`Boeken`.`Taalvermelding` AS `Taalvermelding`,`Boeken`.`Hoogte` AS `Hoogte`,`Boeken`.`Breedte` AS `Breedte`,`Boeken`.`Dikte` AS `Dikte`,`Boeken`.`Gewicht` AS `Gewicht`,`Boeken`.`Verschijningsdatum` AS `Verschijningsdatum`,`Boeken`.`Herdrukdatum` AS `Herdrukdatum`,`Boeken`.`VerwachteVerschijningsdatum` AS `VerwachteVerschijningsdatum`,`Boeken`.`ProductAvailability` AS `ProductAvailability`,`Boeken`.`PublishingStatus` AS `PublishingStatus`,`Boeken`.`CBstatus` AS `CBstatus`,`Boeken`.`Vervangt` AS `Vervangt`,`Boeken`.`Vervangen_door` AS `Vervangen_door`,`Boeken`.`Levertijd` AS `Levertijd`,`Boeken`.`Fysiek_boek` AS `Fysiek_boek`,`Boeken`.`KortingMP` AS `KortingMP`,`Boeken`.`Boekstatus` AS `Boekstatus`,`Boeken`.`Cover` AS `Cover`,`Boeken`.`Backcover` AS `Backcover`,`Boeken`.`PDF` AS `PDF`,`Boeken`.`BestandLaatsteWijziging` AS `BestandLaatsteWijziging`,`Boeken`.`Imprint` AS `Imprint`,`Boeken`.`CommercieleImprint` AS `CommercieleImprint`,`Boeken`.`Nummer_in_serie` AS `Nummer_in_serie`,`Boeken`.`Publicatiestatus_code` AS `Publicatiestatus_code`,`Boeken`.`CbFeedCode` AS `CbFeedCode` from `Boeken` union select `BoekenCHB`.`Ean` AS `Ean`,`BoekenCHB`.`Uitgever` AS `Uitgever`,`BoekenCHB`.`Uitgever_cbid` AS `Uitgever_cbid`,`BoekenCHB`.`Enanderen` AS `Enanderen`,`BoekenCHB`.`Titel` AS `Titel`,`BoekenCHB`.`Ondertitel` AS `Ondertitel`,`BoekenCHB`.`Naamserie` AS `Naamserie`,`BoekenCHB`.`Titelserie` AS `Titelserie`,`BoekenCHB`.`Reeksnummer` AS `Reeksnummer`,`BoekenCHB`.`Editie` AS `Editie`,`BoekenCHB`.`Editieversie` AS `Editieversie`,`BoekenCHB`.`Bindwijze` AS `Bindwijze`,`BoekenCHB`.`onixbindwijze` AS `onixbindwijze`,`BoekenCHB`.`Aantalblz` AS `Aantalblz`,`BoekenCHB`.`Samenvatting` AS `Samenvatting`,`BoekenCHB`.`Inhoudsopgave` AS `Inhoudsopgave`,`BoekenCHB`.`Aanmaakdatum` AS `Aanmaakdatum`,`BoekenCHB`.`Laatstgewijzigd` AS `Laatstgewijzigd`,`BoekenCHB`.`Taalvermelding` AS `Taalvermelding`,`BoekenCHB`.`Hoogte` AS `Hoogte`,`BoekenCHB`.`Breedte` AS `Breedte`,`BoekenCHB`.`Dikte` AS `Dikte`,`BoekenCHB`.`Gewicht` AS `Gewicht`,`BoekenCHB`.`Verschijningsdatum` AS `Verschijningsdatum`,`BoekenCHB`.`Herdrukdatum` AS `Herdrukdatum`,`BoekenCHB`.`VerwachteVerschijningsdatum` AS `VerwachteVerschijningsdatum`,`BoekenCHB`.`ProductAvailability` AS `ProductAvailability`,`BoekenCHB`.`PublishingStatus` AS `PublishingStatus`,`BoekenCHB`.`CBstatus` AS `CBstatus`,`BoekenCHB`.`Vervangt` AS `Vervangt`,`BoekenCHB`.`Vervangen_door` AS `Vervangen_door`,`BoekenCHB`.`Levertijd` AS `Levertijd`,`BoekenCHB`.`Fysiek_boek` AS `Fysiek_boek`,`BoekenCHB`.`KortingMP` AS `KortingMP`,`BoekenCHB`.`Boekstatus` AS `Boekstatus`,`BoekenCHB`.`Cover` AS `Cover`,`BoekenCHB`.`Backcover` AS `Backcover`,`BoekenCHB`.`PDF` AS `PDF`,`BoekenCHB`.`BestandLaatsteWijziging` AS `BestandLaatsteWijziging`,`BoekenCHB`.`Imprint` AS `Imprint`,`BoekenCHB`.`CommercieleImprint` AS `CommercieleImprint`,`BoekenCHB`.`Nummer_in_serie` AS `Nummer_in_serie`,`BoekenCHB`.`Publicatiestatus_code` AS `Publicatiestatus_code`,`BoekenCHB`.`CbFeedCode` AS `CbFeedCode` from `BoekenCHB` union select `BoekenCHV`.`Ean` AS `Ean`,`BoekenCHV`.`Uitgever` AS `Uitgever`,`BoekenCHV`.`Uitgever_cbid` AS `Uitgever_cbid`,`BoekenCHV`.`Enanderen` AS `Enanderen`,`BoekenCHV`.`Titel` AS `Titel`,`BoekenCHV`.`Ondertitel` AS `Ondertitel`,`BoekenCHV`.`Naamserie` AS `Naamserie`,`BoekenCHV`.`Titelserie` AS `Titelserie`,`BoekenCHV`.`Reeksnummer` AS `Reeksnummer`,`BoekenCHV`.`Editie` AS `Editie`,`BoekenCHV`.`Editieversie` AS `Editieversie`,`BoekenCHV`.`Bindwijze` AS `Bindwijze`,`BoekenCHV`.`onixbindwijze` AS `onixbindwijze`,`BoekenCHV`.`Aantalblz` AS `Aantalblz`,`BoekenCHV`.`Samenvatting` AS `Samenvatting`,`BoekenCHV`.`Inhoudsopgave` AS `Inhoudsopgave`,`BoekenCHV`.`Aanmaakdatum` AS `Aanmaakdatum`,`BoekenCHV`.`Laatstgewijzigd` AS `Laatstgewijzigd`,`BoekenCHV`.`Taalvermelding` AS `Taalvermelding`,`BoekenCHV`.`Hoogte` AS `Hoogte`,`BoekenCHV`.`Breedte` AS `Breedte`,`BoekenCHV`.`Dikte` AS `Dikte`,`BoekenCHV`.`Gewicht` AS `Gewicht`,`BoekenCHV`.`Verschijningsdatum` AS `Verschijningsdatum`,`BoekenCHV`.`Herdrukdatum` AS `Herdrukdatum`,`BoekenCHV`.`VerwachteVerschijningsdatum` AS `VerwachteVerschijningsdatum`,`BoekenCHV`.`ProductAvailability` AS `ProductAvailability`,`BoekenCHV`.`PublishingStatus` AS `PublishingStatus`,`BoekenCHV`.`CBstatus` AS `CBstatus`,`BoekenCHV`.`Vervangt` AS `Vervangt`,`BoekenCHV`.`Vervangen_door` AS `Vervangen_door`,`BoekenCHV`.`Levertijd` AS `Levertijd`,`BoekenCHV`.`Fysiek_boek` AS `Fysiek_boek`,`BoekenCHV`.`KortingMP` AS `KortingMP`,`BoekenCHV`.`Boekstatus` AS `Boekstatus`,`BoekenCHV`.`Cover` AS `Cover`,`BoekenCHV`.`Backcover` AS `Backcover`,`BoekenCHV`.`PDF` AS `PDF`,`BoekenCHV`.`BestandLaatsteWijziging` AS `BestandLaatsteWijziging`,`BoekenCHV`.`Imprint` AS `Imprint`,`BoekenCHV`.`CommercieleImprint` AS `CommercieleImprint`,`BoekenCHV`.`Nummer_in_serie` AS `Nummer_in_serie`,`BoekenCHV`.`Publicatiestatus_code` AS `Publicatiestatus_code`,`BoekenCHV`.`CbFeedCode` AS `CbFeedCode` from `BoekenCHV` */;

--
-- Final view structure for view `View_boeken_adwords`
--

/*!50001 DROP TABLE IF EXISTS `View_boeken_adwords`*/;
/*!50001 DROP VIEW IF EXISTS `View_boeken_adwords`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `View_boeken_adwords` AS (select `b`.`Ean` AS `Ean`,`b`.`Uitgever` AS `Uitgever`,`b`.`Uitgever_cbid` AS `Uitgever_cbid`,`b`.`Enanderen` AS `Enanderen`,`b`.`Titel` AS `Titel`,`b`.`Ondertitel` AS `Ondertitel`,`b`.`Naamserie` AS `Naamserie`,`b`.`Titelserie` AS `Titelserie`,`b`.`Editie` AS `Editie`,`b`.`Editieversie` AS `Editieversie`,`b`.`Bindwijze` AS `Bindwijze`,`b`.`Aantalblz` AS `Aantalblz`,`b`.`Samenvatting` AS `Samenvatting`,`b`.`Inhoudsopgave` AS `Inhoudsopgave`,`b`.`Aanmaakdatum` AS `Aanmaakdatum`,`b`.`Laatstgewijzigd` AS `Laatstgewijzigd`,if((`b`.`Taalvermelding` = 'dut'),'NL',`b`.`Taalvermelding`) AS `Taalvermelding`,year(`b`.`Verschijningsdatum`) AS `jaaruitgifte`,`b`.`Editie` AS `Druk`,`b`.`Hoogte` AS `Hoogte`,`b`.`Breedte` AS `Breedte`,`b`.`Dikte` AS `Dikte`,`b`.`Gewicht` AS `Gewicht`,`b`.`Verschijningsdatum` AS `Verschijningsdatum`,`b`.`VerwachteVerschijningsdatum` AS `verwachteVerschijningsdatum`,`b`.`PublishingStatus` AS `PublishingStatus`,`b`.`CBstatus` AS `CBstatus`,`b`.`Vervangt` AS `Vervangt`,`b`.`Vervangen_door` AS `Vervangen_door`,`P`.`Boeksoort` AS `Boeksoort`,`b`.`Levertijd` AS `Levertijd`,`b`.`Fysiek_boek` AS `fysiek_boek`,`P`.`VastePrijs` AS `VastePrijs`,`P`.`VastePrijsExBtw` AS `VastePrijsExBtw`,`P`.`AanbiedingsPrijs` AS `Aanbiedingsprijs`,`P`.`AanbiedingsPrijsExBtw` AS `AanbiedingsPrijsExBtw`,`P`.`Aanbiedingvanaf` AS `Aanbiedingvanaf`,`P`.`Aanbiedingtotenmet` AS `Aanbiedingtotenmet`,`P`.`IsAanbieding` AS `IsAanbieding`,if(`P`.`IsAanbieding`,`P`.`AanbiedingsPrijs`,`P`.`VastePrijs`) AS `HuidigeEuroPrijs`,`P`.`BTWCode` AS `BTWCode`,1 AS `Bindwijze_Inpakken`,`b`.`KortingMP` AS `KortingMP`,`b`.`Boekstatus` AS `Boekstatus`,min(`BNUR`.`NUR`) AS `Nur`,min(`NUR`.`Rubriek`) AS `Rubriek` from (((((((`Boeken` `b` join `DagPrijzen` `P` on((`b`.`Ean` = `P`.`Ean`))) join `filter_Bindwijze` on(((`b`.`Bindwijze` = `filter_Bindwijze`.`Bindwijze`) and (`filter_Bindwijze`.`viewid` = 'adwords')))) join `filter_CBstatus` on(((`b`.`CBstatus` = `filter_CBstatus`.`CBstatus`) and (`filter_CBstatus`.`viewid` = 'adwords')))) join `filter_Taalvermelding` on(((`b`.`Taalvermelding` = `filter_Taalvermelding`.`Taalvermelding`) and (`filter_Taalvermelding`.`viewid` = 'adwords')))) left join `filter_Uitgever` on(((`b`.`Uitgever_cbid` = `filter_Uitgever`.`Uitgever_cbid`) and (`filter_Uitgever`.`viewid` = 'adwords')))) join `BoekNUR` `BNUR` on((`BNUR`.`Ean` = `b`.`Ean`))) join `NUR` on((`BNUR`.`NUR` = `NUR`.`Nur`))) where ((`NUR`.`NURadwords` = 1) and (`b`.`Titel` <> '') and isnull(`filter_Uitgever`.`Uitgever_cbid`) and (`P`.`VastePrijs` > 18)) group by `b`.`Ean`) */;

--
-- Final view structure for view `View_boeken_comcol`
--

/*!50001 DROP TABLE IF EXISTS `View_boeken_comcol`*/;
/*!50001 DROP VIEW IF EXISTS `View_boeken_comcol`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`dennis`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `View_boeken_comcol` AS (select `b`.`Ean` AS `Ean`,`b`.`Uitgever` AS `Uitgever`,`b`.`Uitgever_cbid` AS `Uitgever_cbid`,`b`.`Enanderen` AS `Enanderen`,`b`.`Titel` AS `Titel`,`b`.`Ondertitel` AS `Ondertitel`,`b`.`Naamserie` AS `Naamserie`,`b`.`Titelserie` AS `Titelserie`,`b`.`Editie` AS `Editie`,`b`.`Editieversie` AS `Editieversie`,`b`.`Bindwijze` AS `Bindwijze`,`b`.`Aantalblz` AS `Aantalblz`,`b`.`Samenvatting` AS `Samenvatting`,`b`.`Inhoudsopgave` AS `Inhoudsopgave`,`b`.`Aanmaakdatum` AS `Aanmaakdatum`,`b`.`Laatstgewijzigd` AS `Laatstgewijzigd`,if((`b`.`Taalvermelding` = 'dut'),'NL',`b`.`Taalvermelding`) AS `Taalvermelding`,year(`b`.`Verschijningsdatum`) AS `jaaruitgifte`,`b`.`Editie` AS `Druk`,`b`.`Hoogte` AS `Hoogte`,`b`.`Breedte` AS `Breedte`,`b`.`Dikte` AS `Dikte`,`b`.`Gewicht` AS `Gewicht`,`b`.`Verschijningsdatum` AS `Verschijningsdatum`,`b`.`VerwachteVerschijningsdatum` AS `verwachteVerschijningsdatum`,`b`.`PublishingStatus` AS `PublishingStatus`,`b`.`CBstatus` AS `CBstatus`,`b`.`Vervangt` AS `Vervangt`,`b`.`Vervangen_door` AS `Vervangen_door`,`P`.`Boeksoort` AS `Boeksoort`,`b`.`Levertijd` AS `Levertijd`,`b`.`Fysiek_boek` AS `fysiek_boek`,`P`.`VastePrijs` AS `VastePrijs`,`P`.`VastePrijsExBtw` AS `VastePrijsExBtw`,`P`.`AanbiedingsPrijs` AS `Aanbiedingsprijs`,`P`.`AanbiedingsPrijsExBtw` AS `AanbiedingsPrijsExBtw`,`P`.`Aanbiedingvanaf` AS `Aanbiedingvanaf`,`P`.`Aanbiedingtotenmet` AS `Aanbiedingtotenmet`,`P`.`IsAanbieding` AS `IsAanbieding`,if(`P`.`IsAanbieding`,`P`.`AanbiedingsPrijs`,`P`.`VastePrijs`) AS `HuidigeEuroPrijs`,`P`.`BTWCode` AS `BTWCode`,1 AS `Bindwijze_Inpakken`,`b`.`KortingMP` AS `KortingMP`,`b`.`Boekstatus` AS `Boekstatus`,min(`BNUR`.`NUR`) AS `Nur`,min(`NUR`.`Rubriek`) AS `Rubriek` from (((((((`Boeken` `b` join `DagPrijzen` `P` on((`b`.`Ean` = `P`.`Ean`))) join `filter_Bindwijze` on(((`b`.`Bindwijze` = `filter_Bindwijze`.`Bindwijze`) and (`filter_Bindwijze`.`viewid` = 'comcol')))) join `filter_CBstatus` on(((`b`.`CBstatus` = `filter_CBstatus`.`CBstatus`) and (`filter_CBstatus`.`viewid` = 'comcol')))) join `filter_Taalvermelding` on(((`b`.`Taalvermelding` = `filter_Taalvermelding`.`Taalvermelding`) and (`filter_Taalvermelding`.`viewid` = 'comcol')))) left join `filter_Uitgever` on(((`b`.`Uitgever_cbid` = `filter_Uitgever`.`Uitgever_cbid`) and (`filter_Uitgever`.`viewid` = 'comcol')))) join `BoekNUR` `BNUR` on((`BNUR`.`Ean` = `b`.`Ean`))) join `NUR` on((`BNUR`.`NUR` = `NUR`.`Nur`))) where ((`NUR`.`NURcomcol` = 1) and (`b`.`Titel` <> '') and isnull(`filter_Uitgever`.`Uitgever_cbid`) and (`P`.`VastePrijs` > 18)) group by `b`.`Ean`) */;

--
-- Final view structure for view `View_boeken_gefilterd`
--

/*!50001 DROP TABLE IF EXISTS `View_boeken_gefilterd`*/;
/*!50001 DROP VIEW IF EXISTS `View_boeken_gefilterd`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `View_boeken_gefilterd` AS (select `b`.`Ean` AS `Ean`,`b`.`Uitgever` AS `Uitgever`,`b`.`Uitgever_cbid` AS `Uitgever_cbid`,`b`.`Enanderen` AS `Enanderen`,`b`.`Titel` AS `Titel`,`b`.`Ondertitel` AS `Ondertitel`,`b`.`Naamserie` AS `Naamserie`,`b`.`Titelserie` AS `Titelserie`,`b`.`Editie` AS `Editie`,`b`.`Editieversie` AS `Editieversie`,`b`.`Bindwijze` AS `Bindwijze`,`b`.`Aantalblz` AS `Aantalblz`,`b`.`Samenvatting` AS `Samenvatting`,`b`.`Inhoudsopgave` AS `Inhoudsopgave`,`b`.`Aanmaakdatum` AS `Aanmaakdatum`,`b`.`Laatstgewijzigd` AS `Laatstgewijzigd`,if((`b`.`Taalvermelding` = 'dut'),'NL',`b`.`Taalvermelding`) AS `Taalvermelding`,year(`b`.`Verschijningsdatum`) AS `jaaruitgifte`,`b`.`Editie` AS `Druk`,`b`.`Hoogte` AS `Hoogte`,`b`.`Breedte` AS `Breedte`,`b`.`Dikte` AS `Dikte`,`b`.`Gewicht` AS `Gewicht`,`b`.`Verschijningsdatum` AS `Verschijningsdatum`,`b`.`VerwachteVerschijningsdatum` AS `verwachteVerschijningsdatum`,`b`.`PublishingStatus` AS `PublishingStatus`,`b`.`CBstatus` AS `CBstatus`,`b`.`Vervangt` AS `Vervangt`,`b`.`Vervangen_door` AS `Vervangen_door`,`P`.`Boeksoort` AS `Boeksoort`,`b`.`Levertijd` AS `Levertijd`,`b`.`Fysiek_boek` AS `fysiek_boek`,`P`.`VastePrijs` AS `VastePrijs`,`P`.`VastePrijsExBtw` AS `VastePrijsExBtw`,`P`.`AanbiedingsPrijs` AS `Aanbiedingsprijs`,`P`.`AanbiedingsPrijsExBtw` AS `AanbiedingsPrijsExBtw`,`P`.`Aanbiedingvanaf` AS `Aanbiedingvanaf`,`P`.`Aanbiedingtotenmet` AS `Aanbiedingtotenmet`,`P`.`IsAanbieding` AS `IsAanbieding`,if(`P`.`IsAanbieding`,`P`.`AanbiedingsPrijs`,`P`.`VastePrijs`) AS `HuidigeEuroPrijs`,`P`.`BTWCode` AS `BTWCode`,1 AS `Bindwijze_Inpakken`,`b`.`KortingMP` AS `KortingMP`,`b`.`Boekstatus` AS `Boekstatus`,min(`BNUR`.`NUR`) AS `Nur`,min(`NUR`.`Rubriek`) AS `Rubriek`,`b`.`CommercieleImprint` AS `CommercieleImprint`,`b`.`Nummer_in_serie` AS `Nummer_in_serie` from (((((((`Boeken` `b` join `DagPrijzen` `P` on((`b`.`Ean` = `P`.`Ean`))) join `filter_Bindwijze` on(((`b`.`Bindwijze` = `filter_Bindwijze`.`Bindwijze`) and (`filter_Bindwijze`.`viewid` = 'solr')))) join `filter_CBstatus` on(((`b`.`CBstatus` = `filter_CBstatus`.`CBstatus`) and (`filter_CBstatus`.`viewid` = 'solr')))) join `filter_Taalvermelding` on(((`b`.`Taalvermelding` = `filter_Taalvermelding`.`Taalvermelding`) and (`filter_Taalvermelding`.`viewid` = 'solr')))) left join `filter_Uitgever` on(((`b`.`Uitgever_cbid` = `filter_Uitgever`.`Uitgever_cbid`) and (`filter_Uitgever`.`viewid` = 'solr')))) join `BoekNUR` `BNUR` on((`BNUR`.`Ean` = `b`.`Ean`))) join `NUR` on((`BNUR`.`NUR` = `NUR`.`Nur`))) where ((`NUR`.`NURtonen` = 1) and (`b`.`Titel` <> '') and isnull(`filter_Uitgever`.`Uitgever_cbid`)) group by `b`.`Ean`) */;

--
-- Final view structure for view `View_boeken_verlanglijst`
--

/*!50001 DROP TABLE IF EXISTS `View_boeken_verlanglijst`*/;
/*!50001 DROP VIEW IF EXISTS `View_boeken_verlanglijst`*/;
/*!50001 CREATE ALGORITHM=TEMPTABLE */
/*!50013 DEFINER=`thijs`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `View_boeken_verlanglijst` AS (select `b`.`Ean` AS `Ean`,`b`.`Uitgever` AS `Uitgever`,`b`.`Uitgever_cbid` AS `Uitgever_cbid`,`b`.`Enanderen` AS `Enanderen`,`b`.`Titel` AS `Titel`,`b`.`Ondertitel` AS `Ondertitel`,`b`.`Naamserie` AS `Naamserie`,`b`.`Titelserie` AS `Titelserie`,`b`.`Editie` AS `Editie`,`b`.`Editieversie` AS `Editieversie`,`b`.`Bindwijze` AS `Bindwijze`,`b`.`Aantalblz` AS `Aantalblz`,`b`.`Samenvatting` AS `Samenvatting`,`b`.`Inhoudsopgave` AS `Inhoudsopgave`,`b`.`Aanmaakdatum` AS `Aanmaakdatum`,`b`.`Laatstgewijzigd` AS `Laatstgewijzigd`,if((`b`.`Taalvermelding` = 'dut'),'NL',`b`.`Taalvermelding`) AS `Taalvermelding`,year(`b`.`Verschijningsdatum`) AS `jaaruitgifte`,`b`.`Editie` AS `Druk`,`b`.`Hoogte` AS `Hoogte`,`b`.`Breedte` AS `Breedte`,`b`.`Dikte` AS `Dikte`,`b`.`Gewicht` AS `Gewicht`,`b`.`Verschijningsdatum` AS `Verschijningsdatum`,`b`.`VerwachteVerschijningsdatum` AS `verwachteVerschijningsdatum`,`b`.`PublishingStatus` AS `Publishingstatus`,`b`.`CBstatus` AS `CBstatus`,`b`.`Vervangt` AS `Vervangt`,`b`.`Vervangen_door` AS `Vervangen_door`,`P`.`Boeksoort` AS `Boeksoort`,`b`.`Levertijd` AS `Levertijd`,`b`.`Fysiek_boek` AS `fysiek_boek`,`P`.`VastePrijs` AS `VastePrijs`,`P`.`VastePrijsExBtw` AS `VastePrijsExBtw`,`P`.`AanbiedingsPrijs` AS `Aanbiedingsprijs`,`P`.`AanbiedingsPrijsExBtw` AS `AanbiedingsPrijsExBtw`,`P`.`Aanbiedingvanaf` AS `Aanbiedingvanaf`,`P`.`Aanbiedingtotenmet` AS `Aanbiedingtotenmet`,`P`.`IsAanbieding` AS `IsAanbieding`,if(`P`.`IsAanbieding`,`P`.`AanbiedingsPrijs`,`P`.`VastePrijs`) AS `HuidigeEuroPrijs`,`P`.`BTWCode` AS `BTWCode`,1 AS `Bindwijze_Inpakken`,`b`.`KortingMP` AS `KortingMP`,`b`.`Boekstatus` AS `Boekstatus`,min(`BNUR`.`NUR`) AS `Nur`,min(`CbBoeken`.`NUR`.`Rubriek`) AS `Rubriek` from ((((((((`CbBoeken`.`Boeken` `b` join `CbBoeken`.`DagPrijzen` `P` on((`b`.`Ean` = `P`.`Ean`))) join `CbBoeken`.`filter_Bindwijze` on(((`b`.`Bindwijze` = `CbBoeken`.`filter_Bindwijze`.`Bindwijze`) and (`CbBoeken`.`filter_Bindwijze`.`viewid` = 'verlanglijst')))) join `CbBoeken`.`filter_CBstatus` on(((`b`.`CBstatus` = `CbBoeken`.`filter_CBstatus`.`CBstatus`) and (`CbBoeken`.`filter_CBstatus`.`viewid` = 'verlanglijst')))) join `CbBoeken`.`filter_Taalvermelding` on(((`b`.`Taalvermelding` = `CbBoeken`.`filter_Taalvermelding`.`Taalvermelding`) and (`CbBoeken`.`filter_Taalvermelding`.`viewid` = 'verlanglijst')))) join `CbBoeken`.`BoekNUR` `BNUR` on((`b`.`Ean` = `BNUR`.`Ean`))) join `CbBoeken`.`NUR` on((`BNUR`.`NUR` = `CbBoeken`.`NUR`.`Nur`))) left join `Manpo`.`Boeken` `mpo` on((`b`.`Ean` = `mpo`.`Ean`))) left join `CbBoeken`.`Verlanglijst_blacklist` `bl` on((`b`.`Ean` = `bl`.`Ean`))) where ((`b`.`Titel` <> '') and (`CbBoeken`.`NUR`.`NURverlanglijst` = 1) and isnull(`mpo`.`Ean`) and isnull(`bl`.`Ean`)) group by `b`.`Ean`) */;

--
-- Final view structure for view `View_vervangingen_niet_in_manpo`
--

/*!50001 DROP TABLE IF EXISTS `View_vervangingen_niet_in_manpo`*/;
/*!50001 DROP VIEW IF EXISTS `View_vervangingen_niet_in_manpo`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `View_vervangingen_niet_in_manpo` AS select `N`.`Ean` AS `Nieuw_Ean`,`N`.`Vervangt` AS `Oud_Ean`,`B`.`Titel` AS `Oude_titel`,`CB`.`Titel` AS `Nieuwe_titel` from ((`CbBoeken`.`VervangersNietInManpo` `N` join `Manpo`.`Boeken` `B` on((`N`.`Vervangt` = `B`.`Ean`))) join `CbBoeken`.`Boeken` `CB` on((`N`.`Ean` = `CB`.`Ean`))) */;

--
-- Current Database: `CbOne`
--

USE `CbOne`;

--
-- Final view structure for view `CBFout`
--

/*!50001 DROP TABLE IF EXISTS `CBFout`*/;
/*!50001 DROP VIEW IF EXISTS `CBFout`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `CBFout` AS select `Managementboek_Klanten`.`BestellingAll`.`Bestellingid` AS `Bestellingid`,`Managementboek_Klanten`.`BestellingAll`.`Klantid` AS `Klantid`,`Managementboek_Klanten`.`BestellingAll`.`Siteid` AS `Siteid`,`Managementboek_Klanten`.`BestellingAll`.`Opmerkingen` AS `Opmerkingen`,`Managementboek_Klanten`.`BestellingAll`.`Achternaam` AS `Achternaam`,`Managementboek_Klanten`.`BestellingAll`.`Bedrijfsnaam` AS `Bedrijfsnaam`,`Managementboek_Klanten`.`BestellingAll`.`DT` AS `DT`,`Managementboek_Klanten`.`BestellingAll`.`Afleverid` AS `Afleverid`,`Managementboek_Klanten`.`BestellingAll`.`IP` AS `IP`,`Managementboek_Klanten`.`BestellingAll`.`ProcessStatus` AS `ProcessStatus`,`Managementboek_Klanten`.`BestellingAll`.`BatchID` AS `BatchID`,`Managementboek_Klanten`.`BestellingAll`.`AffiliateId` AS `AffiliateId`,`Managementboek_Klanten`.`BestellingAll`.`ReferrerDomain` AS `ReferrerDomain`,`Managementboek_Klanten`.`BestellingAll`.`IsClubOrder` AS `IsClubOrder`,`Managementboek_Klanten`.`BestellingAll`.`Betaalmethode` AS `Betaalmethode`,`Managementboek_Klanten`.`BestellingAll`.`Rekeningnummer` AS `Rekeningnummer`,`Managementboek_Klanten`.`BestellingAll`.`Uwreferentie` AS `Uwreferentie`,`Managementboek_Klanten`.`BestellingAll`.`Afgerond` AS `Afgerond`,`Managementboek_Klanten`.`BestellingAll`.`Herinnering` AS `Herinnering`,`Managementboek_Klanten`.`BestellingAll`.`Hash` AS `Hash`,`Managementboek_Klanten`.`BestellingAll`.`MailedTracktrace` AS `MailedTracktrace`,`Managementboek_Klanten`.`BestellingAll`.`SessionId` AS `SessionId`,`Managementboek_Klanten`.`BestellingAll`.`EersteBestelling` AS `EersteBestelling`,`Managementboek_Klanten`.`BestellingAll`.`StemMailVerzonden` AS `StemMailVerzonden`,`Managementboek_Klanten`.`BestellingAll`.`DTStemMail` AS `DTStemMail`,`Managementboek_Klanten`.`BestellingAll`.`SamengevoegdMet` AS `SamengevoegdMet`,`Managementboek_Klanten`.`BestellingAll`.`Factuurid` AS `Factuurid`,`Managementboek_Klanten`.`BestellingAll`.`Gebruiker` AS `Gebruiker`,`Managementboek_Klanten`.`BestellingAll`.`OpmerkingNegeren` AS `OpmerkingNegeren`,`Managementboek_Klanten`.`BestellingAll`.`AutoClassificatie` AS `AutoClassificatie`,`Managementboek_Klanten`.`BestellingAll`.`ClassificatieRedenKort` AS `ClassificatieRedenKort`,`Managementboek_Klanten`.`BestellingAll`.`ClassificatieReden` AS `ClassificatieReden`,`Managementboek_Klanten`.`BestellingAll`.`Geexporteerd` AS `Geexporteerd`,`Managementboek_Klanten`.`BestellingAll`.`OrigineelBestellingId` AS `OrigineelBestellingId`,`Managementboek_Klanten`.`BestellingAll`.`ProspectId` AS `ProspectId`,`Managementboek_Klanten`.`BestellingAll`.`GeenPortoBerekenen` AS `GeenPortoBerekenen`,`Managementboek_Klanten`.`BestellingAll`.`IdealOpen` AS `IdealOpen`,`Managementboek_Klanten`.`BestellingAll`.`IdealTimeout` AS `IdealTimeout`,`Managementboek_Klanten`.`BestellingAll`.`BetalingsTermijn` AS `BetalingsTermijn`,`Managementboek_Klanten`.`BestellingAll`.`Geannuleerd` AS `Geannuleerd`,`Managementboek_Klanten`.`BestellingAll`.`UitBackorder` AS `UitBackorder`,`Managementboek_Klanten`.`BestellingAll`.`SiteBestelling` AS `SiteBestelling`,`Managementboek_Klanten`.`BestellingAll`.`DeelLevering` AS `DeelLevering`,`Managementboek_Klanten`.`BestellingAll`.`DTFactuur` AS `DTFactuur`,`Managementboek_Klanten`.`BestellingAll`.`DTVerval` AS `DTVerval`,`Managementboek_Klanten`.`BestellingAll`.`TeltAls` AS `TeltAls`,`Managementboek_Klanten`.`BestellingAll`.`IsOmzet` AS `IsOmzet`,`Managementboek_Klanten`.`BestellingAll`.`IsCorrectie` AS `IsCorrectie`,`Managementboek_Klanten`.`BestellingAll`.`IsCredit` AS `IsCredit`,`Managementboek_Klanten`.`BestellingAll`.`IsOpnieuw` AS `IsOpnieuw`,`Managementboek_Klanten`.`BestellingAll`.`ToonBestelling` AS `ToonBestelling`,`Managementboek_Klanten`.`BestellingAll`.`Herkomst` AS `Herkomst`,`Managementboek_Klanten`.`BestellingAll`.`VerstuurCompleteOrder` AS `VerstuurCompleteOrder`,`CBB`.`CbFoutmelding` AS `CbFoutmelding`,`CBB`.`CbTrackingCode` AS `CbTrackingCode`,`CBB`.`FoutBijCb` AS `FoutBijCb`,`CBB`.`VerzondenDoorCb` AS `VerzondenDoorCb`,`CBB`.`IsOntvangen` AS `IsOntvangen` from ((`Managementboek_Klanten`.`BestellingAll` join `CbOne`.`Bestellingen` `CBB` on((`Managementboek_Klanten`.`BestellingAll`.`Bestellingid` = `CBB`.`bestellingId`))) join `Managementboek_Klanten`.`OrderkopStatusPlat` `P` on((`Managementboek_Klanten`.`BestellingAll`.`Bestellingid` = `P`.`BestellingId`))) where ((`CBB`.`IsOntvangen` = 1) and (`CBB`.`FoutBijCb` = 1) and (`P`.`geannuleerd` = 0) and (`P`.`gecrediteerd` = 0) and (`P`.`afgesloten` = 0)) */;

--
-- Final view structure for view `CBIn`
--

/*!50001 DROP TABLE IF EXISTS `CBIn`*/;
/*!50001 DROP VIEW IF EXISTS `CBIn`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `CBIn` AS select `Managementboek_Klanten`.`BestellingAll`.`Bestellingid` AS `Bestellingid`,`Managementboek_Klanten`.`BestellingAll`.`Klantid` AS `Klantid`,`Managementboek_Klanten`.`BestellingAll`.`Siteid` AS `Siteid`,`Managementboek_Klanten`.`BestellingAll`.`Opmerkingen` AS `Opmerkingen`,`Managementboek_Klanten`.`BestellingAll`.`Achternaam` AS `Achternaam`,`Managementboek_Klanten`.`BestellingAll`.`Bedrijfsnaam` AS `Bedrijfsnaam`,`Managementboek_Klanten`.`BestellingAll`.`DT` AS `DT`,`Managementboek_Klanten`.`BestellingAll`.`Afleverid` AS `Afleverid`,`Managementboek_Klanten`.`BestellingAll`.`IP` AS `IP`,`Managementboek_Klanten`.`BestellingAll`.`ProcessStatus` AS `ProcessStatus`,`Managementboek_Klanten`.`BestellingAll`.`BatchID` AS `BatchID`,`Managementboek_Klanten`.`BestellingAll`.`AffiliateId` AS `AffiliateId`,`Managementboek_Klanten`.`BestellingAll`.`ReferrerDomain` AS `ReferrerDomain`,`Managementboek_Klanten`.`BestellingAll`.`IsClubOrder` AS `IsClubOrder`,`Managementboek_Klanten`.`BestellingAll`.`Betaalmethode` AS `Betaalmethode`,`Managementboek_Klanten`.`BestellingAll`.`Rekeningnummer` AS `Rekeningnummer`,`Managementboek_Klanten`.`BestellingAll`.`Uwreferentie` AS `Uwreferentie`,`Managementboek_Klanten`.`BestellingAll`.`Afgerond` AS `Afgerond`,`Managementboek_Klanten`.`BestellingAll`.`Herinnering` AS `Herinnering`,`Managementboek_Klanten`.`BestellingAll`.`Hash` AS `Hash`,`Managementboek_Klanten`.`BestellingAll`.`MailedTracktrace` AS `MailedTracktrace`,`Managementboek_Klanten`.`BestellingAll`.`SessionId` AS `SessionId`,`Managementboek_Klanten`.`BestellingAll`.`EersteBestelling` AS `EersteBestelling`,`Managementboek_Klanten`.`BestellingAll`.`StemMailVerzonden` AS `StemMailVerzonden`,`Managementboek_Klanten`.`BestellingAll`.`DTStemMail` AS `DTStemMail`,`Managementboek_Klanten`.`BestellingAll`.`SamengevoegdMet` AS `SamengevoegdMet`,`Managementboek_Klanten`.`BestellingAll`.`Factuurid` AS `Factuurid`,`Managementboek_Klanten`.`BestellingAll`.`Gebruiker` AS `Gebruiker`,`Managementboek_Klanten`.`BestellingAll`.`OpmerkingNegeren` AS `OpmerkingNegeren`,`Managementboek_Klanten`.`BestellingAll`.`AutoClassificatie` AS `AutoClassificatie`,`Managementboek_Klanten`.`BestellingAll`.`ClassificatieRedenKort` AS `ClassificatieRedenKort`,`Managementboek_Klanten`.`BestellingAll`.`ClassificatieReden` AS `ClassificatieReden`,`Managementboek_Klanten`.`BestellingAll`.`Geexporteerd` AS `Geexporteerd`,`Managementboek_Klanten`.`BestellingAll`.`OrigineelBestellingId` AS `OrigineelBestellingId`,`Managementboek_Klanten`.`BestellingAll`.`ProspectId` AS `ProspectId`,`Managementboek_Klanten`.`BestellingAll`.`GeenPortoBerekenen` AS `GeenPortoBerekenen`,`Managementboek_Klanten`.`BestellingAll`.`IdealOpen` AS `IdealOpen`,`Managementboek_Klanten`.`BestellingAll`.`IdealTimeout` AS `IdealTimeout`,`Managementboek_Klanten`.`BestellingAll`.`BetalingsTermijn` AS `BetalingsTermijn`,`Managementboek_Klanten`.`BestellingAll`.`Geannuleerd` AS `Geannuleerd`,`Managementboek_Klanten`.`BestellingAll`.`UitBackorder` AS `UitBackorder`,`Managementboek_Klanten`.`BestellingAll`.`SiteBestelling` AS `SiteBestelling`,`Managementboek_Klanten`.`BestellingAll`.`DeelLevering` AS `DeelLevering`,`Managementboek_Klanten`.`BestellingAll`.`DTFactuur` AS `DTFactuur`,`Managementboek_Klanten`.`BestellingAll`.`DTVerval` AS `DTVerval`,`Managementboek_Klanten`.`BestellingAll`.`TeltAls` AS `TeltAls`,`Managementboek_Klanten`.`BestellingAll`.`IsOmzet` AS `IsOmzet`,`Managementboek_Klanten`.`BestellingAll`.`IsCorrectie` AS `IsCorrectie`,`Managementboek_Klanten`.`BestellingAll`.`IsCredit` AS `IsCredit`,`Managementboek_Klanten`.`BestellingAll`.`IsOpnieuw` AS `IsOpnieuw`,`Managementboek_Klanten`.`BestellingAll`.`ToonBestelling` AS `ToonBestelling`,`Managementboek_Klanten`.`BestellingAll`.`Herkomst` AS `Herkomst`,`Managementboek_Klanten`.`BestellingAll`.`VerstuurCompleteOrder` AS `VerstuurCompleteOrder`,`CBB`.`CbFoutmelding` AS `CbFoutmelding`,`CBB`.`CbTrackingCode` AS `CbTrackingCode`,`CBB`.`FoutBijCb` AS `FoutBijCb`,`CBB`.`VerzondenDoorCb` AS `VerzondenDoorCb`,`CBB`.`IsOntvangen` AS `IsOntvangen` from ((`Managementboek_Klanten`.`BestellingAll` join `CbOne`.`Bestellingen` `CBB` on((`Managementboek_Klanten`.`BestellingAll`.`Bestellingid` = `CBB`.`bestellingId`))) join `Managementboek_Klanten`.`OrderkopStatusPlat` `P` on((`CBB`.`bestellingId` = `P`.`BestellingId`))) where ((`CBB`.`IsOntvangen` = 0) and (`P`.`geannuleerd` = 0) and (`P`.`gecrediteerd` = 0) and (`P`.`afgesloten` = 0)) */;

--
-- Final view structure for view `CBIndienen`
--

/*!50001 DROP TABLE IF EXISTS `CBIndienen`*/;
/*!50001 DROP VIEW IF EXISTS `CBIndienen`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `CBIndienen` AS select `O`.`BestellingId` AS `Bestellingid`,`A`.`DT` AS `DT`,`O`.`exact_export` AS `exact_export`,`O`.`exact_controle` AS `exact_controle`,`O`.`factuur_sturen_niet_nodig` AS `factuur_sturen_niet_nodig`,`O`.`factuur_geprint` AS `factuur_geprint`,`O`.`gefactureerd` AS `gefactureerd`,`O`.`bevestigd` AS `bevestigd`,`O`.`is_geparkeerd` AS `is_geparkeerd`,`O`.`ingepakt` AS `ingepakt`,`O`.`geannuleerd` AS `geannuleerd`,`O`.`betaald` AS `betaald`,`O`.`openstaande_post_aangemaakt` AS `openstaande_post_aangemaakt`,`O`.`afgesloten` AS `afgesloten`,`O`.`vink_open` AS `vink_open`,`O`.`niet_inpakken` AS `niet_inpakken`,`O`.`pakket_afgeleverd_volgens_postnl` AS `pakket_afgeleverd_volgens_postnl`,`O`.`voorgemeld_bij_postnl` AS `voorgemeld_bij_postnl`,`O`.`inpakbevestiging_verzonden` AS `inpakbevestiging_verzonden`,`O`.`gecrediteerd` AS `gecrediteerd`,`O`.`enquete_verstuurd` AS `enquete_verstuurd`,`O`.`enquete_ingevuld` AS `enquete_ingevuld`,`O`.`opmerking_ingevuld` AS `opmerking_ingevuld`,`O`.`opmerking_gemaild` AS `opmerking_gemaild`,`O`.`opmerking_verwerkt` AS `opmerking_verwerkt`,`O`.`contact_opnemen` AS `contact_opnemen`,`O`.`contact_opgenomen` AS `contact_opgenomen`,`O`.`enquete_opvolgen` AS `enquete_opvolgen`,`O`.`volledig_geleverd_backorder` AS `volledig_geleverd_backorder`,`O`.`in_backorder_gezet` AS `in_backorder_gezet`,`O`.`momenteel_in_backorder` AS `momenteel_in_backorder`,`O`.`leveren_via_cb` AS `leveren_via_cb`,`O`.`uitgevoerd_via_cb` AS `uitgevoerd_via_cb`,`CB`.`CbBestellingId` AS `CbBestellingId`,`CB`.`factuurId` AS `factuurId`,`CB`.`DTBestelling` AS `DTBestelling`,`CB`.`DTGeplaatst` AS `DTGeplaatst`,`CB`.`DTPoging1` AS `DTPoging1`,`CB`.`DTPoging2` AS `DTPoging2`,`CB`.`DTPoging3` AS `DTPoging3`,`CB`.`DTOntvangen` AS `DTOntvangen`,`CB`.`IsGeplaatst` AS `IsGeplaatst`,`CB`.`IsOntvangen` AS `IsOntvangen`,`CB`.`FoutBijCb` AS `FoutBijCb`,`CB`.`VerzondenDoorCb` AS `VerzondenDoorCb`,`CB`.`IsGeannuleerd` AS `IsGeannuleerd`,`CB`.`DTVerzonden` AS `DTVerzonden`,`CB`.`refmainpress` AS `refmainpress`,`CB`.`refklant` AS `refklant`,`CB`.`apartefactuur` AS `apartefactuur`,`CB`.`levertijdtype` AS `levertijdtype`,`CB`.`levervanaf` AS `levervanaf`,`CB`.`levertot` AS `levertot`,`CB`.`portorekenen` AS `portorekenen`,`CB`.`porto` AS `porto`,`CB`.`acceptgirobijvoegen` AS `acceptgirobijvoegen`,`CB`.`prijstonen` AS `prijstonen`,`CB`.`betalingskenmerk` AS `betalingskenmerk`,`CB`.`factuurapartverzenden` AS `factuurapartverzenden`,`CB`.`rekeningnummer` AS `rekeningnummer`,`CB`.`betalingsvoorwaarde` AS `betalingsvoorwaarde`,`CB`.`korting` AS `korting`,`CB`.`kortingbedrag` AS `kortingbedrag`,`CB`.`kortingomschrijving` AS `kortingomschrijving`,`CB`.`heeftbijlage` AS `heeftbijlage`,`CB`.`bijlageverzonden` AS `bijlageverzonden`,`CB`.`bijlagenaam` AS `bijlagenaam`,`CB`.`kopregel` AS `kopregel`,`CB`.`voetregel` AS `voetregel`,`CB`.`traceerbaar` AS `traceerbaar`,`CB`.`CbFoutmelding` AS `CbFoutmelding`,`CB`.`CbTrackingCode` AS `CbTrackingCode` from ((`Managementboek_Klanten`.`OrderkopStatusPlat` `O` join `Managementboek_Klanten`.`BestellingAll` `A` on((`O`.`BestellingId` = `A`.`Bestellingid`))) left join `CbOne`.`Bestellingen` `CB` on((`O`.`BestellingId` = `CB`.`bestellingId`))) where ((`O`.`leveren_via_cb` = 1) and (`O`.`afgesloten` = 0) and (`O`.`is_geparkeerd` = 0) and (`O`.`geannuleerd` = 0) and (`O`.`gefactureerd` = 0) and (ifnull(`CB`.`IsOntvangen`,0) = 0)) */;

--
-- Final view structure for view `CBOntvangen`
--

/*!50001 DROP TABLE IF EXISTS `CBOntvangen`*/;
/*!50001 DROP VIEW IF EXISTS `CBOntvangen`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `CBOntvangen` AS select `Managementboek_Klanten`.`BestellingAll`.`Bestellingid` AS `Bestellingid`,`Managementboek_Klanten`.`BestellingAll`.`Klantid` AS `Klantid`,`Managementboek_Klanten`.`BestellingAll`.`Siteid` AS `Siteid`,`Managementboek_Klanten`.`BestellingAll`.`Opmerkingen` AS `Opmerkingen`,`Managementboek_Klanten`.`BestellingAll`.`Achternaam` AS `Achternaam`,`Managementboek_Klanten`.`BestellingAll`.`Bedrijfsnaam` AS `Bedrijfsnaam`,`Managementboek_Klanten`.`BestellingAll`.`DT` AS `DT`,`Managementboek_Klanten`.`BestellingAll`.`Afleverid` AS `Afleverid`,`Managementboek_Klanten`.`BestellingAll`.`IP` AS `IP`,`Managementboek_Klanten`.`BestellingAll`.`ProcessStatus` AS `ProcessStatus`,`Managementboek_Klanten`.`BestellingAll`.`BatchID` AS `BatchID`,`Managementboek_Klanten`.`BestellingAll`.`AffiliateId` AS `AffiliateId`,`Managementboek_Klanten`.`BestellingAll`.`ReferrerDomain` AS `ReferrerDomain`,`Managementboek_Klanten`.`BestellingAll`.`IsClubOrder` AS `IsClubOrder`,`Managementboek_Klanten`.`BestellingAll`.`Betaalmethode` AS `Betaalmethode`,`Managementboek_Klanten`.`BestellingAll`.`Rekeningnummer` AS `Rekeningnummer`,`Managementboek_Klanten`.`BestellingAll`.`Uwreferentie` AS `Uwreferentie`,`Managementboek_Klanten`.`BestellingAll`.`Afgerond` AS `Afgerond`,`Managementboek_Klanten`.`BestellingAll`.`Herinnering` AS `Herinnering`,`Managementboek_Klanten`.`BestellingAll`.`Hash` AS `Hash`,`Managementboek_Klanten`.`BestellingAll`.`MailedTracktrace` AS `MailedTracktrace`,`Managementboek_Klanten`.`BestellingAll`.`SessionId` AS `SessionId`,`Managementboek_Klanten`.`BestellingAll`.`EersteBestelling` AS `EersteBestelling`,`Managementboek_Klanten`.`BestellingAll`.`StemMailVerzonden` AS `StemMailVerzonden`,`Managementboek_Klanten`.`BestellingAll`.`DTStemMail` AS `DTStemMail`,`Managementboek_Klanten`.`BestellingAll`.`SamengevoegdMet` AS `SamengevoegdMet`,`Managementboek_Klanten`.`BestellingAll`.`Factuurid` AS `Factuurid`,`Managementboek_Klanten`.`BestellingAll`.`Gebruiker` AS `Gebruiker`,`Managementboek_Klanten`.`BestellingAll`.`OpmerkingNegeren` AS `OpmerkingNegeren`,`Managementboek_Klanten`.`BestellingAll`.`AutoClassificatie` AS `AutoClassificatie`,`Managementboek_Klanten`.`BestellingAll`.`ClassificatieRedenKort` AS `ClassificatieRedenKort`,`Managementboek_Klanten`.`BestellingAll`.`ClassificatieReden` AS `ClassificatieReden`,`Managementboek_Klanten`.`BestellingAll`.`Geexporteerd` AS `Geexporteerd`,`Managementboek_Klanten`.`BestellingAll`.`OrigineelBestellingId` AS `OrigineelBestellingId`,`Managementboek_Klanten`.`BestellingAll`.`ProspectId` AS `ProspectId`,`Managementboek_Klanten`.`BestellingAll`.`GeenPortoBerekenen` AS `GeenPortoBerekenen`,`Managementboek_Klanten`.`BestellingAll`.`IdealOpen` AS `IdealOpen`,`Managementboek_Klanten`.`BestellingAll`.`IdealTimeout` AS `IdealTimeout`,`Managementboek_Klanten`.`BestellingAll`.`BetalingsTermijn` AS `BetalingsTermijn`,`Managementboek_Klanten`.`BestellingAll`.`Geannuleerd` AS `Geannuleerd`,`Managementboek_Klanten`.`BestellingAll`.`UitBackorder` AS `UitBackorder`,`Managementboek_Klanten`.`BestellingAll`.`SiteBestelling` AS `SiteBestelling`,`Managementboek_Klanten`.`BestellingAll`.`DeelLevering` AS `DeelLevering`,`Managementboek_Klanten`.`BestellingAll`.`DTFactuur` AS `DTFactuur`,`Managementboek_Klanten`.`BestellingAll`.`DTVerval` AS `DTVerval`,`Managementboek_Klanten`.`BestellingAll`.`TeltAls` AS `TeltAls`,`Managementboek_Klanten`.`BestellingAll`.`IsOmzet` AS `IsOmzet`,`Managementboek_Klanten`.`BestellingAll`.`IsCorrectie` AS `IsCorrectie`,`Managementboek_Klanten`.`BestellingAll`.`IsCredit` AS `IsCredit`,`Managementboek_Klanten`.`BestellingAll`.`IsOpnieuw` AS `IsOpnieuw`,`Managementboek_Klanten`.`BestellingAll`.`ToonBestelling` AS `ToonBestelling`,`Managementboek_Klanten`.`BestellingAll`.`Herkomst` AS `Herkomst`,`Managementboek_Klanten`.`BestellingAll`.`VerstuurCompleteOrder` AS `VerstuurCompleteOrder`,`CBB`.`CbFoutmelding` AS `CbFoutmelding`,`CBB`.`CbTrackingCode` AS `CbTrackingCode`,`CBB`.`FoutBijCb` AS `FoutBijCb`,`CBB`.`VerzondenDoorCb` AS `VerzondenDoorCb`,`CBB`.`IsOntvangen` AS `IsOntvangen` from ((`Managementboek_Klanten`.`BestellingAll` join `CbOne`.`Bestellingen` `CBB` on((`Managementboek_Klanten`.`BestellingAll`.`Bestellingid` = `CBB`.`bestellingId`))) join `Managementboek_Klanten`.`OrderkopStatusPlat` `P` on((`CBB`.`bestellingId` = `P`.`BestellingId`))) where ((`CBB`.`IsOntvangen` = 1) and (`CBB`.`VerzondenDoorCb` = 0) and (`CBB`.`FoutBijCb` = 0) and (`P`.`geannuleerd` = 0) and (`P`.`gecrediteerd` = 0) and (`P`.`afgesloten` = 0)) */;

--
-- Final view structure for view `CBVerzonden`
--

/*!50001 DROP TABLE IF EXISTS `CBVerzonden`*/;
/*!50001 DROP VIEW IF EXISTS `CBVerzonden`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `CBVerzonden` AS select `Managementboek_Klanten`.`BestellingAll`.`Bestellingid` AS `Bestellingid`,`Managementboek_Klanten`.`BestellingAll`.`Klantid` AS `Klantid`,`Managementboek_Klanten`.`BestellingAll`.`Siteid` AS `Siteid`,`Managementboek_Klanten`.`BestellingAll`.`Opmerkingen` AS `Opmerkingen`,`Managementboek_Klanten`.`BestellingAll`.`Achternaam` AS `Achternaam`,`Managementboek_Klanten`.`BestellingAll`.`Bedrijfsnaam` AS `Bedrijfsnaam`,`Managementboek_Klanten`.`BestellingAll`.`DT` AS `DT`,`Managementboek_Klanten`.`BestellingAll`.`Afleverid` AS `Afleverid`,`Managementboek_Klanten`.`BestellingAll`.`IP` AS `IP`,`Managementboek_Klanten`.`BestellingAll`.`ProcessStatus` AS `ProcessStatus`,`Managementboek_Klanten`.`BestellingAll`.`BatchID` AS `BatchID`,`Managementboek_Klanten`.`BestellingAll`.`AffiliateId` AS `AffiliateId`,`Managementboek_Klanten`.`BestellingAll`.`ReferrerDomain` AS `ReferrerDomain`,`Managementboek_Klanten`.`BestellingAll`.`IsClubOrder` AS `IsClubOrder`,`Managementboek_Klanten`.`BestellingAll`.`Betaalmethode` AS `Betaalmethode`,`Managementboek_Klanten`.`BestellingAll`.`Rekeningnummer` AS `Rekeningnummer`,`Managementboek_Klanten`.`BestellingAll`.`Uwreferentie` AS `Uwreferentie`,`Managementboek_Klanten`.`BestellingAll`.`Afgerond` AS `Afgerond`,`Managementboek_Klanten`.`BestellingAll`.`Herinnering` AS `Herinnering`,`Managementboek_Klanten`.`BestellingAll`.`Hash` AS `Hash`,`Managementboek_Klanten`.`BestellingAll`.`MailedTracktrace` AS `MailedTracktrace`,`Managementboek_Klanten`.`BestellingAll`.`SessionId` AS `SessionId`,`Managementboek_Klanten`.`BestellingAll`.`EersteBestelling` AS `EersteBestelling`,`Managementboek_Klanten`.`BestellingAll`.`StemMailVerzonden` AS `StemMailVerzonden`,`Managementboek_Klanten`.`BestellingAll`.`DTStemMail` AS `DTStemMail`,`Managementboek_Klanten`.`BestellingAll`.`SamengevoegdMet` AS `SamengevoegdMet`,`Managementboek_Klanten`.`BestellingAll`.`Factuurid` AS `Factuurid`,`Managementboek_Klanten`.`BestellingAll`.`Gebruiker` AS `Gebruiker`,`Managementboek_Klanten`.`BestellingAll`.`OpmerkingNegeren` AS `OpmerkingNegeren`,`Managementboek_Klanten`.`BestellingAll`.`AutoClassificatie` AS `AutoClassificatie`,`Managementboek_Klanten`.`BestellingAll`.`ClassificatieRedenKort` AS `ClassificatieRedenKort`,`Managementboek_Klanten`.`BestellingAll`.`ClassificatieReden` AS `ClassificatieReden`,`Managementboek_Klanten`.`BestellingAll`.`Geexporteerd` AS `Geexporteerd`,`Managementboek_Klanten`.`BestellingAll`.`OrigineelBestellingId` AS `OrigineelBestellingId`,`Managementboek_Klanten`.`BestellingAll`.`ProspectId` AS `ProspectId`,`Managementboek_Klanten`.`BestellingAll`.`GeenPortoBerekenen` AS `GeenPortoBerekenen`,`Managementboek_Klanten`.`BestellingAll`.`IdealOpen` AS `IdealOpen`,`Managementboek_Klanten`.`BestellingAll`.`IdealTimeout` AS `IdealTimeout`,`Managementboek_Klanten`.`BestellingAll`.`BetalingsTermijn` AS `BetalingsTermijn`,`Managementboek_Klanten`.`BestellingAll`.`Geannuleerd` AS `Geannuleerd`,`Managementboek_Klanten`.`BestellingAll`.`UitBackorder` AS `UitBackorder`,`Managementboek_Klanten`.`BestellingAll`.`SiteBestelling` AS `SiteBestelling`,`Managementboek_Klanten`.`BestellingAll`.`DeelLevering` AS `DeelLevering`,`Managementboek_Klanten`.`BestellingAll`.`DTFactuur` AS `DTFactuur`,`Managementboek_Klanten`.`BestellingAll`.`DTVerval` AS `DTVerval`,`Managementboek_Klanten`.`BestellingAll`.`TeltAls` AS `TeltAls`,`Managementboek_Klanten`.`BestellingAll`.`IsOmzet` AS `IsOmzet`,`Managementboek_Klanten`.`BestellingAll`.`IsCorrectie` AS `IsCorrectie`,`Managementboek_Klanten`.`BestellingAll`.`IsCredit` AS `IsCredit`,`Managementboek_Klanten`.`BestellingAll`.`IsOpnieuw` AS `IsOpnieuw`,`Managementboek_Klanten`.`BestellingAll`.`ToonBestelling` AS `ToonBestelling`,`Managementboek_Klanten`.`BestellingAll`.`Herkomst` AS `Herkomst`,`Managementboek_Klanten`.`BestellingAll`.`VerstuurCompleteOrder` AS `VerstuurCompleteOrder`,`CBB`.`CbFoutmelding` AS `CbFoutmelding`,`CBB`.`CbTrackingCode` AS `CbTrackingCode`,`CBB`.`FoutBijCb` AS `FoutBijCb`,`CBB`.`VerzondenDoorCb` AS `VerzondenDoorCb`,`CBB`.`IsOntvangen` AS `IsOntvangen` from ((`Managementboek_Klanten`.`BestellingAll` join `CbOne`.`Bestellingen` `CBB` on((`Managementboek_Klanten`.`BestellingAll`.`Bestellingid` = `CBB`.`bestellingId`))) join `Managementboek_Klanten`.`OrderkopStatusPlat` `P` on((`CBB`.`bestellingId` = `P`.`BestellingId`))) where ((`CBB`.`IsOntvangen` = 1) and (`CBB`.`VerzondenDoorCb` = 1) and (`CBB`.`FoutBijCb` = 0) and (`P`.`geannuleerd` = 0) and (`P`.`gecrediteerd` = 0) and (`P`.`afgesloten` = 0)) */;

--
-- Current Database: `Computerboek_Boeken`
--

USE `Computerboek_Boeken`;

--
-- Final view structure for view `Auteurs_met_naam`
--

/*!50001 DROP TABLE IF EXISTS `Auteurs_met_naam`*/;
/*!50001 DROP VIEW IF EXISTS `Auteurs_met_naam`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Auteurs_met_naam` AS select `Auteurs`.`Auteurid` AS `Auteurid`,convert(`Auteurs`.`Achternaam` using utf8) AS `Achternaam`,convert(`Auteurs`.`Voorletters` using utf8) AS `Voorletters`,convert(`Auteurs`.`Voorvoegsels` using utf8) AS `Voorvoegsels`,convert(`Auteurs`.`Voornaam` using utf8) AS `Voornaam`,convert(`Auteurs`.`Email` using utf8) AS `Email`,`Auteurs`.`Steltprijsopemail` AS `Steltprijsopemail`,convert(`Auteurs`.`Omschrijving` using utf8) AS `Omschrijving`,convert(`Auteurs`.`Website` using utf8) AS `Website`,`Auteurs`.`Websitelinken` AS `Websitelinken`,convert(trim(replace(concat(if((length(`Auteurs`.`Voornaam`) > 0),`Auteurs`.`Voornaam`,if((length(`Auteurs`.`Voorletters`) > 0),`Auteurs`.`Voorletters`,'')),' ',ifnull(`Auteurs`.`Voorvoegsels`,''),' ',ifnull(`Auteurs`.`Achternaam`,'Onbekend')),' ',' ')) using utf8) AS `VolledigeNaam` from `Auteurs` */;

--
-- Final view structure for view `Boeken_met_aanbiedingsprijs`
--

/*!50001 DROP TABLE IF EXISTS `Boeken_met_aanbiedingsprijs`*/;
/*!50001 DROP VIEW IF EXISTS `Boeken_met_aanbiedingsprijs`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Boeken_met_aanbiedingsprijs` AS select `Boeken`.`Ean` AS `Ean`,round(`Boeken_met_prijs`.`HuidigeEuroPrijs`,2) AS `EuroPrijs`,round(`calc_prijs`(`Boeken`.`Prijs`,`Boeken`.`Valuta`),2) AS `VastePrijs`,if((round(`Boeken_met_prijs`.`HuidigeEuroPrijs`,2) < round(`calc_prijs`(`Boeken`.`Prijs`,`Boeken`.`Valuta`),2)),round(`Boeken_met_prijs`.`HuidigeEuroPrijs`,2),0) AS `AanbiedingsPrijs` from (`Boeken` join `Boeken_met_prijs` on((`Boeken`.`Ean` = `Boeken_met_prijs`.`Ean`))) */;

--
-- Final view structure for view `Boeken_met_prijs`
--

/*!50001 DROP TABLE IF EXISTS `Boeken_met_prijs`*/;
/*!50001 DROP VIEW IF EXISTS `Boeken_met_prijs`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Boeken_met_prijs` AS select `k`.`Ean` AS `Ean`,if(((`k`.`Aanbiedingsprijs` > 0) and (curdate() >= `k`.`Aanbiedingvanaf`) and (curdate() <= if((ifnull(`k`.`Aanbiedingtotenmet`,0) = 0),curdate(),`k`.`Aanbiedingtotenmet`))),`k`.`Aanbiedingsprijs`,`calc_prijs`(`k`.`Prijs`,`k`.`Valuta`)) AS `HuidigeEuroPrijs` from `Boeken` `k` */;

--
-- Final view structure for view `RankingTop_30d_Inc_Historie`
--

/*!50001 DROP TABLE IF EXISTS `RankingTop_30d_Inc_Historie`*/;
/*!50001 DROP VIEW IF EXISTS `RankingTop_30d_Inc_Historie`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `RankingTop_30d_Inc_Historie` AS select `ORG`.`Historieovernemen` AS `Historieovernemen`,`ORG`.`Ean` AS `Ean`,min(`T`.`30d`) AS `30d` from (((`Computerboek_Boeken`.`Boeken` `ORG` join `Computerboek_Boeken`.`Boekvervangtean` `V` on((`ORG`.`Ean` = `V`.`Ean`))) join `Computerboek_Boeken`.`Boeken` `B` on((`B`.`Ean` = `V`.`Vervangtean`))) join `Computerboek_Klanten`.`Ranking_Top` `T` on((`T`.`Ean` = `B`.`Ean`))) where (((`ORG`.`Historieovernemen` = 1) and (`V`.`Ean` <> `V`.`Vervangtean`)) or (`V`.`Ean` = `V`.`Vervangtean`)) group by `ORG`.`Ean` */;

--
-- Current Database: `Computerboek_Klanten`
--

USE `Computerboek_Klanten`;

--
-- Final view structure for view `Bestelling`
--

/*!50001 DROP TABLE IF EXISTS `Bestelling`*/;
/*!50001 DROP VIEW IF EXISTS `Bestelling`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Bestelling` AS select `BestellingAll`.`Bestellingid` AS `Bestellingid`,`BestellingAll`.`Klantid` AS `Klantid`,`BestellingAll`.`Siteid` AS `Siteid`,`BestellingAll`.`Opmerkingen` AS `Opmerkingen`,`BestellingAll`.`Achternaam` AS `Achternaam`,`BestellingAll`.`Bedrijfsnaam` AS `Bedrijfsnaam`,`BestellingAll`.`DT` AS `DT`,`BestellingAll`.`Afleverid` AS `Afleverid`,`BestellingAll`.`IP` AS `IP`,`BestellingAll`.`ProcessStatus` AS `ProcessStatus`,`BestellingAll`.`BatchID` AS `BatchID`,`BestellingAll`.`AffiliateId` AS `AffiliateId`,`BestellingAll`.`ReferrerDomain` AS `ReferrerDomain`,`BestellingAll`.`IsClubOrder` AS `IsClubOrder`,`BestellingAll`.`Betaalmethode` AS `Betaalmethode`,`BestellingAll`.`Rekeningnummer` AS `Rekeningnummer`,`BestellingAll`.`Uwreferentie` AS `Uwreferentie`,`BestellingAll`.`Afgerond` AS `Afgerond`,`BestellingAll`.`Herinnering` AS `Herinnering`,`BestellingAll`.`Hash` AS `Hash`,`BestellingAll`.`MailedTracktrace` AS `MailedTracktrace`,`BestellingAll`.`SessionId` AS `SessionId`,`BestellingAll`.`EersteBestelling` AS `EersteBestelling`,`BestellingAll`.`StemMailVerzonden` AS `StemMailVerzonden`,`BestellingAll`.`DTStemMail` AS `DTStemMail`,`BestellingAll`.`SamengevoegdMet` AS `SamengevoegdMet`,`BestellingAll`.`Factuurid` AS `Factuurid`,`BestellingAll`.`Gebruiker` AS `Gebruiker`,`BestellingAll`.`OpmerkingNegeren` AS `OpmerkingNegeren`,`BestellingAll`.`AutoClassificatie` AS `AutoClassificatie`,`BestellingAll`.`ClassificatieRedenKort` AS `ClassificatieRedenKort`,`BestellingAll`.`ClassificatieReden` AS `ClassificatieReden`,`BestellingAll`.`Geexporteerd` AS `Geexporteerd`,`BestellingAll`.`OrigineelBestellingId` AS `OrigineelBestellingId`,`BestellingAll`.`ProspectId` AS `ProspectId`,`BestellingAll`.`GeenPortoBerekenen` AS `GeenPortoBerekenen`,`BestellingAll`.`IdealOpen` AS `IdealOpen`,`BestellingAll`.`IdealTimeout` AS `IdealTimeout`,`BestellingAll`.`BetalingsTermijn` AS `BetalingsTermijn`,`BestellingAll`.`Geannuleerd` AS `Geannuleerd`,`BestellingAll`.`UitBackorder` AS `UitBackorder`,`BestellingAll`.`SiteBestelling` AS `SiteBestelling`,`BestellingAll`.`DeelLevering` AS `DeelLevering`,`BestellingAll`.`DTFactuur` AS `DTFactuur`,`BestellingAll`.`DTVerval` AS `DTVerval`,`BestellingAll`.`TeltAls` AS `TeltAls`,`BestellingAll`.`IsOmzet` AS `IsOmzet`,`BestellingAll`.`IsCorrectie` AS `IsCorrectie`,`BestellingAll`.`IsCredit` AS `IsCredit`,`BestellingAll`.`IsOpnieuw` AS `IsOpnieuw`,`BestellingAll`.`ToonBestelling` AS `ToonBestelling`,`BestellingAll`.`Herkomst` AS `Herkomst`,`BestellingAll`.`VerstuurCompleteOrder` AS `VerstuurCompleteOrder` from `BestellingAll` where ((`BestellingAll`.`Afgerond` = 1) and (`BestellingAll`.`Geannuleerd` = 0)) */;

--
-- Final view structure for view `BestellingInProgress`
--

/*!50001 DROP TABLE IF EXISTS `BestellingInProgress`*/;
/*!50001 DROP VIEW IF EXISTS `BestellingInProgress`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `BestellingInProgress` AS select `BestellingAll`.`Bestellingid` AS `Bestellingid`,`BestellingAll`.`Klantid` AS `Klantid`,`BestellingAll`.`Siteid` AS `Siteid`,`BestellingAll`.`Opmerkingen` AS `Opmerkingen`,`BestellingAll`.`Achternaam` AS `Achternaam`,`BestellingAll`.`Bedrijfsnaam` AS `Bedrijfsnaam`,`BestellingAll`.`DT` AS `DT`,`BestellingAll`.`Afleverid` AS `Afleverid`,`BestellingAll`.`IP` AS `IP`,`BestellingAll`.`ProcessStatus` AS `ProcessStatus`,`BestellingAll`.`BatchID` AS `BatchID`,`BestellingAll`.`AffiliateId` AS `AffiliateId`,`BestellingAll`.`ReferrerDomain` AS `ReferrerDomain`,`BestellingAll`.`Betaalmethode` AS `Betaalmethode`,`BestellingAll`.`Rekeningnummer` AS `Rekeningnummer`,`BestellingAll`.`Uwreferentie` AS `Uwreferentie`,`BestellingAll`.`Afgerond` AS `Afgerond`,`BestellingAll`.`Herinnering` AS `Herinnering`,`BestellingAll`.`Hash` AS `Hash` from `BestellingAll` where (`BestellingAll`.`Afgerond` = 0) */;

--
-- Final view structure for view `BestellingStatusPlat`
--

/*!50001 DROP TABLE IF EXISTS `BestellingStatusPlat`*/;
/*!50001 DROP VIEW IF EXISTS `BestellingStatusPlat`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `BestellingStatusPlat` AS select `B`.`Bestellingid` AS `BestellingId`,`B`.`Klantid` AS `Klantid`,`B`.`DT` AS `DT`,if(isnull(`S5`.`BestellingId`),0,1) AS `gefactureerd`,`S5`.`DT` AS `dt_gefactureerd`,if(isnull(`S6`.`BestellingId`),0,1) AS `is_geparkeerd`,`S6`.`DT` AS `dt_is_geparkeerd`,if(isnull(`S7`.`BestellingId`),0,1) AS `factuurnummer_toegewezen`,`S7`.`DT` AS `dt_factuurnummer_toegewezen`,if(isnull(`S14`.`BestellingId`),0,1) AS `etiket_geprint`,`S14`.`DT` AS `dt_etiket_geprint`,if(isnull(`S15`.`BestellingId`),0,1) AS `ingepakt`,`S15`.`DT` AS `dt_ingepakt`,if(isnull(`S17`.`BestellingId`),0,1) AS `factuur_geprint`,`S17`.`DT` AS `dt_factuur_geprint`,if(isnull(`S18`.`BestellingId`),0,1) AS `pakketlabel_geprint`,`S18`.`DT` AS `dt_pakketlabel_geprint`,if(isnull(`S19`.`BestellingId`),0,1) AS `brieflabel_geprint`,`S19`.`DT` AS `dt_brieflabel_geprint`,if(isnull(`S20`.`BestellingId`),0,1) AS `betaald_via_ideal`,`S20`.`DT` AS `dt_betaald_via_ideal`,if(isnull(`S21`.`BestellingId`),0,1) AS `betaald`,`S21`.`DT` AS `dt_betaald`,if(isnull(`S25`.`BestellingId`),0,1) AS `in_backorder_gezet`,`S25`.`DT` AS `dt_in_backorder_gezet`,if(isnull(`S29`.`BestellingId`),0,1) AS `gecrediteerd`,`S29`.`DT` AS `dt_gecrediteerd`,if(isnull(`S30`.`BestellingId`),0,1) AS `volledig_geleverd_backorder`,`S30`.`DT` AS `dt_volledig_geleverd_backorder`,if(isnull(`S31`.`BestellingId`),0,1) AS `samengevoegd_met_eerdere_order`,`S31`.`DT` AS `dt_samengevoegd_met_eerdere_order`,if(isnull(`S32`.`BestellingId`),0,1) AS `niet_inpakken`,`S32`.`DT` AS `dt_niet_inpakken`,if(isnull(`S33`.`BestellingId`),0,1) AS `afgesloten`,`S33`.`DT` AS `dt_afgesloten`,if(isnull(`S34`.`BestellingId`),0,1) AS `factuur_per_mail_verzonden`,`S34`.`DT` AS `dt_factuur_per_mail_verzonden`,if(isnull(`S36`.`BestellingId`),0,1) AS `voorgemeld_bij_postnl`,`S36`.`DT` AS `dt_voorgemeld_bij_postnl`,if(isnull(`S37`.`BestellingId`),0,1) AS `pakket_afgeleverd_volgens_postnl`,`S37`.`DT` AS `dt_pakket_afgeleverd_volgens_postnl`,if(isnull(`S39`.`BestellingId`),0,1) AS `pakbon_geprint`,`S39`.`DT` AS `dt_pakbon_geprint`,if(isnull(`S40`.`BestellingId`),0,1) AS `uit_backorder_gehaald`,`S40`.`DT` AS `dt_uit_backorder_gehaald`,if(isnull(`S41`.`BestellingId`),0,1) AS `factuur_sturen_niet_nodig`,`S41`.`DT` AS `dt_factuur_sturen_niet_nodig`,if(isnull(`S44`.`BestellingId`),0,1) AS `wacht_op_compleet`,`S44`.`DT` AS `dt_wacht_op_compleet`,if(isnull(`S45`.`BestellingId`),0,1) AS `inpakbevestiging_verzonden`,`S45`.`DT` AS `dt_inpakbevestiging_verzonden` from (((((((((((((((((((((((((((((((`BestellingAll` `B` left join `BestellingStatus` `S5` on(((`S5`.`BestellingId` = `B`.`Bestellingid`) and (`S5`.`StatusId` = 5)))) left join `BestellingStatus` `S6` on(((`S6`.`BestellingId` = `B`.`Bestellingid`) and (`S6`.`StatusId` = 6)))) left join `BestellingStatus` `S7` on(((`S7`.`BestellingId` = `B`.`Bestellingid`) and (`S7`.`StatusId` = 7)))) left join `BestellingStatus` `S9` on(((`S9`.`BestellingId` = `B`.`Bestellingid`) and (`S9`.`StatusId` = 9)))) left join `BestellingStatus` `S10` on(((`S10`.`BestellingId` = `B`.`Bestellingid`) and (`S10`.`StatusId` = 10)))) left join `BestellingStatus` `S11` on(((`S11`.`BestellingId` = `B`.`Bestellingid`) and (`S11`.`StatusId` = 11)))) left join `BestellingStatus` `S12` on(((`S12`.`BestellingId` = `B`.`Bestellingid`) and (`S12`.`StatusId` = 12)))) left join `BestellingStatus` `S13` on(((`S13`.`BestellingId` = `B`.`Bestellingid`) and (`S13`.`StatusId` = 13)))) left join `BestellingStatus` `S14` on(((`S14`.`BestellingId` = `B`.`Bestellingid`) and (`S14`.`StatusId` = 14)))) left join `BestellingStatus` `S15` on(((`S15`.`BestellingId` = `B`.`Bestellingid`) and (`S15`.`StatusId` = 15)))) left join `BestellingStatus` `S17` on(((`S17`.`BestellingId` = `B`.`Bestellingid`) and (`S17`.`StatusId` = 17)))) left join `BestellingStatus` `S18` on(((`S18`.`BestellingId` = `B`.`Bestellingid`) and (`S18`.`StatusId` = 18)))) left join `BestellingStatus` `S19` on(((`S19`.`BestellingId` = `B`.`Bestellingid`) and (`S19`.`StatusId` = 19)))) left join `BestellingStatus` `S20` on(((`S20`.`BestellingId` = `B`.`Bestellingid`) and (`S20`.`StatusId` = 20)))) left join `BestellingStatus` `S21` on(((`S21`.`BestellingId` = `B`.`Bestellingid`) and (`S21`.`StatusId` = 21)))) left join `BestellingStatus` `S25` on(((`S25`.`BestellingId` = `B`.`Bestellingid`) and (`S25`.`StatusId` = 25)))) left join `BestellingStatus` `S29` on(((`S29`.`BestellingId` = `B`.`Bestellingid`) and (`S29`.`StatusId` = 29)))) left join `BestellingStatus` `S30` on(((`S30`.`BestellingId` = `B`.`Bestellingid`) and (`S30`.`StatusId` = 30)))) left join `BestellingStatus` `S31` on(((`S31`.`BestellingId` = `B`.`Bestellingid`) and (`S31`.`StatusId` = 31)))) left join `BestellingStatus` `S32` on(((`S32`.`BestellingId` = `B`.`Bestellingid`) and (`S32`.`StatusId` = 32)))) left join `BestellingStatus` `S33` on(((`S33`.`BestellingId` = `B`.`Bestellingid`) and (`S33`.`StatusId` = 33)))) left join `BestellingStatus` `S34` on(((`S34`.`BestellingId` = `B`.`Bestellingid`) and (`S34`.`StatusId` = 34)))) left join `BestellingStatus` `S36` on(((`S36`.`BestellingId` = `B`.`Bestellingid`) and (`S36`.`StatusId` = 36)))) left join `BestellingStatus` `S37` on(((`S37`.`BestellingId` = `B`.`Bestellingid`) and (`S37`.`StatusId` = 37)))) left join `BestellingStatus` `S39` on(((`S39`.`BestellingId` = `B`.`Bestellingid`) and (`S39`.`StatusId` = 39)))) left join `BestellingStatus` `S40` on(((`S40`.`BestellingId` = `B`.`Bestellingid`) and (`S40`.`StatusId` = 40)))) left join `BestellingStatus` `S41` on(((`S41`.`BestellingId` = `B`.`Bestellingid`) and (`S41`.`StatusId` = 41)))) left join `BestellingStatus` `S42` on(((`S42`.`BestellingId` = `B`.`Bestellingid`) and (`S42`.`StatusId` = 42)))) left join `BestellingStatus` `S43` on(((`S43`.`BestellingId` = `B`.`Bestellingid`) and (`S43`.`StatusId` = 43)))) left join `BestellingStatus` `S44` on(((`S44`.`BestellingId` = `B`.`Bestellingid`) and (`S44`.`StatusId` = 44)))) left join `BestellingStatus` `S45` on(((`S45`.`BestellingId` = `B`.`Bestellingid`) and (`S45`.`StatusId` = 45)))) */;

--
-- Final view structure for view `Bestelling_met_totaal`
--

/*!50001 DROP TABLE IF EXISTS `Bestelling_met_totaal`*/;
/*!50001 DROP VIEW IF EXISTS `Bestelling_met_totaal`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Bestelling_met_totaal` AS (select `Bestelling`.`Bestellingid` AS `Bestellingid`,`Bestelling`.`Klantid` AS `Klantid`,`Bestelling`.`Siteid` AS `Siteid`,`Bestelling`.`Opmerkingen` AS `Opmerkingen`,`Bestelling`.`Achternaam` AS `Achternaam`,`Bestelling`.`Bedrijfsnaam` AS `Bedrijfsnaam`,`Bestelling`.`DT` AS `DT`,`Bestelling`.`Afleverid` AS `Afleverid`,`Bestelling`.`IP` AS `IP`,`Bestelling`.`ProcessStatus` AS `ProcessStatus`,`Bestelling`.`BatchID` AS `BatchID`,`Bestelling`.`AffiliateId` AS `AffiliateId`,`Bestelling`.`ReferrerDomain` AS `ReferrerDomain`,`Bestelling`.`IsClubOrder` AS `IsClubOrder`,`Bestelling`.`Betaalmethode` AS `Betaalmethode`,`Bestelling`.`Rekeningnummer` AS `Rekeningnummer`,`Bestelling`.`Uwreferentie` AS `Uwreferentie`,`Bestelling`.`Afgerond` AS `Afgerond`,`Bestelling`.`Herinnering` AS `Herinnering`,`Bestelling`.`Hash` AS `Hash`,`Bestelling`.`MailedTracktrace` AS `MailedTracktrace`,`Bestelling`.`SessionId` AS `SessionId`,`Bestelling`.`EersteBestelling` AS `EersteBestelling`,`Bestelling`.`StemMailVerzonden` AS `StemMailVerzonden`,`Bestelling`.`DTStemMail` AS `DTStemMail`,`Bestelling`.`SamengevoegdMet` AS `SamengevoegdMet`,`Bestelling`.`Factuurid` AS `Factuurid`,`Bestelling`.`Gebruiker` AS `Gebruiker`,`Bestelling`.`OpmerkingNegeren` AS `OpmerkingNegeren`,`Bestelling`.`AutoClassificatie` AS `AutoClassificatie`,`Bestelling`.`ClassificatieRedenKort` AS `ClassificatieRedenKort`,`Bestelling`.`ClassificatieReden` AS `ClassificatieReden`,`Bestelling`.`Geexporteerd` AS `Geexporteerd`,`Bestelling`.`OrigineelBestellingId` AS `OrigineelBestellingId`,`Bestelling`.`ProspectId` AS `ProspectId`,`Bestelling`.`GeenPortoBerekenen` AS `GeenPortoBerekenen`,`Bestelling`.`IdealOpen` AS `IdealOpen`,`Bestelling`.`IdealTimeout` AS `IdealTimeout`,`Bestelling`.`BetalingsTermijn` AS `BetalingsTermijn`,`Bestelling`.`Geannuleerd` AS `Geannuleerd`,`Bestelling`.`Herkomst` AS `Herkomst`,`Computerboek_Klanten`.`bestelling_totaal_met_porto`(`Bestelling`.`Bestellingid`) AS `bestelling_totaal`,`Computerboek_Klanten`.`bestelling_aantal`(`Bestelling`.`Bestellingid`) AS `bestelling_aantal` from `BestellingAll` `Bestelling` where (`Bestelling`.`Afgerond` = 1)) */;

--
-- Final view structure for view `Bestellingen_met_backorders`
--

/*!50001 DROP TABLE IF EXISTS `Bestellingen_met_backorders`*/;
/*!50001 DROP VIEW IF EXISTS `Bestellingen_met_backorders`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Bestellingen_met_backorders` AS select `BO`.`Id` AS `Id`,`BO`.`Auteurnaam` AS `Auteurnaam`,`BO`.`Aantal` AS `Aantal`,`BO`.`Prijs` AS `Prijs`,`BO`.`Bestellingid` AS `Bestellingid`,`BO`.`Ean` AS `Ean`,`BO`.`Omschrijving` AS `Omschrijving`,`BO`.`Geexporteerd` AS `Geexporteerd`,`BO`.`KortingPercentage` AS `KortingPercentage`,`BO`.`IsPromo` AS `IsPromo`,`BO`.`KortingReden` AS `KortingReden`,`BO`.`KortingMP` AS `KortingMP`,`BO`.`KostenMP` AS `KostenMP`,`BO`.`DTOrderregel` AS `DTOrderregel`,`BO`.`VastePrijs` AS `VastePrijs`,`BO`.`ActiePrijs` AS `ActiePrijs`,`BO`.`BTWTarief` AS `BTWTarief`,`BO`.`BTWCode` AS `BTWCode`,`BO`.`AantalBackorder` AS `AantalBackorder`,`BO`.`BackorderOrigineel` AS `BackorderOrigineel`,`BO`.`BackorderReden` AS `BackorderReden`,`BO`.`BriefCode` AS `BriefCode`,`BO`.`DTExactExport` AS `DTExactExport`,`BO`.`KortingBedrag` AS `KortingBedrag`,`BO`.`KortingBedragExBtw` AS `KortingBedragExBtw`,`BO`.`PrijsExBtwExKorting` AS `PrijsExBtwExKorting`,`BO`.`PrijsExBtwIncKorting` AS `PrijsExBtwIncKorting`,`BO`.`BedragExBtwExKorting` AS `BedragExBtwExKorting`,`BO`.`BedragIncBtwExKorting` AS `BedragIncBtwExKorting`,`BO`.`BedragIncBtwIncKorting` AS `BedragIncBtwIncKorting`,`BO`.`BedragExBtwIncKorting` AS `BedragExBtwIncKorting`,`BO`.`BedragBTW` AS `BedragBTW`,`BO`.`LineNr` AS `LineNr`,`BO`.`Geannuleerd` AS `Geannuleerd`,ifnull(sum(`BB`.`Aantal`),0) AS `Geleverd` from (`Bestellingen` `BO` left join `Bestellingen` `BB` on(((`BB`.`BackorderOrigineel` = `BO`.`Id`) and (`BB`.`Aantal` > 0) and (`BB`.`Geannuleerd` = 0)))) where ((`BO`.`AantalBackorder` <> 0) and (`BO`.`Geannuleerd` = 0)) group by `BO`.`Id` */;

--
-- Final view structure for view `Bestellingen_met_backorders2`
--

/*!50001 DROP TABLE IF EXISTS `Bestellingen_met_backorders2`*/;
/*!50001 DROP VIEW IF EXISTS `Bestellingen_met_backorders2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Bestellingen_met_backorders2` AS select `Bestellingen`.`Id` AS `Id`,`Bestellingen`.`Auteurnaam` AS `Auteurnaam`,`Bestellingen`.`Aantal` AS `Aantal`,`Bestellingen`.`Prijs` AS `Prijs`,`Bestellingen`.`Bestellingid` AS `Bestellingid`,`Bestellingen`.`Ean` AS `Ean`,`Bestellingen`.`Omschrijving` AS `Omschrijving`,`Bestellingen`.`Geexporteerd` AS `Geexporteerd`,`Bestellingen`.`KortingPercentage` AS `KortingPercentage`,`Bestellingen`.`IsPromo` AS `IsPromo`,`Bestellingen`.`KortingReden` AS `KortingReden`,`Bestellingen`.`KortingMP` AS `KortingMP`,`Bestellingen`.`KostenMP` AS `KostenMP`,`Bestellingen`.`DTOrderregel` AS `DTOrderregel`,`Bestellingen`.`VastePrijs` AS `VastePrijs`,`Bestellingen`.`ActiePrijs` AS `ActiePrijs`,`Bestellingen`.`BTWTarief` AS `BTWTarief`,`Bestellingen`.`BTWCode` AS `BTWCode`,`Bestellingen`.`AantalBackorder` AS `AantalBackorder`,`Bestellingen`.`BackorderOrigineel` AS `BackorderOrigineel`,`Bestellingen`.`BackorderReden` AS `BackorderReden`,`Bestellingen`.`BriefCode` AS `BriefCode`,`Bestellingen`.`DTExactExport` AS `DTExactExport`,`Bestellingen`.`KortingBedrag` AS `KortingBedrag`,`Bestellingen`.`KortingBedragExBtw` AS `KortingBedragExBtw`,`Bestellingen`.`PrijsExBtwExKorting` AS `PrijsExBtwExKorting`,`Bestellingen`.`PrijsExBtwIncKorting` AS `PrijsExBtwIncKorting`,`Bestellingen`.`BedragExBtwExKorting` AS `BedragExBtwExKorting`,`Bestellingen`.`BedragIncBtwExKorting` AS `BedragIncBtwExKorting`,`Bestellingen`.`BedragIncBtwIncKorting` AS `BedragIncBtwIncKorting`,`Bestellingen`.`BedragExBtwIncKorting` AS `BedragExBtwIncKorting`,`Bestellingen`.`BedragBTW` AS `BedragBTW`,`Bestellingen`.`LineNr` AS `LineNr`,`Bestellingen`.`Geannuleerd` AS `Geannuleerd`,`Bestellingen`.`Bijdrage` AS `Bijdrage`,`Bestellingen`.`OmzetExBtwExKorting` AS `OmzetExBtwExKorting`,`Bestellingen`.`OmzetExBtwIncKorting` AS `OmzetExBtwIncKorting`,`Bestellingen`.`OmzetIncBtwExKorting` AS `OmzetIncBtwExKorting`,`Bestellingen`.`OmzetIncBtwIncKorting` AS `OmzetIncBtwIncKorting`,`Bestellingen`.`StatusId` AS `StatusId`,`Bestellingen`.`FactuurId` AS `FactuurId`,`Bestellingen`.`RegelReferentie` AS `RegelReferentie`,`Bestellingen`.`BoekStatusBijBestelling` AS `BoekStatusBijBestelling`,`orderregel_geleverd`(`Bestellingen`.`Id`) AS `Geleverd` from `Bestellingen` */;

--
-- Final view structure for view `Bestellingen_met_btwgegevens`
--

/*!50001 DROP TABLE IF EXISTS `Bestellingen_met_btwgegevens`*/;
/*!50001 DROP VIEW IF EXISTS `Bestellingen_met_btwgegevens`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Bestellingen_met_btwgegevens` AS (select `Computerboek_Klanten`.`Bestellingen`.`Id` AS `Id`,`Computerboek_Klanten`.`Bestellingen`.`Auteurnaam` AS `Auteurnaam`,`Computerboek_Klanten`.`Bestellingen`.`Aantal` AS `Aantal`,`Computerboek_Klanten`.`Bestellingen`.`Prijs` AS `Prijs`,`Computerboek_Klanten`.`Bestellingen`.`Bestellingid` AS `Bestellingid`,`Computerboek_Klanten`.`Bestellingen`.`Ean` AS `Ean`,`Computerboek_Klanten`.`Bestellingen`.`Omschrijving` AS `Omschrijving`,`Computerboek_Klanten`.`Bestellingen`.`Geexporteerd` AS `Geexporteerd`,`Computerboek_Klanten`.`Bestellingen`.`KortingPercentage` AS `KortingPercentage`,`Computerboek_Klanten`.`Bestellingen`.`IsPromo` AS `IsPromo`,`Computerboek_Klanten`.`Bestellingen`.`KortingReden` AS `KortingReden`,`Computerboek_Klanten`.`Bestellingen`.`KortingMP` AS `KortingMP`,`Computerboek_Klanten`.`Bestellingen`.`KostenMP` AS `KostenMP`,`Computerboek_Klanten`.`Bestellingen`.`DTOrderregel` AS `DTOrderregel`,`Computerboek_Klanten`.`Bestellingen`.`VastePrijs` AS `VastePrijs`,`Computerboek_Klanten`.`Bestellingen`.`ActiePrijs` AS `ActiePrijs`,`Computerboek_Klanten`.`Bestellingen`.`AantalBackorder` AS `AantalBackorder`,`Computerboek_Klanten`.`Bestellingen`.`BackorderOrigineel` AS `BackorderOrigineel`,`Computerboek_Klanten`.`Bestellingen`.`BackorderReden` AS `BackorderReden`,`Computerboek_Klanten`.`Bestellingen`.`BriefCode` AS `BriefCode`,`Computerboek_Boeken`.`Boeken`.`Btwcode` AS `BtwCode`,`Computerboek_Boeken`.`Boeken`.`Magazijnsoort` AS `Magazijnsoort`,`Computerboek_Boeken`.`Boeken`.`Magazijnlocatienummer` AS `Magazijnlocatie`,`Computerboek_Klanten`.`Bestellingen`.`BTWTarief` AS `BTWTarief`,(`Computerboek_Klanten`.`Bestellingen`.`Prijs` * `Computerboek_Klanten`.`Bestellingen`.`Aantal`) AS `SubtotaalVoorKorting`,round(((((100 - `Computerboek_Klanten`.`Bestellingen`.`KortingPercentage`) * `Computerboek_Klanten`.`Bestellingen`.`Prijs`) * `Computerboek_Klanten`.`Bestellingen`.`Aantal`) / 100),0) AS `SubtotaalNaKorting`,((`Computerboek_Klanten`.`Bestellingen`.`Prijs` * `Computerboek_Klanten`.`Bestellingen`.`Aantal`) - round(((((100 - `Computerboek_Klanten`.`Bestellingen`.`KortingPercentage`) * `Computerboek_Klanten`.`Bestellingen`.`Prijs`) * `Computerboek_Klanten`.`Bestellingen`.`Aantal`) / 100),0)) AS `Korting` from (`Computerboek_Klanten`.`Bestellingen` join `Computerboek_Boeken`.`Boeken` on((`Computerboek_Klanten`.`Bestellingen`.`Ean` = `Computerboek_Boeken`.`Boeken`.`Ean`)))) */;

--
-- Final view structure for view `Bestellingen_met_extra`
--

/*!50001 DROP TABLE IF EXISTS `Bestellingen_met_extra`*/;
/*!50001 DROP VIEW IF EXISTS `Bestellingen_met_extra`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Bestellingen_met_extra` AS select `Bestellingen`.`Id` AS `Id`,`Bestellingen`.`Auteurnaam` AS `Auteurnaam`,`Bestellingen`.`Aantal` AS `Aantal`,`Bestellingen`.`Prijs` AS `Prijs`,`Bestellingen`.`Bestellingid` AS `Bestellingid`,`Bestellingen`.`Ean` AS `Ean`,`Bestellingen`.`Omschrijving` AS `Omschrijving`,`Bestellingen`.`Geexporteerd` AS `Geexporteerd`,`Bestellingen`.`KortingPercentage` AS `KortingPercentage`,`Bestellingen`.`IsPromo` AS `IsPromo`,`Bestellingen`.`KortingReden` AS `KortingReden`,`Bestellingen`.`KortingMP` AS `KortingMP`,`Bestellingen`.`KostenMP` AS `KostenMP`,`Bestellingen`.`DTOrderregel` AS `DTOrderregel`,`Bestellingen`.`VastePrijs` AS `VastePrijs`,`Bestellingen`.`ActiePrijs` AS `ActiePrijs`,`Bestellingen`.`BTWTarief` AS `BTWTarief`,`Bestellingen`.`BTWCode` AS `BTWCode`,`Bestellingen`.`AantalBackorder` AS `AantalBackorder`,`Bestellingen`.`BackorderOrigineel` AS `BackorderOrigineel`,`Bestellingen`.`BackorderReden` AS `BackorderReden`,`Bestellingen`.`BriefCode` AS `BriefCode`,`Bestellingen`.`DTExactExport` AS `DTExactExport`,`Bestellingen`.`KortingBedrag` AS `KortingBedrag`,`Bestellingen`.`KortingBedragExBtw` AS `KortingBedragExBtw`,`Bestellingen`.`PrijsExBtwExKorting` AS `PrijsExBtwExKorting`,`Bestellingen`.`PrijsExBtwIncKorting` AS `PrijsExBtwIncKorting`,`Bestellingen`.`BedragExBtwExKorting` AS `BedragExBtwExKorting`,`Bestellingen`.`BedragIncBtwExKorting` AS `BedragIncBtwExKorting`,`Bestellingen`.`BedragIncBtwIncKorting` AS `BedragIncBtwIncKorting`,`Bestellingen`.`BedragExBtwIncKorting` AS `BedragExBtwIncKorting`,`Bestellingen`.`BedragBTW` AS `BedragBTW`,`Bestellingen`.`LineNr` AS `LineNr`,`Bestellingen`.`Geannuleerd` AS `Geannuleerd`,`Bestellingen`.`Bijdrage` AS `Bijdrage`,`Bestellingen`.`OmzetExBtwExKorting` AS `OmzetExBtwExKorting`,`Bestellingen`.`OmzetExBtwIncKorting` AS `OmzetExBtwIncKorting`,`Bestellingen`.`OmzetIncBtwExKorting` AS `OmzetIncBtwExKorting`,`Bestellingen`.`OmzetIncBtwIncKorting` AS `OmzetIncBtwIncKorting`,`Bestellingen`.`StatusId` AS `StatusId`,`Bestellingen`.`FactuurId` AS `FactuurId`,`Bestellingen`.`RegelReferentie` AS `RegelReferentie`,`Bestellingen`.`BoekStatusBijBestelling` AS `BoekStatusBijBestelling`,`BestellingenExtra`.`Tag` AS `Tag`,`BestellingenExtra`.`PrijsHerkomst` AS `PrijsHerkomst`,`BestellingenExtra`.`AangepastePrijsCode` AS `AangepastePrijsCode` from (`Bestellingen` join `BestellingenExtra` on((`Bestellingen`.`Id` = `BestellingenExtra`.`Id`))) */;

--
-- Final view structure for view `Bestellingen_met_reserveringen`
--

/*!50001 DROP TABLE IF EXISTS `Bestellingen_met_reserveringen`*/;
/*!50001 DROP VIEW IF EXISTS `Bestellingen_met_reserveringen`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Bestellingen_met_reserveringen` AS select `N`.`Id` AS `Id`,`N`.`Auteurnaam` AS `Auteurnaam`,`N`.`Aantal` AS `Aantal`,`N`.`Prijs` AS `Prijs`,`N`.`Bestellingid` AS `Bestellingid`,`N`.`Ean` AS `Ean`,`N`.`Omschrijving` AS `Omschrijving`,`N`.`Geexporteerd` AS `Geexporteerd`,`N`.`KortingPercentage` AS `KortingPercentage`,`N`.`IsPromo` AS `IsPromo`,`N`.`KortingReden` AS `KortingReden`,`N`.`KortingMP` AS `KortingMP`,`N`.`KostenMP` AS `KostenMP`,`N`.`DTOrderregel` AS `DTOrderregel`,`N`.`VastePrijs` AS `VastePrijs`,`N`.`ActiePrijs` AS `ActiePrijs`,`N`.`BTWTarief` AS `BTWTarief`,`N`.`BTWCode` AS `BTWCode`,`N`.`AantalBackorder` AS `AantalBackorder`,`N`.`BackorderOrigineel` AS `BackorderOrigineel`,`N`.`BackorderReden` AS `BackorderReden`,`N`.`BriefCode` AS `BriefCode`,`N`.`DTExactExport` AS `DTExactExport`,`N`.`KortingBedrag` AS `KortingBedrag`,`N`.`KortingBedragExBtw` AS `KortingBedragExBtw`,`N`.`PrijsExBtwExKorting` AS `PrijsExBtwExKorting`,`N`.`PrijsExBtwIncKorting` AS `PrijsExBtwIncKorting`,`N`.`BedragExBtwExKorting` AS `BedragExBtwExKorting`,`N`.`BedragIncBtwExKorting` AS `BedragIncBtwExKorting`,`N`.`BedragIncBtwIncKorting` AS `BedragIncBtwIncKorting`,`N`.`BedragExBtwIncKorting` AS `BedragExBtwIncKorting`,`N`.`BedragBTW` AS `BedragBTW`,`N`.`LineNr` AS `LineNr`,`N`.`Geannuleerd` AS `Geannuleerd`,`N`.`Bijdrage` AS `Bijdrage`,`N`.`OmzetExBtwExKorting` AS `OmzetExBtwExKorting`,`N`.`OmzetExBtwIncKorting` AS `OmzetExBtwIncKorting`,`N`.`OmzetIncBtwExKorting` AS `OmzetIncBtwExKorting`,`N`.`OmzetIncBtwIncKorting` AS `OmzetIncBtwIncKorting`,`N`.`StatusId` AS `StatusId`,`N`.`FactuurId` AS `FactuurId`,`N`.`RegelReferentie` AS `RegelReferentie`,`N`.`BoekStatusBijBestelling` AS `BoekStatusBijBestelling`,`Voorraadbeheer`.`regelReserveringen`('Computerboek',`N`.`Id`) AS `Reserveringen` from `Computerboek_Klanten`.`Bestellingen` `N` */;

--
-- Final view structure for view `Bestellingen_met_voorraad`
--

/*!50001 DROP TABLE IF EXISTS `Bestellingen_met_voorraad`*/;
/*!50001 DROP VIEW IF EXISTS `Bestellingen_met_voorraad`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Bestellingen_met_voorraad` AS select `Computerboek_Klanten`.`Bestellingen`.`Id` AS `Id`,`Computerboek_Klanten`.`Bestellingen`.`Auteurnaam` AS `Auteurnaam`,`Computerboek_Klanten`.`Bestellingen`.`Aantal` AS `Aantal`,`Computerboek_Klanten`.`Bestellingen`.`Prijs` AS `Prijs`,`Computerboek_Klanten`.`Bestellingen`.`Bestellingid` AS `Bestellingid`,`Computerboek_Klanten`.`Bestellingen`.`Ean` AS `Ean`,`Computerboek_Klanten`.`Bestellingen`.`Omschrijving` AS `Omschrijving`,`Computerboek_Klanten`.`Bestellingen`.`Geexporteerd` AS `Geexporteerd`,`Computerboek_Klanten`.`Bestellingen`.`KortingPercentage` AS `KortingPercentage`,`Computerboek_Klanten`.`Bestellingen`.`IsPromo` AS `IsPromo`,`Computerboek_Klanten`.`Bestellingen`.`KortingReden` AS `KortingReden`,`Computerboek_Klanten`.`Bestellingen`.`KortingMP` AS `KortingMP`,`Computerboek_Klanten`.`Bestellingen`.`KostenMP` AS `KostenMP`,`Computerboek_Klanten`.`Bestellingen`.`DTOrderregel` AS `DTOrderregel`,`Computerboek_Klanten`.`Bestellingen`.`VastePrijs` AS `VastePrijs`,`Computerboek_Klanten`.`Bestellingen`.`ActiePrijs` AS `ActiePrijs`,`Computerboek_Klanten`.`Bestellingen`.`BTWTarief` AS `BTWTarief`,`Computerboek_Klanten`.`Bestellingen`.`BTWCode` AS `BTWCode`,`Computerboek_Klanten`.`Bestellingen`.`AantalBackorder` AS `AantalBackorder`,`Computerboek_Klanten`.`Bestellingen`.`BackorderOrigineel` AS `BackorderOrigineel`,`Computerboek_Klanten`.`Bestellingen`.`BackorderReden` AS `BackorderReden`,`Computerboek_Klanten`.`Bestellingen`.`BriefCode` AS `BriefCode`,`Computerboek_Klanten`.`Bestellingen`.`DTExactExport` AS `DTExactExport`,`Computerboek_Klanten`.`Bestellingen`.`KortingBedrag` AS `KortingBedrag`,`Computerboek_Klanten`.`Bestellingen`.`KortingBedragExBtw` AS `KortingBedragExBtw`,`Computerboek_Klanten`.`Bestellingen`.`PrijsExBtwExKorting` AS `PrijsExBtwExKorting`,`Computerboek_Klanten`.`Bestellingen`.`PrijsExBtwIncKorting` AS `PrijsExBtwIncKorting`,`Computerboek_Klanten`.`Bestellingen`.`BedragExBtwExKorting` AS `BedragExBtwExKorting`,`Computerboek_Klanten`.`Bestellingen`.`BedragIncBtwExKorting` AS `BedragIncBtwExKorting`,`Computerboek_Klanten`.`Bestellingen`.`BedragIncBtwIncKorting` AS `BedragIncBtwIncKorting`,`Computerboek_Klanten`.`Bestellingen`.`BedragExBtwIncKorting` AS `BedragExBtwIncKorting`,`Computerboek_Klanten`.`Bestellingen`.`BedragBTW` AS `BedragBTW`,`Computerboek_Klanten`.`Bestellingen`.`LineNr` AS `LineNr`,`Computerboek_Klanten`.`Bestellingen`.`Geannuleerd` AS `Geannuleerd`,`Computerboek_Klanten`.`Bestellingen`.`Bijdrage` AS `Bijdrage`,`Computerboek_Klanten`.`Bestellingen`.`OmzetExBtwExKorting` AS `OmzetExBtwExKorting`,`Computerboek_Klanten`.`Bestellingen`.`OmzetExBtwIncKorting` AS `OmzetExBtwIncKorting`,`Computerboek_Klanten`.`Bestellingen`.`OmzetIncBtwExKorting` AS `OmzetIncBtwExKorting`,`Computerboek_Klanten`.`Bestellingen`.`OmzetIncBtwIncKorting` AS `OmzetIncBtwIncKorting`,`Computerboek_Klanten`.`Bestellingen`.`StatusId` AS `StatusId`,`Computerboek_Klanten`.`Bestellingen`.`FactuurId` AS `FactuurId`,`Computerboek_Klanten`.`Bestellingen`.`RegelReferentie` AS `RegelReferentie`,`Computerboek_Klanten`.`Bestellingen`.`BoekStatusBijBestelling` AS `BoekStatusBijBestelling`,`voorraad`(`Computerboek_Klanten`.`Bestellingen`.`Ean`) AS `voorraad`,`Voorraadbeheer`.`is_voorraadartikel`(`Computerboek_Klanten`.`Bestellingen`.`Ean`) AS `is_voorraadartikel` from `Computerboek_Klanten`.`Bestellingen` */;

--
-- Final view structure for view `Bestellingen_voor_omzet`
--

/*!50001 DROP TABLE IF EXISTS `Bestellingen_voor_omzet`*/;
/*!50001 DROP VIEW IF EXISTS `Bestellingen_voor_omzet`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Bestellingen_voor_omzet` AS select `B`.`Aantal` AS `Aantal`,`B`.`AantalBackorder` AS `AantalBackorder`,if(((`B`.`Ean` in ('porto','voucher','spoed','p')) or (`B`.`Prijs` = 0)),0,(`B`.`Aantal` + `B`.`AantalBackorder`)) AS `AantalVoorOmzet`,`A`.`Achternaam` AS `Achternaam`,`B`.`ActiePrijs` AS `ActiePrijs`,`A`.`AffiliateId` AS `AffiliateId`,`A`.`Afgerond` AS `Afgerond`,`A`.`Afleverid` AS `Afleverid`,`B`.`Auteurnaam` AS `Auteurnaam`,`A`.`AutoClassificatie` AS `AutoClassificatie`,`B`.`BackorderOrigineel` AS `BackorderOrigineel`,`B`.`BackorderReden` AS `BackorderReden`,`A`.`BatchID` AS `BatchID`,`B`.`BedragBTW` AS `BedragBTW`,`B`.`BedragExBtwExKorting` AS `BedragExBtwExKorting`,`B`.`BedragExBtwIncKorting` AS `BedragExBtwIncKorting`,`B`.`BedragIncBtwExKorting` AS `BedragIncBtwExKorting`,`B`.`BedragIncBtwIncKorting` AS `BedragIncBtwIncKorting`,`A`.`Bedrijfsnaam` AS `Bedrijfsnaam`,`H`.`BestellingHerkomst` AS `BestellingHerkomst`,`A`.`Bestellingid` AS `Bestellingid`,`A`.`Betaalmethode` AS `Betaalmethode`,`A`.`BetalingsTermijn` AS `BetalingsTermijn`,`B`.`Bijdrage` AS `Bijdrage`,`B`.`BoekStatusBijBestelling` AS `BoekStatusBijBestelling`,`B`.`BriefCode` AS `BriefCode`,`B`.`BTWCode` AS `BTWCode`,`B`.`BTWTarief` AS `BTWTarief`,`A`.`ClassificatieReden` AS `ClassificatieReden`,`A`.`ClassificatieRedenKort` AS `ClassificatieRedenKort`,`A`.`DeelLevering` AS `DeelLevering`,`A`.`DT` AS `DT`,`B`.`DTExactExport` AS `DTExactExport`,`A`.`DTFactuur` AS `DTFactuur`,`B`.`DTOrderregel` AS `DTOrderregel`,`A`.`DTStemMail` AS `DTStemMail`,`A`.`DTVerval` AS `DTVerval`,`B`.`Ean` AS `Ean`,`A`.`EersteBestelling` AS `EersteBestelling`,`B`.`FactuurId` AS `Factuurid`,`H`.`Gclid` AS `Gclid`,`B`.`Geannuleerd` AS `Geannuleerd`,`A`.`Gebruiker` AS `Gebruiker`,`A`.`GeenPortoBerekenen` AS `GeenPortoBerekenen`,`A`.`Hash` AS `Hash`,`A`.`Herinnering` AS `Herinnering`,`A`.`Herkomst` AS `Herkomst`,`B`.`Id` AS `Id`,`A`.`IdealOpen` AS `IdealOpen`,`A`.`IdealTimeout` AS `IdealTimeout`,`A`.`IP` AS `IP`,`A`.`IsClubOrder` AS `IsClubOrder`,`A`.`IsCorrectie` AS `IsCorrectie`,`A`.`IsCredit` AS `IsCredit`,`A`.`IsOmzet` AS `IsOmzet`,`A`.`IsOpnieuw` AS `IsOpnieuw`,`B`.`IsPromo` AS `IsPromo`,`H`.`Kanaal` AS `Kanaal`,`H`.`Keyword` AS `Keyword`,`A`.`Klantid` AS `Klantid`,`B`.`KortingBedrag` AS `KortingBedrag`,`B`.`KortingBedragExBtw` AS `KortingBedragExBtw`,`B`.`KortingMP` AS `KortingMP`,`B`.`KortingPercentage` AS `KortingPercentage`,`B`.`KortingReden` AS `KortingReden`,`B`.`KostenMP` AS `KostenMP`,`B`.`LineNr` AS `LineNr`,`A`.`MailedTracktrace` AS `MailedTracktrace`,`H`.`Nieuwsbriefid` AS `Nieuwsbriefid`,`B`.`Omschrijving` AS `Omschrijving`,if((`B`.`Ean` in ('porto','spoed')),0,`B`.`OmzetExBtwExKorting`) AS `OmzetExBtwExKorting`,if((`B`.`Ean` in ('porto','spoed')),0,`B`.`OmzetIncBtwExKorting`) AS `OmzetIncBtwExKorting`,if((`B`.`Ean` in ('porto','spoed')),0,`B`.`OmzetExBtwIncKorting`) AS `OmzetExBtwIncKorting`,if((`B`.`Ean` in ('porto','spoed')),0,`B`.`OmzetIncBtwIncKorting`) AS `OmzetIncBtwIncKorting`,`A`.`Opmerkingen` AS `Opmerkingen`,`A`.`OpmerkingNegeren` AS `OpmerkingNegeren`,`A`.`OrigineelBestellingId` AS `OrigineelBestellingId`,`B`.`Prijs` AS `Prijs`,`B`.`PrijsExBtwExKorting` AS `PrijsExBtwExKorting`,`B`.`PrijsExBtwIncKorting` AS `PrijsExBtwIncKorting`,`A`.`ProcessStatus` AS `ProcessStatus`,`A`.`ProspectId` AS `ProspectId`,`A`.`ReferrerDomain` AS `ReferrerDomain`,`B`.`RegelReferentie` AS `RegelReferentie`,`A`.`Rekeningnummer` AS `Rekeningnummer`,`A`.`SamengevoegdMet` AS `SamengevoegdMet`,`A`.`SessionId` AS `SessionId`,`A`.`SiteBestelling` AS `SiteBestelling`,`A`.`Siteid` AS `Siteid`,`B`.`StatusId` AS `StatusId`,`A`.`StemMailVerzonden` AS `StemMailVerzonden`,`A`.`TeltAls` AS `TeltAls`,`A`.`ToonBestelling` AS `ToonBestelling`,`A`.`UitBackorder` AS `UitBackorder`,`H`.`UserAgent` AS `UserAgent`,`A`.`Uwreferentie` AS `Uwreferentie`,`B`.`VastePrijs` AS `VastePrijs`,`A`.`VerstuurCompleteOrder` AS `VerstuurCompleteOrder` from ((`BestellingAll` `A` join `Bestellingen` `B` on((`A`.`Bestellingid` = `B`.`Bestellingid`))) join `BestellingHerkomst` `H` on((`A`.`Bestellingid` = `H`.`BestellingId`))) where ((`A`.`Afgerond` = 1) and (`A`.`UitBackorder` = 0) and (`A`.`IsCredit` = 0) and (`A`.`IsOpnieuw` = 0) and (`A`.`Geannuleerd` = 0) and (`B`.`Prijs` <> 0) and (`B`.`Geannuleerd` = 0)) */;

--
-- Final view structure for view `Bestellingen_zonder_backorders`
--

/*!50001 DROP TABLE IF EXISTS `Bestellingen_zonder_backorders`*/;
/*!50001 DROP VIEW IF EXISTS `Bestellingen_zonder_backorders`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Bestellingen_zonder_backorders` AS (select `Bestellingen`.`Id` AS `Id`,`Bestellingen`.`Auteurnaam` AS `Auteurnaam`,(`Bestellingen`.`Aantal` + `Bestellingen`.`AantalBackorder`) AS `Aantal`,`Bestellingen`.`Prijs` AS `Prijs`,`Bestellingen`.`Bestellingid` AS `Bestellingid`,`Bestellingen`.`Ean` AS `Ean`,`Bestellingen`.`Omschrijving` AS `Omschrijving`,`Bestellingen`.`Geexporteerd` AS `Geexporteerd`,`Bestellingen`.`KortingPercentage` AS `KortingPercentage`,`Bestellingen`.`IsPromo` AS `IsPromo`,`Bestellingen`.`KortingReden` AS `KortingReden`,`Bestellingen`.`KortingMP` AS `KortingMP`,`Bestellingen`.`KostenMP` AS `KostenMP`,`Bestellingen`.`DTOrderregel` AS `DTOrderregel`,`Bestellingen`.`VastePrijs` AS `VastePrijs`,`Bestellingen`.`ActiePrijs` AS `ActiePrijs`,`Bestellingen`.`BTWTarief` AS `BTWTarief`,`Bestellingen`.`BTWCode` AS `BTWCode`,`Bestellingen`.`BriefCode` AS `BriefCode`,`Bestellingen`.`DTExactExport` AS `DTExactExport`,`Bestellingen`.`KortingBedrag` AS `KortingBedrag`,`Bestellingen`.`KortingBedragExBtw` AS `KortingBedragExBtw`,`Bestellingen`.`PrijsExBtwExKorting` AS `PrijsExBtwExKorting`,`Bestellingen`.`PrijsExBtwIncKorting` AS `PrijsExBtwIncKorting`,`Bestellingen`.`BedragExBtwExKorting` AS `BedragExBtwExKorting`,`Bestellingen`.`BedragIncBtwExKorting` AS `BedragIncBtwExKorting`,if((`Bestellingen`.`BedragIncBtwIncKorting` = 0),((((`Bestellingen`.`Aantal` + `Bestellingen`.`AantalBackorder`) * `Bestellingen`.`Prijs`) / 100) - round((((((`Bestellingen`.`Aantal` + `Bestellingen`.`AantalBackorder`) * `Bestellingen`.`Prijs`) / 100) * `Bestellingen`.`KortingPercentage`) * 0.01),2)),`Bestellingen`.`BedragIncBtwIncKorting`) AS `BedragIncBtwIncKorting`,round((if((`Bestellingen`.`BedragIncBtwIncKorting` = 0),((((`Bestellingen`.`Aantal` + `Bestellingen`.`AantalBackorder`) * `Bestellingen`.`Prijs`) / 100) - round((((((`Bestellingen`.`Aantal` + `Bestellingen`.`AantalBackorder`) * `Bestellingen`.`Prijs`) / 100) * `Bestellingen`.`KortingPercentage`) * 0.01),2)),`Bestellingen`.`BedragIncBtwIncKorting`) / (1 + (0.01 * `Bestellingen`.`BTWTarief`))),2) AS `BedragExBtwIncKorting`,`Bestellingen`.`BedragBTW` AS `BedragBTW`,`Bestellingen`.`LineNr` AS `LineNr`,`Bestellingen`.`Geannuleerd` AS `Geannuleerd`,`Bestellingen`.`Bijdrage` AS `Bijdrage`,`Bestellingen`.`OmzetExBtwIncKorting` AS `OmzetExBtwIncKorting`,`Bestellingen`.`OmzetExBtwExKorting` AS `OmzetExBtwExKorting`,`Bestellingen`.`OmzetIncBtwExKorting` AS `OmzetIncBtwExKorting`,`Bestellingen`.`OmzetIncBtwIncKorting` AS `OmzetIncBtwIncKorting` from `Bestellingen` where ((`Bestellingen`.`Ean` <> 'IDEAL') and ((`Bestellingen`.`Aantal` + `Bestellingen`.`AantalBackorder`) <> 0) and (`Bestellingen`.`Geannuleerd` = 0) and ((`Bestellingen`.`BackorderOrigineel` = 0) or isnull(`Bestellingen`.`BackorderOrigineel`)))) */;

--
-- Final view structure for view `HuidigeOrderstatussen`
--

/*!50001 DROP TABLE IF EXISTS `HuidigeOrderstatussen`*/;
/*!50001 DROP VIEW IF EXISTS `HuidigeOrderstatussen`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pieter`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `HuidigeOrderstatussen` AS select `S`.`StatusId` AS `StatusId`,`S`.`BestellingId` AS `BestellingId`,`S`.`Resultaat` AS `Resultaat`,`S`.`Gebruiker` AS `Gebruiker`,`S`.`DT` AS `DT`,`SS`.`Naam` AS `Naam`,`SS`.`Omschrijving` AS `Omschrijving`,`SS`.`ToonAlsOpenOrder` AS `ToonAlsOpenOrder`,`SS`.`Volgorde` AS `Volgorde` from (`BestellingStatus` `S` left join `BestellingStatussen` `SS` on((`S`.`StatusId` = `SS`.`StatusId`))) */;

--
-- Final view structure for view `Klanten_handmatig_te_autoriseren`
--

/*!50001 DROP TABLE IF EXISTS `Klanten_handmatig_te_autoriseren`*/;
/*!50001 DROP VIEW IF EXISTS `Klanten_handmatig_te_autoriseren`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Klanten_handmatig_te_autoriseren` AS select `Klanten_met_adres`.`ExperianCheck` AS `ExperianCheck`,`Klanten_met_adres`.`Klantid` AS `Klantid`,`Klanten_met_adres`.`Wachtwoord` AS `Wachtwoord`,`Klanten_met_adres`.`Emailadres` AS `Emailadres`,`Klanten_met_adres`.`Emailadres_oud` AS `Emailadres_oud`,`Klanten_met_adres`.`Geabonneerd` AS `Geabonneerd`,`Klanten_met_adres`.`Magbestellen` AS `Magbestellen`,`Klanten_met_adres`.`Heefttoegang` AS `Heefttoegang`,`Klanten_met_adres`.`Redenontzegging` AS `Redenontzegging`,`Klanten_met_adres`.`Siteid` AS `Siteid`,`Klanten_met_adres`.`Herkomstid` AS `Herkomstid`,`Klanten_met_adres`.`Domeincheck` AS `Domeincheck`,`Klanten_met_adres`.`DTaanmaak` AS `DTaanmaak`,`Klanten_met_adres`.`DTlaatstebezoek` AS `DTlaatstebezoek`,`Klanten_met_adres`.`Aantalbezoeken` AS `Aantalbezoeken`,`Klanten_met_adres`.`Exactid` AS `Exactid`,`Klanten_met_adres`.`Winkelkarmail` AS `Winkelkarmail`,`Klanten_met_adres`.`IP` AS `IP`,`Klanten_met_adres`.`IPlaatstebezoek` AS `IPlaatstebezoek`,`Klanten_met_adres`.`Mailcode` AS `Mailcode`,`Klanten_met_adres`.`AdresStatus` AS `AdresStatus`,`Klanten_met_adres`.`DTLock` AS `DTLock`,`Klanten_met_adres`.`Bankrekening` AS `Bankrekening`,`Klanten_met_adres`.`Bankrekening_oud` AS `Bankrekening_oud`,`Klanten_met_adres`.`ReferrerDomain` AS `ReferrerDomain`,`Klanten_met_adres`.`DTGewaardeerdeKlant` AS `DTGewaardeerdeKlant`,`Klanten_met_adres`.`GeenOplichter` AS `GeenOplichter`,`Klanten_met_adres`.`BankrekeningIncasso` AS `BankrekeningIncasso`,`Klanten_met_adres`.`Adresid` AS `Adresid`,`Klanten_met_adres`.`Voornaam` AS `Voornaam`,`Klanten_met_adres`.`Voornaam_oud` AS `Voornaam_oud`,`Klanten_met_adres`.`Achternaam` AS `Achternaam`,`Klanten_met_adres`.`Achternaam_oud` AS `Achternaam_oud`,`Klanten_met_adres`.`Bedrijfsnaam` AS `Bedrijfsnaam`,`Klanten_met_adres`.`Bedrijfsnaam_oud` AS `Bedrijfsnaam_oud`,`Klanten_met_adres`.`Bedrijfsnaam2` AS `Bedrijfsnaam2`,`Klanten_met_adres`.`Afdeling` AS `Afdeling`,`Klanten_met_adres`.`Afdeling_oud` AS `Afdeling_oud`,`Klanten_met_adres`.`Functie` AS `Functie`,`Klanten_met_adres`.`Functie_oud` AS `Functie_oud`,`Klanten_met_adres`.`Adres` AS `Adres`,`Klanten_met_adres`.`Adres_oud` AS `Adres_oud`,`Klanten_met_adres`.`Postcode` AS `Postcode`,`Klanten_met_adres`.`Postcode_oud` AS `Postcode_oud`,`Klanten_met_adres`.`Plaats` AS `Plaats`,`Klanten_met_adres`.`Plaats_oud` AS `Plaats_oud`,`Klanten_met_adres`.`Telefoonnummer` AS `Telefoonnummer`,`Klanten_met_adres`.`Telefoonnummer_oud` AS `Telefoonnummer_oud`,`Klanten_met_adres`.`Faxnummer` AS `Faxnummer`,`Klanten_met_adres`.`Faxnummer_oud` AS `Faxnummer_oud`,`Klanten_met_adres`.`Geslacht` AS `Geslacht`,`Klanten_met_adres`.`Geslacht_oud` AS `Geslacht_oud`,`Klanten_met_adres`.`DTadreswijziging` AS `DTadreswijziging`,`Klanten_met_adres`.`Adrestype` AS `Adrestype`,`Klanten_met_adres`.`Straatnaam` AS `Straatnaam`,`Klanten_met_adres`.`Straatnaam_oud` AS `Straatnaam_oud`,`Klanten_met_adres`.`Huisnummer` AS `Huisnummer`,`Klanten_met_adres`.`Huisnummer_oud` AS `Huisnummer_oud`,`Klanten_met_adres`.`Huisnummertoevoeging` AS `Huisnummertoevoeging`,`Klanten_met_adres`.`Huisnummertoevoeging_oud` AS `Huisnummertoevoeging_oud`,`Klanten_met_adres`.`ExactEmailadres` AS `ExactEmailadres`,`Klanten_met_adres`.`Notities` AS `Notities`,`Klanten_met_adres`.`InExact` AS `InExact`,`Klanten_met_adres`.`AutomatischGeautoriseerd` AS `AutomatischGeautoriseerd`,`Klanten_met_adres`.`AutorisatieReden` AS `AutorisatieReden`,`Klanten_met_adres`.`AutorisatieNodig` AS `AutorisatieNodig` from `Klanten_met_adres` where ((`Klanten_met_adres`.`AutomatischGeautoriseerd` = 1) and (`Klanten_met_adres`.`InExact` = 0) and (`Klanten_met_adres`.`Mailcode` not in ('OPL','WANAFG','DRA','AUTH'))) */;

--
-- Final view structure for view `Klanten_met_adres`
--

/*!50001 DROP TABLE IF EXISTS `Klanten_met_adres`*/;
/*!50001 DROP VIEW IF EXISTS `Klanten_met_adres`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Klanten_met_adres` AS select `Klanten`.`ExperianCheck` AS `ExperianCheck`,`Klanten`.`Klantid` AS `Klantid`,`Klanten`.`Wachtwoord` AS `Wachtwoord`,`Klanten`.`Emailadres` AS `Emailadres`,`Klanten`.`Emailadres_oud` AS `Emailadres_oud`,`Klanten`.`Geabonneerd` AS `Geabonneerd`,`Klanten`.`Magbestellen` AS `Magbestellen`,`Klanten`.`Heefttoegang` AS `Heefttoegang`,`Klanten`.`Redenontzegging` AS `Redenontzegging`,`Klanten`.`Siteid` AS `Siteid`,`Klanten`.`Herkomstid` AS `Herkomstid`,`Klanten`.`Domeincheck` AS `Domeincheck`,`Klanten`.`DTaanmaak` AS `DTaanmaak`,`Klanten`.`DTlaatstebezoek` AS `DTlaatstebezoek`,`Klanten`.`Aantalbezoeken` AS `Aantalbezoeken`,`Klanten`.`Exactid` AS `Exactid`,`Klanten`.`Winkelkarmail` AS `Winkelkarmail`,`Klanten`.`IP` AS `IP`,`Klanten`.`IPlaatstebezoek` AS `IPlaatstebezoek`,`Klanten`.`Mailcode` AS `Mailcode`,`Klanten`.`AdresStatus` AS `AdresStatus`,`Klanten`.`DTLock` AS `DTLock`,`Klanten`.`Bankrekening` AS `Bankrekening`,`Klanten`.`Bankrekening_oud` AS `Bankrekening_oud`,`Klanten`.`ReferrerDomain` AS `ReferrerDomain`,`Klanten`.`DTGewaardeerdeKlant` AS `DTGewaardeerdeKlant`,`Klanten`.`GeenOplichter` AS `GeenOplichter`,`Klanten`.`BankrekeningIncasso` AS `BankrekeningIncasso`,`Adres`.`Adresid` AS `Adresid`,`Adres`.`Voornaam` AS `Voornaam`,`Adres`.`Voornaam_oud` AS `Voornaam_oud`,`Adres`.`Achternaam` AS `Achternaam`,`Adres`.`Achternaam_oud` AS `Achternaam_oud`,`Adres`.`Bedrijfsnaam` AS `Bedrijfsnaam`,`Adres`.`Bedrijfsnaam_oud` AS `Bedrijfsnaam_oud`,`Adres`.`Bedrijfsnaam2` AS `Bedrijfsnaam2`,`Adres`.`Afdeling` AS `Afdeling`,`Adres`.`Afdeling_oud` AS `Afdeling_oud`,`Adres`.`Functie` AS `Functie`,`Adres`.`Functie_oud` AS `Functie_oud`,`Adres`.`Adres` AS `Adres`,`Adres`.`Adres_oud` AS `Adres_oud`,`Adres`.`Postcode` AS `Postcode`,`Adres`.`Postcode_oud` AS `Postcode_oud`,`Adres`.`Plaats` AS `Plaats`,`Adres`.`Plaats_oud` AS `Plaats_oud`,`Adres`.`Telefoonnummer` AS `Telefoonnummer`,`Adres`.`Telefoonnummer_oud` AS `Telefoonnummer_oud`,`Adres`.`Faxnummer` AS `Faxnummer`,`Adres`.`Faxnummer_oud` AS `Faxnummer_oud`,`Adres`.`Geslacht` AS `Geslacht`,`Adres`.`Geslacht_oud` AS `Geslacht_oud`,`Adres`.`DTadreswijziging` AS `DTadreswijziging`,`Adres`.`Adrestype` AS `Adrestype`,`Adres`.`Straatnaam` AS `Straatnaam`,`Adres`.`Straatnaam_oud` AS `Straatnaam_oud`,`Adres`.`Huisnummer` AS `Huisnummer`,`Adres`.`Huisnummer_oud` AS `Huisnummer_oud`,`Adres`.`Huisnummertoevoeging` AS `Huisnummertoevoeging`,`Adres`.`Huisnummertoevoeging_oud` AS `Huisnummertoevoeging_oud`,`Adres`.`Land` AS `Land`,`Klanten`.`ExactEmailadres` AS `ExactEmailadres`,`Klanten`.`Notities` AS `Notities`,`Klanten`.`InExact` AS `InExact`,`Klanten`.`AutomatischGeautoriseerd` AS `AutomatischGeautoriseerd`,`Klanten`.`AutorisatieReden` AS `AutorisatieReden`,`Klanten`.`AutorisatieNodig` AS `AutorisatieNodig`,`Klanten`.`Betalingsconditie` AS `Betalingsconditie` from (`Klanten` left join `Adres` on((`Klanten`.`Klantid` = `Adres`.`Klantid`))) where (`Adres`.`Adrestype` = 'factuur') */;

--
-- Final view structure for view `OrderregelsViaONE`
--

/*!50001 DROP TABLE IF EXISTS `OrderregelsViaONE`*/;
/*!50001 DROP VIEW IF EXISTS `OrderregelsViaONE`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `OrderregelsViaONE` AS select `A`.`Bestellingid` AS `bestellingid`,`Bn`.`Id` AS `id`,`Bn`.`Ean` AS `ean`,ifnull(`CBU`.`Mag_ONE`,1) AS `cb_mag_one`,ifnull(`BU`.`MagONE`,1) AS `manpo_mag_one`,least(ifnull(`CBU`.`Mag_ONE`,1),ifnull(`BU`.`MagONE`,1)) AS `mag_one`,if((least(ifnull(`CBU`.`Mag_ONE`,1),ifnull(`BU`.`MagONE`,1)) and (ifnull(`BK`.`Boeken_inramsj`,0) = 0) and (`CBB`.`CBstatus` in ('Direct leverbaar','POD'))),1,0) AS `leverbaar_via_cb`,if((least(ifnull(`CBU`.`Mag_ONE`,1),ifnull(`BU`.`MagONE`,1)) and (ifnull(`BK`.`Boeken_inramsj`,0) = 0) and (`CBB`.`CBstatus` in ('Direct leverbaar','POD')) and (`CBV`.`Voorraad` >= (`Bn`.`Aantal` + `Bn`.`AantalBackorder`))),1,0) AS `leverbaar_via_cb24`,if((`V`.`FysiekeVoorraad` >= (`Bn`.`Aantal` + `Bn`.`AantalBackorder`)),1,0) AS `leverbaar_via_mgt`,if(((`V`.`FysiekeVoorraad` < (`Bn`.`Aantal` + `Bn`.`AantalBackorder`)) and (`CBV`.`Voorraad` < (`Bn`.`Aantal` + `Bn`.`AantalBackorder`)) and (`CBB`.`CBstatus` in ('Direct leverbaar','POD')) and ((`CBV`.`Voorraad` + `V`.`FysiekeVoorraad`) >= (`Bn`.`Aantal` + `Bn`.`AantalBackorder`))),1,0) AS `splitsbaar` from ((((((((`Computerboek_Klanten`.`BestellingAll` `A` join `Computerboek_Klanten`.`Bestellingen` `Bn` on((`A`.`Bestellingid` = `Bn`.`Bestellingid`))) left join `CbBoeken`.`Boeken` `CBB` on((convert(`Bn`.`Ean` using utf8) = `CBB`.`Ean`))) left join `CbBoeken`.`Uitgevers` `CBU` on((`CBB`.`Uitgever_cbid` = `CBU`.`cb_id`))) left join `Manpo`.`Boeken` `BK` on((convert(`Bn`.`Ean` using utf8) = `BK`.`Ean`))) left join `Manpo`.`Uitgevers` `BU` on((`BK`.`UitgeverID` = `BU`.`UitgeverID`))) left join `Manpo`.`Bindwijze` `BW` on((`BK`.`Bindwijze` = `BW`.`Bindwijze`))) left join `Voorraadbeheer`.`Voorraad` `V` on((`Bn`.`Ean` = `V`.`Ean`))) left join `CbBoeken`.`Voorraad` `CBV` on((convert(`Bn`.`Ean` using utf8) = `CBV`.`Ean`))) where ((`Bn`.`Geannuleerd` = 0) and (`A`.`Geannuleerd` = 0)) */;

--
-- Final view structure for view `open_orderregels`
--

/*!50001 DROP TABLE IF EXISTS `open_orderregels`*/;
/*!50001 DROP VIEW IF EXISTS `open_orderregels`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`thijs`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `open_orderregels` AS select `P`.`Id` AS `Id`,`P`.`aangemaakt` AS `aangemaakt`,`P`.`bevestigd` AS `bevestigd`,`P`.`gefactureerd` AS `gefactureerd`,`P`.`is_geparkeerd` AS `is_geparkeerd`,`P`.`factuurnummer_toegewezen` AS `factuurnummer_toegewezen`,`P`.`exact_export` AS `exact_export`,`P`.`exact_controle` AS `exact_controle`,`P`.`exact_factuur_verwerkt` AS `exact_factuur_verwerkt`,`P`.`etiket_geprint` AS `etiket_geprint`,`P`.`ingepakt` AS `ingepakt`,`P`.`geannuleerd` AS `geannuleerd`,`P`.`factuur_geprint` AS `factuur_geprint`,`P`.`pakketlabel_geprint` AS `pakketlabel_geprint`,`P`.`brieflabel_geprint` AS `brieflabel_geprint`,`P`.`betaald_via_ideal` AS `betaald_via_ideal`,`P`.`betaald` AS `betaald`,`P`.`openstaande_post_aangemaakt` AS `openstaande_post_aangemaakt`,`P`.`in_backorder_gezet` AS `in_backorder_gezet`,`P`.`oud_handmatig_verwerkt` AS `oud_handmatig_verwerkt`,`P`.`automatisch_geclassificeerd` AS `automatisch_geclassificeerd`,`P`.`handmatig_geclassificeerd` AS `handmatig_geclassificeerd`,`P`.`gecrediteerd` AS `gecrediteerd`,`P`.`volledig_geleverd_backorder` AS `volledig_geleverd_backorder`,`P`.`samengevoegd_met_eerdere_order` AS `samengevoegd_met_eerdere_order`,`P`.`niet_inpakken` AS `niet_inpakken`,`P`.`afgesloten` AS `afgesloten`,`P`.`factuur_per_mail_verzonden` AS `factuur_per_mail_verzonden`,`P`.`pdf_factuur_gecontroleerd` AS `pdf_factuur_gecontroleerd`,`P`.`voorgemeld_bij_postnl` AS `voorgemeld_bij_postnl`,`P`.`pakket_afgeleverd_volgens_postnl` AS `pakket_afgeleverd_volgens_postnl`,`P`.`kan_gedownload_worden` AS `kan_gedownload_worden`,`P`.`pakbon_geprint` AS `pakbon_geprint`,`P`.`uit_backorder_gehaald` AS `uit_backorder_gehaald`,`P`.`factuur_sturen_niet_nodig` AS `factuur_sturen_niet_nodig`,`P`.`hoeft_niet_betaald_te_worden` AS `hoeft_niet_betaald_te_worden`,`P`.`uitgevoerd_naar_exact_via_mari` AS `uitgevoerd_naar_exact_via_mari`,`P`.`wacht_op_compleet` AS `wacht_op_compleet`,`P`.`inpakbevestiging_verzonden` AS `inpakbevestiging_verzonden`,`P`.`niet_reserveren` AS `niet_reserveren`,`P`.`vink_open` AS `vink_open`,`P`.`vink_magazijn` AS `vink_magazijn`,`P`.`vink_klantenservice` AS `vink_klantenservice`,`R`.`Omschrijving` AS `Omschrijving`,`R`.`Bestellingid` AS `BestellingId`,`R`.`Ean` AS `Ean`,((`R`.`Aantal` + `R`.`AantalBackorder`) - if((`R`.`AantalBackorder` > 0),`orderregel_geleverd`(`P`.`Id`),0)) AS `OpenAantal` from (((`Computerboek_Klanten`.`OrderregelStatusPlat` `P` join `Computerboek_Klanten`.`Bestellingen` `R` on((`P`.`Id` = `R`.`Id`))) left join `Computerboek_Boeken`.`Boeken` `B` on((`R`.`Ean` = `B`.`Ean`))) left join `Computerboek_Boeken`.`Bindwijze` `BW` on((`B`.`Bindwijze` = `BW`.`Bindwijze`))) where ((`P`.`vink_open` = 1) and (ifnull(`BW`.`Bindwijze_voorraadartikel`,1) = 1)) */;

--
-- Final view structure for view `open_orderregels_query`
--

/*!50001 DROP TABLE IF EXISTS `open_orderregels_query`*/;
/*!50001 DROP VIEW IF EXISTS `open_orderregels_query`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `open_orderregels_query` AS select `P`.`Id` AS `Id`,`R`.`Omschrijving` AS `Omschrijving`,`R`.`Bestellingid` AS `BestellingId`,`R`.`Ean` AS `Ean`,((`R`.`Aantal` + `R`.`AantalBackorder`) - if((`R`.`AantalBackorder` > 0),`orderregel_geleverd`(`P`.`Id`),0)) AS `OpenAantal` from (((`Computerboek_Klanten`.`OrderregelStatusPlat` `P` join `Computerboek_Klanten`.`Bestellingen` `R` on((`P`.`Id` = `R`.`Id`))) join `Computerboek_Boeken`.`Boeken` on((`R`.`Ean` = `Computerboek_Boeken`.`Boeken`.`Ean`))) join `Computerboek_Boeken`.`Bindwijze` on((`Computerboek_Boeken`.`Boeken`.`Bindwijze` = `Computerboek_Boeken`.`Bindwijze`.`Bindwijze`))) where ((`P`.`bevestigd` = 1) and (`P`.`ingepakt` = 0) and (`P`.`geannuleerd` = 0) and (`P`.`gecrediteerd` = 0) and (`P`.`niet_inpakken` = 0) and (`P`.`afgesloten` = 0) and (`P`.`volledig_geleverd_backorder` = 0) and (`P`.`niet_reserveren` = 0) and (`Computerboek_Boeken`.`Bindwijze`.`Bindwijze_voorraadartikel` = 1)) */;

--
-- Final view structure for view `uit_backorder_regels`
--

/*!50001 DROP TABLE IF EXISTS `uit_backorder_regels`*/;
/*!50001 DROP VIEW IF EXISTS `uit_backorder_regels`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `uit_backorder_regels` AS select `Bestellingen`.`BackorderOrigineel` AS `BackorderOrigineel`,sum(`Bestellingen`.`Aantal`) AS `Geleverd` from `Bestellingen` where ((`Bestellingen`.`BackorderOrigineel` > 0) and (`Bestellingen`.`Aantal` > 0) and (`Bestellingen`.`Geannuleerd` = 0)) group by `Bestellingen`.`BackorderOrigineel` */;

--
-- Current Database: `Computerboek_Nieuwsbrieven`
--

USE `Computerboek_Nieuwsbrieven`;

--
-- Current Database: `Computerboek_vogoo`
--

USE `Computerboek_vogoo`;

--
-- Current Database: `Digipoort`
--

USE `Digipoort`;

--
-- Current Database: `Enquetes`
--

USE `Enquetes`;

--
-- Current Database: `ExactKoppeling`
--

USE `ExactKoppeling`;

--
-- Final view structure for view `Aanmaningen`
--

/*!50001 DROP TABLE IF EXISTS `Aanmaningen`*/;
/*!50001 DROP VIEW IF EXISTS `Aanmaningen`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Aanmaningen` AS (select `Facturen`.`Admnr` AS `Admnr`,`Facturen`.`FactuurID` AS `FactuurID`,`Facturen`.`OrderID` AS `OrderID`,`Facturen`.`Debtor` AS `Debtor`,`Facturen`.`InvoiceDebtor` AS `InvoiceDebtor`,`Facturen`.`DT` AS `DT`,`Facturen`.`Bedrag` AS `Bedrag`,`Facturen`.`OpenBedrag` AS `OpenBedrag`,`Facturen`.`Status` AS `Status`,`Facturen`.`LaatsteHerinnering` AS `LaatsteHerinnering`,`Facturen`.`AantalHerinneringen` AS `AantalHerinneringen`,`Facturen`.`PayMethod` AS `PayMethod`,`Facturen`.`PayCondition` AS `PayCondition` from `Facturen` where ((`Facturen`.`Status` = 'open') and (`Facturen`.`OpenBedrag` > '0.02') and (((`Facturen`.`DT` < (now() - interval (`Facturen`.`PayCondition` + 7) day)) and (`Facturen`.`AantalHerinneringen` = 0)) or ((`Facturen`.`AantalHerinneringen` > 0) and (`Facturen`.`LaatsteHerinnering` < (now() - interval 14 day)))))) */;

--
-- Final view structure for view `ExportView`
--

/*!50001 DROP TABLE IF EXISTS `ExportView`*/;
/*!50001 DROP VIEW IF EXISTS `ExportView`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `ExportView` AS select `ExportHistory`.`Administratieid` AS `Administratieid`,`ExportHistory`.`Orderregelnummer` AS `Orderregelnummer`,`ExportHistory`.`Ordernummer` AS `Ordernummer`,`ExportHistory`.`Batchid` AS `Batchid`,`ExportHistory`.`Exactid` AS `Exactid`,`ExportHistory`.`Klantid` AS `Klantid`,substr(`ExportHistory`.`Exportregel`,9,15) AS `ArtikelCode`,cast(substr(`ExportHistory`.`Exportregel`,24,6) as signed) AS `Aantal`,cast(substr(`ExportHistory`.`Exportregel`,286,8) as decimal(4,2)) AS `Prijs`,cast(substr(`ExportHistory`.`Exportregel`,294,6) as decimal(6,2)) AS `Korting`,substr(`ExportHistory`.`Exportregel`,300,4) AS `Backorder`,substr(`ExportHistory`.`Exportregel`,304,2) AS `BackorderReden`,substr(`ExportHistory`.`Exportregel`,326,10) AS `Bestellingid`,substr(`ExportHistory`.`Exportregel`,359,1) AS `Betaalwijze`,substr(`ExportHistory`.`Exportregel`,30,256) AS `Omschrijving`,substr(`ExportHistory`.`Exportregel`,360,9) AS `Rekeningnummer`,substr(`ExportHistory`.`Exportregel`,399,2) AS `Initialen`,`ExportHistory`.`DT` AS `DT` from `ExportHistory` */;

--
-- Final view structure for view `Herinneringen_Alles_Voor_Klant`
--

/*!50001 DROP TABLE IF EXISTS `Herinneringen_Alles_Voor_Klant`*/;
/*!50001 DROP VIEW IF EXISTS `Herinneringen_Alles_Voor_Klant`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Herinneringen_Alles_Voor_Klant` AS select `F`.`Debtor` AS `Debtor`,`F`.`FactuurID` AS `FactuurId`,date_format(`F`.`DT`,'%d-%m-%Y') AS `FactuurDatum`,`F`.`PayCondition` AS `BetaalTermijn`,date_format(ifnull(`F`.`VervalDatum`,(`F`.`DT` + interval 14 day)),'%d-%m-%Y') AS `VervalDatum`,if((cast(now() as date) >= cast(`F`.`VervalDatum` as date)),1,0) AS `Vervallen`,`H`.`HerinneringNiveau` AS `HerinneringNiveau`,`H`.`HerinneringDT` AS `LaatsteHerinnering`,`H`.`Mail_1` AS `Mail_1`,`H`.`Brief_2` AS `Brief_2`,`H`.`Mail_3` AS `Mail_3`,`H`.`Brief_4` AS `Brief_4`,`H`.`Mail_5` AS `Mail_5`,`H`.`Brief_6` AS `Brief_6`,`H`.`EDR` AS `EDR`,`F`.`Bedrag` AS `OrigineelBedrag`,`F`.`OpenBedrag` AS `OpenBedrag`,`F`.`AantalPosten` AS `AantalPosten`,`F`.`PDF` AS `PDF`,if((`BA`.`Siteid` = 3333),'comcol',if((`BA`.`Siteid` = 2222),'jongbloed','managementboek')) AS `Template`,coalesce(`KFAC`.`Emailadres`,`KFAC`.`ExactEmailadres`,`KVERZ`.`Emailadres`,`KVERZ`.`ExactEmailadres`) AS `EmailAdres`,if(((`F`.`VervalDatum` < now()) and (`H`.`HerinneringNiveau` < 6)),1,0) AS `Aanmanen`,`BADR`.`FactuurBedrijfsnaam` AS `FactuurBedrijfsnaam`,`BADR`.`FactuurBedrijfsnaam2` AS `FactuurBedrijfsnaam2`,`BADR`.`FactuurAfdeling` AS `FactuurAfdeling`,`BADR`.`FactuurGeslacht` AS `FactuurGeslacht`,`BADR`.`FactuurInitialen` AS `FactuurInitialen`,`BADR`.`FactuurAchternaam` AS `FactuurAchternaam`,`BADR`.`FactuurStraatnaam` AS `FactuurStraatnaam`,`BADR`.`FactuurHuisnummer` AS `FactuurHuisnummer`,`BADR`.`FactuurHuisnummerToevoeging` AS `FactuurHuisnummerToevoeging`,`BADR`.`FactuurPostcode` AS `FactuurPostcode`,`BADR`.`FactuurPlaatsnaam` AS `FactuurPlaatsnaam`,`BADR`.`FactuurLand` AS `FactuurLand` from (((((`ExactKoppeling`.`Facturen` `F` join `ExactKoppeling`.`FactuurHerinneringen` `H` on(((`F`.`Admnr` = `H`.`Admnr`) and (`F`.`FactuurID` = `H`.`FactuurID`)))) left join `Managementboek_Klanten`.`BestellingAll` `BA` on((`F`.`OrderID` = `BA`.`Bestellingid`))) left join `Managementboek_Klanten`.`BestellingAdressen` `BADR` on((`BA`.`Bestellingid` = `BADR`.`BestellingId`))) left join `Managementboek_Klanten`.`Klanten` `KVERZ` on((`BADR`.`VerzendKlantId` = `KVERZ`.`Klantid`))) left join `Managementboek_Klanten`.`Klanten` `KFAC` on((`F`.`Debtor` = `KFAC`.`Exactid`))) where ((`F`.`OpenBedrag` <> 0) and (`F`.`Status` = 'open') and (`F`.`Admnr` = 709)) group by `F`.`FactuurID` having (not((`EmailAdres` like '%@mainpress'))) */;

--
-- Final view structure for view `Herinneringen_EDR_Bedrijven`
--

/*!50001 DROP TABLE IF EXISTS `Herinneringen_EDR_Bedrijven`*/;
/*!50001 DROP VIEW IF EXISTS `Herinneringen_EDR_Bedrijven`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Herinneringen_EDR_Bedrijven` AS select `Herinneringen_Open_Voor_Klant`.`Debtor` AS `Referentie`,`Herinneringen_Open_Voor_Klant`.`FactuurBedrijfsnaam` AS `Bedrijfsnaam`,`Herinneringen_Open_Voor_Klant`.`FactuurBedrijfsnaam2` AS `Bedrijfsnaam2`,`Herinneringen_Open_Voor_Klant`.`FactuurAfdeling` AS `Afdeling`,`Herinneringen_Open_Voor_Klant`.`FactuurInitialen` AS `Voorletters`,'' AS `Tussenvoegsel`,`Herinneringen_Open_Voor_Klant`.`FactuurAchternaam` AS `Achternaam`,`Herinneringen_Open_Voor_Klant`.`FactuurGeslacht` AS `Geslacht`,'' AS `GeboorteDatum`,`Herinneringen_Open_Voor_Klant`.`FactuurTelefoonnummer` AS `Telefoon`,'' AS `Fax`,'' AS `Mobiel`,`Herinneringen_Open_Voor_Klant`.`EmailAdres` AS `Mail`,'' AS `RekeningNr`,`Herinneringen_Open_Voor_Klant`.`FactuurStraatnaam` AS `Straat`,`Herinneringen_Open_Voor_Klant`.`FactuurHuisnummer` AS `Huisnr`,`Herinneringen_Open_Voor_Klant`.`FactuurHuisnummerToevoeging` AS `Toevoeging`,`Herinneringen_Open_Voor_Klant`.`FactuurPostcode` AS `PC`,`Herinneringen_Open_Voor_Klant`.`FactuurPlaatsnaam` AS `Plaats`,`Herinneringen_Open_Voor_Klant`.`FactuurId` AS `Factuur`,`Herinneringen_Open_Voor_Klant`.`VervalDatum` AS `RenteDatum`,`Herinneringen_Open_Voor_Klant`.`OrigineelBedrag` AS `FactuurBedrag`,(`Herinneringen_Open_Voor_Klant`.`OrigineelBedrag` - `Herinneringen_Open_Voor_Klant`.`OpenBedrag`) AS `Betaald`,`Herinneringen_Open_Voor_Klant`.`OpenBedrag` AS `Saldo` from `ExactKoppeling`.`Herinneringen_Open_Voor_Klant` where ((`Herinneringen_Open_Voor_Klant`.`FactuurBedrijfsnaam` <> '') and (`Herinneringen_Open_Voor_Klant`.`HerinneringNiveau` = 6) and isnull(`Herinneringen_Open_Voor_Klant`.`EDR`)) order by `Herinneringen_Open_Voor_Klant`.`Debtor` */;

--
-- Final view structure for view `Herinneringen_EDR_Personen`
--

/*!50001 DROP TABLE IF EXISTS `Herinneringen_EDR_Personen`*/;
/*!50001 DROP VIEW IF EXISTS `Herinneringen_EDR_Personen`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Herinneringen_EDR_Personen` AS select `Herinneringen_Open_Voor_Klant`.`Debtor` AS `Referentie`,`Herinneringen_Open_Voor_Klant`.`FactuurInitialen` AS `Voorletters`,'' AS `Tussenvoegsel`,`Herinneringen_Open_Voor_Klant`.`FactuurAchternaam` AS `Achternaam`,`Herinneringen_Open_Voor_Klant`.`FactuurGeslacht` AS `Geslacht`,'' AS `GeboorteDatum`,`Herinneringen_Open_Voor_Klant`.`FactuurTelefoonnummer` AS `Telefoon`,'' AS `Fax`,'' AS `Mobiel`,`Herinneringen_Open_Voor_Klant`.`EmailAdres` AS `Mail`,'' AS `RekeningNr`,`Herinneringen_Open_Voor_Klant`.`FactuurStraatnaam` AS `Straat`,`Herinneringen_Open_Voor_Klant`.`FactuurHuisnummer` AS `Huisnr`,`Herinneringen_Open_Voor_Klant`.`FactuurHuisnummerToevoeging` AS `Toevoeging`,`Herinneringen_Open_Voor_Klant`.`FactuurPostcode` AS `PC`,`Herinneringen_Open_Voor_Klant`.`FactuurPlaatsnaam` AS `Plaats`,`Herinneringen_Open_Voor_Klant`.`FactuurId` AS `Factuur`,`Herinneringen_Open_Voor_Klant`.`VervalDatum` AS `RenteDatum`,`Herinneringen_Open_Voor_Klant`.`OrigineelBedrag` AS `FactuurBedrag`,(`Herinneringen_Open_Voor_Klant`.`OrigineelBedrag` - `Herinneringen_Open_Voor_Klant`.`OpenBedrag`) AS `Betaald`,`Herinneringen_Open_Voor_Klant`.`OpenBedrag` AS `Saldo` from `ExactKoppeling`.`Herinneringen_Open_Voor_Klant` where ((`Herinneringen_Open_Voor_Klant`.`FactuurBedrijfsnaam` = '') and (`Herinneringen_Open_Voor_Klant`.`HerinneringNiveau` = 6) and isnull(`Herinneringen_Open_Voor_Klant`.`EDR`)) order by `Herinneringen_Open_Voor_Klant`.`Debtor` */;

--
-- Final view structure for view `Herinneringen_Klanten`
--

/*!50001 DROP TABLE IF EXISTS `Herinneringen_Klanten`*/;
/*!50001 DROP VIEW IF EXISTS `Herinneringen_Klanten`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Herinneringen_Klanten` AS select max(if((`BA`.`Siteid` = 3333),'comcol',if((`BA`.`Siteid` = 2222),'jongbloed','managementboek'))) AS `Template`,`F`.`Debtor` AS `Debtor`,count(distinct `F`.`FactuurID`) AS `AantalFacturen`,min(`F`.`DT`) AS `OudsteFactuur`,max(`H`.`HerinneringNiveau`) AS `MaxNiveau`,min(`H`.`HerinneringNiveau`) AS `MinNiveau`,max(`H`.`HerinneringDT`) AS `LaatsteHerinnering`,sum(`F`.`Bedrag`) AS `OrigineelBedrag`,sum(`F`.`OpenBedrag`) AS `OpenBedrag`,coalesce(`KFAC`.`Emailadres`,`KFAC`.`ExactEmailadres`,`KVERZ`.`Emailadres`,`KVERZ`.`ExactEmailadres`) AS `EmailAdres`,group_concat(distinct `F`.`FactuurID` separator ',') AS `Facturen`,min(`BADR`.`FactuurBedrijfsnaam`) AS `FactuurBedrijfsnaam`,min(`BADR`.`FactuurBedrijfsnaam2`) AS `FactuurBedrijfsnaam2`,min(`BADR`.`FactuurAfdeling`) AS `FactuurAfdeling`,concat(ucase(left(min(`BADR`.`FactuurGeslacht`),1)),substr(min(`BADR`.`FactuurGeslacht`),2)) AS `FactuurGeslacht`,min(`BADR`.`FactuurInitialen`) AS `FactuurInitialen`,min(`BADR`.`FactuurAchternaam`) AS `FactuurAchternaam`,min(`BADR`.`FactuurStraatnaam`) AS `FactuurStraatnaam`,min(`BADR`.`FactuurHuisnummer`) AS `FactuurHuisnummer`,min(`BADR`.`FactuurHuisnummerToevoeging`) AS `FactuurHuisnummerToevoeging`,min(`BADR`.`FactuurPostcode`) AS `FactuurPostcode`,min(`BADR`.`FactuurPlaatsnaam`) AS `FactuurPlaatsnaam`,min(`BADR`.`FactuurLand`) AS `FactuurLand` from (((((`ExactKoppeling`.`Facturen` `F` left join `ExactKoppeling`.`FactuurHerinneringen` `H` on(((`F`.`Admnr` = `H`.`Admnr`) and (`F`.`FactuurID` = `H`.`FactuurID`)))) left join `Managementboek_Klanten`.`BestellingAll` `BA` on((`F`.`OrderID` = `BA`.`Bestellingid`))) left join `Managementboek_Klanten`.`BestellingAdressen` `BADR` on((`BA`.`Bestellingid` = `BADR`.`BestellingId`))) left join `Managementboek_Klanten`.`Klanten` `KVERZ` on((`BADR`.`VerzendKlantId` = `KVERZ`.`Klantid`))) left join `Managementboek_Klanten`.`Klanten` `KFAC` on((`F`.`Debtor` = `KFAC`.`Exactid`))) where ((`F`.`Status` = 'open') and (`F`.`Admnr` = 709) and (`F`.`VervalDatum` < (now() - interval 7 day)) and ((`H`.`HerinneringNiveau` = 0) or ((`H`.`HerinneringNiveau` < 6) and (ifnull(`H`.`HerinneringDT`,'2014-01-01') <= (now() - interval 13 day))))) group by `F`.`Debtor`,if((`BA`.`Siteid` = 3333),'comcol',if((`BA`.`Siteid` = 2222),'jongbloed','managementboek')) having ((`OpenBedrag` > 5) and (`OrigineelBedrag` > 0) and (`Debtor` <> 2668969) and (not((`EmailAdres` like '%@mainpress')))) */;

--
-- Final view structure for view `Herinneringen_Open_Voor_Klant`
--

/*!50001 DROP TABLE IF EXISTS `Herinneringen_Open_Voor_Klant`*/;
/*!50001 DROP VIEW IF EXISTS `Herinneringen_Open_Voor_Klant`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `Herinneringen_Open_Voor_Klant` AS select `F`.`Debtor` AS `Debtor`,`F`.`FactuurID` AS `FactuurId`,date_format(`F`.`DT`,'%d-%m-%Y') AS `FactuurDatum`,`F`.`PayCondition` AS `BetaalTermijn`,date_format(`F`.`VervalDatum`,'%d-%m-%Y') AS `VervalDatum`,`H`.`HerinneringNiveau` AS `HerinneringNiveau`,`H`.`HerinneringDT` AS `LaatsteHerinnering`,`H`.`Mail_1` AS `Mail_1`,`H`.`Brief_2` AS `Brief_2`,`H`.`Mail_3` AS `Mail_3`,`H`.`Brief_4` AS `Brief_4`,`H`.`Mail_5` AS `Mail_5`,`H`.`Brief_6` AS `Brief_6`,`H`.`EDR` AS `EDR`,`F`.`Bedrag` AS `OrigineelBedrag`,`F`.`OpenBedrag` AS `OpenBedrag`,`F`.`AantalPosten` AS `AantalPosten`,if((`BA`.`Siteid` = 3333),'comcol',if((`BA`.`Siteid` = 2222),'jongbloed','managementboek')) AS `Template`,coalesce(`KFAC`.`Emailadres`,`KFAC`.`ExactEmailadres`,`KVERZ`.`Emailadres`,`KVERZ`.`ExactEmailadres`) AS `EmailAdres`,if(((`F`.`VervalDatum` < now()) and (`H`.`HerinneringNiveau` < 6)),1,0) AS `Aanmanen`,`BADR`.`FactuurBedrijfsnaam` AS `FactuurBedrijfsnaam`,`BADR`.`FactuurBedrijfsnaam2` AS `FactuurBedrijfsnaam2`,`BADR`.`FactuurAfdeling` AS `FactuurAfdeling`,`BADR`.`FactuurGeslacht` AS `FactuurGeslacht`,`BADR`.`FactuurInitialen` AS `FactuurInitialen`,`BADR`.`FactuurAchternaam` AS `FactuurAchternaam`,`BADR`.`FactuurStraatnaam` AS `FactuurStraatnaam`,`BADR`.`FactuurHuisnummer` AS `FactuurHuisnummer`,`BADR`.`FactuurHuisnummerToevoeging` AS `FactuurHuisnummerToevoeging`,`BADR`.`FactuurPostcode` AS `FactuurPostcode`,`BADR`.`FactuurPlaatsnaam` AS `FactuurPlaatsnaam`,`BADR`.`FactuurLand` AS `FactuurLand`,`KFAC`.`Telefoonnummer` AS `FactuurTelefoonnummer` from (((((`ExactKoppeling`.`Facturen` `F` join `ExactKoppeling`.`FactuurHerinneringen` `H` on(((`F`.`Admnr` = `H`.`Admnr`) and (`F`.`FactuurID` = `H`.`FactuurID`)))) left join `Managementboek_Klanten`.`BestellingAll` `BA` on((`F`.`OrderID` = `BA`.`Bestellingid`))) left join `Managementboek_Klanten`.`BestellingAdressen` `BADR` on((`BA`.`Bestellingid` = `BADR`.`BestellingId`))) left join `Managementboek_Klanten`.`Klanten` `KVERZ` on((`BADR`.`VerzendKlantId` = `KVERZ`.`Klantid`))) left join `Managementboek_Klanten`.`Klanten_met_adres` `KFAC` on((`F`.`Debtor` = `KFAC`.`Exactid`))) where ((`F`.`Status` = 'open') and (`F`.`Admnr` = 709) and (`F`.`VervalDatum` < (now() - interval 7 day)) and ((`H`.`HerinneringNiveau` = 0) or ((`H`.`HerinneringNiveau` <= 6) and (`H`.`HerinneringDT` <= (now() - interval 13 day))))) group by `F`.`FactuurID` having (not((`EmailAdres` like '%@mainpress'))) */;

--
-- Current Database: `Feed_Nielsen`
--

USE `Feed_Nielsen`;

--
-- Final view structure for view `BoekenWebsite`
--

/*!50001 DROP TABLE IF EXISTS `BoekenWebsite`*/;
/*!50001 DROP VIEW IF EXISTS `BoekenWebsite`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `BoekenWebsite` AS select `Boeken`.`ISBN13` AS `ISBN13`,`Boeken`.`TL` AS `TL`,`Boeken`.`CR1` AS `CR1`,`Boeken`.`CRT1` AS `CRT1`,`Boeken`.`CCI1` AS `CCI1`,`Boeken`.`ICKN1` AS `ICKN1`,`Boeken`.`CR2` AS `CR2`,`Boeken`.`CRT2` AS `CRT2`,`Boeken`.`CCI2` AS `CCI2`,`Boeken`.`ICFN2` AS `ICFN2`,`Boeken`.`ICKN2` AS `ICKN2`,`Boeken`.`CR3` AS `CR3`,`Boeken`.`CRT3` AS `CRT3`,`Boeken`.`CCI3` AS `CCI3`,`Boeken`.`ICFN3` AS `ICFN3`,`Boeken`.`ICKN3` AS `ICKN3`,`Boeken`.`HMM` AS `HMM`,`Boeken`.`WMM` AS `WMM`,`Boeken`.`SMM` AS `SMM`,`Boeken`.`WG` AS `WG`,`Boeken`.`EDSS` AS `EDSS`,`Boeken`.`PFC` AS `PFC`,`Boeken`.`PFCT` AS `PFCT`,`Boeken`.`PFD1` AS `PFD1`,`Boeken`.`PFDT1` AS `PFDT1`,`Boeken`.`PFD2` AS `PFD2`,`Boeken`.`PFDT2` AS `PFDT2`,`Boeken`.`IMPN` AS `IMPN`,`Boeken`.`IMPID` AS `IMPID`,`Boeken`.`PUBN` AS `PUBN`,`Boeken`.`PUBID` AS `PUBID`,`Boeken`.`COP` AS `COP`,`Boeken`.`LS` AS `LS`,`Boeken`.`NAC1` AS `NAC1`,`Boeken`.`NAT1` AS `NAT1`,`Boeken`.`DEWS1` AS `DEWS1`,`Boeken`.`DEWEY1` AS `DEWEY1`,`Boeken`.`BISACSC1` AS `BISACSC1`,`Boeken`.`BISACC1` AS `BISACC1`,`Boeken`.`BISACT1` AS `BISACT1`,`Boeken`.`BISACSC2` AS `BISACSC2`,`Boeken`.`BISACC2` AS `BISACC2`,`Boeken`.`BISACT2` AS `BISACT2`,`Boeken`.`BIC2SC1` AS `BIC2SC1`,`Boeken`.`BIC2ST1` AS `BIC2ST1`,`Boeken`.`BIC2SC2` AS `BIC2SC2`,`Boeken`.`BIC2ST2` AS `BIC2ST2`,`Boeken`.`PUBPD` AS `PUBPD`,`Boeken`.`PUBSC` AS `PUBSC`,`Boeken`.`PUBST` AS `PUBST`,`Boeken`.`USDCCPRA` AS `USDCCPRA`,`Boeken`.`USDCCPRC` AS `USDCCPRC`,`Boeken`.`USDCCPRRRP` AS `USDCCPRRRP`,`Boeken`.`USDCCPRTOP` AS `USDCCPRTOP`,`Boeken`.`USDCCPRRRPLT` AS `USDCCPRRRPLT`,`Boeken`.`USDCCPRPN` AS `USDCCPRPN`,`Boeken`.`USNBDAA` AS `USNBDAA`,`Boeken`.`USNBDPAC` AS `USNBDPAC`,`Boeken`.`USNBDPAT` AS `USNBDPAT`,`Boeken`.`USADN1` AS `USADN1`,`Boeken`.`EAN` AS `EAN`,`Boeken`.`ICFN1` AS `ICFN1`,`Boeken`.`EPT` AS `EPT`,`Boeken`.`EPTC` AS `EPTC`,`Boeken`.`EPF` AS `EPF`,`Boeken`.`EPFC` AS `EPFC`,`Boeken`.`EPFS` AS `EPFS`,`Boeken`.`NBDSD` AS `NBDSD`,`Boeken`.`NBDLD` AS `NBDLD`,`Boeken`.`PWU1` AS `PWU1`,`Boeken`.`PWTC1` AS `PWTC1`,`Boeken`.`PWTT1` AS `PWTT1`,`Boeken`.`PUBAIS13` AS `PUBAIS13`,`Boeken`.`GBPCCPTC` AS `GBPCCPTC`,`Boeken`.`GBPCCPTD` AS `GBPCCPTD`,`Boeken`.`GBPCCPRA` AS `GBPCCPRA`,`Boeken`.`GBPCCPRC` AS `GBPCCPRC`,`Boeken`.`GBPCCPRRRP` AS `GBPCCPRRRP`,`Boeken`.`GBPCCPRPN` AS `GBPCCPRPN`,`Boeken`.`USDCCPTC` AS `USDCCPTC`,`Boeken`.`USDCCPTD` AS `USDCCPTD`,`Boeken`.`EURCCPTC` AS `EURCCPTC`,`Boeken`.`EURCCPTD` AS `EURCCPTD`,`Boeken`.`EURCCPRA` AS `EURCCPRA`,`Boeken`.`EURCCPRC` AS `EURCCPRC`,`Boeken`.`EURCCPRRRP` AS `EURCCPRRRP`,`Boeken`.`EURCCPRPN` AS `EURCCPRPN`,`Boeken`.`NBDTOC` AS `NBDTOC`,`Boeken`.`BIC2QC1` AS `BIC2QC1`,`Boeken`.`BIC2QC2` AS `BIC2QC2`,`Boeken`.`BIC2QC3` AS `BIC2QC3`,`Boeken`.`BIC2QT1` AS `BIC2QT1`,`Boeken`.`BIC2QT2` AS `BIC2QT2`,`Boeken`.`BIC2QT3` AS `BIC2QT3`,`Boeken`.`BIC2SC3` AS `BIC2SC3`,`Boeken`.`BIC2ST3` AS `BIC2ST3`,`Boeken`.`BISACC3` AS `BISACC3`,`Boeken`.`BISACSC3` AS `BISACSC3`,`Boeken`.`BISACT3` AS `BISACT3`,`Boeken`.`CRT10` AS `CRT10`,`Boeken`.`CRT4` AS `CRT4`,`Boeken`.`CRT5` AS `CRT5`,`Boeken`.`CRT6` AS `CRT6`,`Boeken`.`CRT7` AS `CRT7`,`Boeken`.`CRT8` AS `CRT8`,`Boeken`.`CRT9` AS `CRT9`,`Boeken`.`EPBIS13` AS `EPBIS13`,`Boeken`.`EPSS` AS `EPSS`,`Boeken`.`EURADI1` AS `EURADI1`,`Boeken`.`EURADI2` AS `EURADI2`,`Boeken`.`EURADI3` AS `EURADI3`,`Boeken`.`EURADN1` AS `EURADN1`,`Boeken`.`EURADN2` AS `EURADN2`,`Boeken`.`EURADN3` AS `EURADN3`,`Boeken`.`EURCCPRRRPLT` AS `EURCCPRRRPLT`,`Boeken`.`EURCCPRTOP` AS `EURCCPRTOP`,`Boeken`.`EURNBDAA` AS `EURNBDAA`,`Boeken`.`EURNBDPAC` AS `EURNBDPAC`,`Boeken`.`EURNBDPAT` AS `EURNBDPAT`,`Boeken`.`EURNBDPQ` AS `EURNBDPQ`,`Boeken`.`GBPCCPRRRPLT` AS `GBPCCPRRRPLT`,`Boeken`.`GBPCCPRTOP` AS `GBPCCPRTOP`,`Boeken`.`ICAFF1` AS `ICAFF1`,`Boeken`.`ICAFF2` AS `ICAFF2`,`Boeken`.`ICAFF3` AS `ICAFF3`,`Boeken`.`ICCY1` AS `ICCY1`,`Boeken`.`ICCY2` AS `ICCY2`,`Boeken`.`ICCY3` AS `ICCY3`,`Boeken`.`ICKNP1` AS `ICKNP1`,`Boeken`.`ICKNS1` AS `ICKNS1`,`Boeken`.`ICKNS10` AS `ICKNS10`,`Boeken`.`ICKNS2` AS `ICKNS2`,`Boeken`.`ICKNS3` AS `ICKNS3`,`Boeken`.`ICKNS4` AS `ICKNS4`,`Boeken`.`ICKNS5` AS `ICKNS5`,`Boeken`.`ICKNS6` AS `ICKNS6`,`Boeken`.`ICLAN1` AS `ICLAN1`,`Boeken`.`ICLAN10` AS `ICLAN10`,`Boeken`.`ICLAN2` AS `ICLAN2`,`Boeken`.`ICLAN3` AS `ICLAN3`,`Boeken`.`ICNAK1` AS `ICNAK1`,`Boeken`.`ICNAK2` AS `ICNAK2`,`Boeken`.`ICNAK3` AS `ICNAK3`,`Boeken`.`ICPP1` AS `ICPP1`,`Boeken`.`ICPP2` AS `ICPP2`,`Boeken`.`ICPP3` AS `ICPP3`,`Boeken`.`ICTAN1` AS `ICTAN1`,`Boeken`.`ICTAN2` AS `ICTAN2`,`Boeken`.`ICTAN3` AS `ICTAN3`,`Boeken`.`ICTBN1` AS `ICTBN1`,`Boeken`.`ICTBN2` AS `ICTBN2`,`Boeken`.`ICTBN3` AS `ICTBN3`,`Boeken`.`ISSN` AS `ISSN`,`Boeken`.`LA` AS `LA`,`Boeken`.`MOPD` AS `MOPD`,`Boeken`.`NAC10` AS `NAC10`,`Boeken`.`NAC2` AS `NAC2`,`Boeken`.`NAC3` AS `NAC3`,`Boeken`.`NAC4` AS `NAC4`,`Boeken`.`NAC5` AS `NAC5`,`Boeken`.`NAC6` AS `NAC6`,`Boeken`.`NAC7` AS `NAC7`,`Boeken`.`NAC8` AS `NAC8`,`Boeken`.`NAC9` AS `NAC9`,`Boeken`.`NAT10` AS `NAT10`,`Boeken`.`NAT2` AS `NAT2`,`Boeken`.`NAT3` AS `NAT3`,`Boeken`.`NAT4` AS `NAT4`,`Boeken`.`NAT5` AS `NAT5`,`Boeken`.`NAT6` AS `NAT6`,`Boeken`.`NAT7` AS `NAT7`,`Boeken`.`NAT8` AS `NAT8`,`Boeken`.`NAT9` AS `NAT9`,`Boeken`.`NWS` AS `NWS`,`Boeken`.`PAGNUM` AS `PAGNUM`,`Boeken`.`PFD3` AS `PFD3`,`Boeken`.`PFD4` AS `PFD4`,`Boeken`.`PFDT3` AS `PFDT3`,`Boeken`.`PFDT4` AS `PFDT4`,`Boeken`.`POP` AS `POP`,`Boeken`.`PS1` AS `PS1`,`Boeken`.`PT1` AS `PT1`,`Boeken`.`PT2` AS `PT2`,`Boeken`.`PTS` AS `PTS`,`Boeken`.`PVNO1` AS `PVNO1`,`Boeken`.`PVNO2` AS `PVNO2`,`Boeken`.`PWTC2` AS `PWTC2`,`Boeken`.`PWTC3` AS `PWTC3`,`Boeken`.`PWTT2` AS `PWTT2`,`Boeken`.`PWTT3` AS `PWTT3`,`Boeken`.`PWU2` AS `PWU2`,`Boeken`.`PWU3` AS `PWU3`,`Boeken`.`REPBIS13` AS `REPBIS13`,`Boeken`.`REPIS13` AS `REPIS13`,`Boeken`.`SLC` AS `SLC`,`Boeken`.`SLT` AS `SLT`,`Boeken`.`SN` AS `SN`,`Boeken`.`ST` AS `ST`,`Boeken`.`UKADI1` AS `UKADI1`,`Boeken`.`UKADI2` AS `UKADI2`,`Boeken`.`UKADN1` AS `UKADN1`,`Boeken`.`UKADN2` AS `UKADN2`,`Boeken`.`UKNBDAA` AS `UKNBDAA`,`Boeken`.`UKNBDEAD` AS `UKNBDEAD`,`Boeken`.`UKNBDOT` AS `UKNBDOT`,`Boeken`.`UKNBDPAC` AS `UKNBDPAC`,`Boeken`.`UKNBDPAT` AS `UKNBDPAT`,`Boeken`.`UKNBDPQ` AS `UKNBDPQ`,`Boeken`.`USADI1` AS `USADI1`,`Boeken`.`USADI2` AS `USADI2`,`Boeken`.`USADI3` AS `USADI3`,`Boeken`.`USADN2` AS `USADN2`,`Boeken`.`USADN3` AS `USADN3`,`Boeken`.`USNBDPQ` AS `USNBDPQ`,`Boeken`.`WSLREXUK` AS `WSLREXUK`,`Boeken`.`WSLRUK` AS `WSLRUK`,`Boeken`.`YS` AS `YS` from `Boeken` where ((`Boeken`.`PUBSC` in ('04','02')) and ((`Boeken`.`EURNBDPAC` in (20,21,22,23)) or (`Boeken`.`UKNBDPAC` in (20,21,22,23))) and ((`Boeken`.`EURCCPRRRP` > 0) or (`Boeken`.`GBPCCPRRRP` > 0))) */;

--
-- Final view structure for view `BoekenWebsiteGefilterd`
--

/*!50001 DROP TABLE IF EXISTS `BoekenWebsiteGefilterd`*/;
/*!50001 DROP VIEW IF EXISTS `BoekenWebsiteGefilterd`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`sander`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `BoekenWebsiteGefilterd` AS select `B`.`ISBN13` AS `ISBN13`,`B`.`TL` AS `TL`,`B`.`CR1` AS `CR1`,`B`.`CRT1` AS `CRT1`,`B`.`CCI1` AS `CCI1`,`B`.`ICKN1` AS `ICKN1`,`B`.`CR2` AS `CR2`,`B`.`CRT2` AS `CRT2`,`B`.`CCI2` AS `CCI2`,`B`.`ICFN2` AS `ICFN2`,`B`.`ICKN2` AS `ICKN2`,`B`.`CR3` AS `CR3`,`B`.`CRT3` AS `CRT3`,`B`.`CCI3` AS `CCI3`,`B`.`ICFN3` AS `ICFN3`,`B`.`ICKN3` AS `ICKN3`,`B`.`HMM` AS `HMM`,`B`.`WMM` AS `WMM`,`B`.`SMM` AS `SMM`,`B`.`WG` AS `WG`,`B`.`EDSS` AS `EDSS`,`B`.`PFC` AS `PFC`,`B`.`PFCT` AS `PFCT`,`B`.`PFD1` AS `PFD1`,`B`.`PFDT1` AS `PFDT1`,`B`.`PFD2` AS `PFD2`,`B`.`PFDT2` AS `PFDT2`,`B`.`IMPN` AS `IMPN`,`B`.`IMPID` AS `IMPID`,`B`.`PUBN` AS `PUBN`,`B`.`PUBID` AS `PUBID`,`B`.`COP` AS `COP`,`B`.`LS` AS `LS`,`B`.`NAC1` AS `NAC1`,`B`.`NAT1` AS `NAT1`,`B`.`DEWS1` AS `DEWS1`,`B`.`DEWEY1` AS `DEWEY1`,`B`.`BISACSC1` AS `BISACSC1`,`B`.`BISACC1` AS `BISACC1`,`B`.`BISACT1` AS `BISACT1`,`B`.`BISACSC2` AS `BISACSC2`,`B`.`BISACC2` AS `BISACC2`,`B`.`BISACT2` AS `BISACT2`,`B`.`BIC2SC1` AS `BIC2SC1`,`B`.`BIC2ST1` AS `BIC2ST1`,`B`.`BIC2SC2` AS `BIC2SC2`,`B`.`BIC2ST2` AS `BIC2ST2`,`B`.`PUBPD` AS `PUBPD`,`B`.`PUBSC` AS `PUBSC`,`B`.`PUBST` AS `PUBST`,`B`.`USDCCPRA` AS `USDCCPRA`,`B`.`USDCCPRC` AS `USDCCPRC`,`B`.`USDCCPRRRP` AS `USDCCPRRRP`,`B`.`USDCCPRTOP` AS `USDCCPRTOP`,`B`.`USDCCPRRRPLT` AS `USDCCPRRRPLT`,`B`.`USDCCPRPN` AS `USDCCPRPN`,`B`.`USNBDAA` AS `USNBDAA`,`B`.`USNBDPAC` AS `USNBDPAC`,`B`.`USNBDPAT` AS `USNBDPAT`,`B`.`USADN1` AS `USADN1`,`B`.`EAN` AS `EAN`,`B`.`ICFN1` AS `ICFN1`,`B`.`EPT` AS `EPT`,`B`.`EPTC` AS `EPTC`,`B`.`EPF` AS `EPF`,`B`.`EPFC` AS `EPFC`,`B`.`EPFS` AS `EPFS`,`B`.`NBDSD` AS `NBDSD`,`B`.`NBDLD` AS `NBDLD`,`B`.`PWU1` AS `PWU1`,`B`.`PWTC1` AS `PWTC1`,`B`.`PWTT1` AS `PWTT1`,`B`.`PUBAIS13` AS `PUBAIS13`,`B`.`GBPCCPTC` AS `GBPCCPTC`,`B`.`GBPCCPTD` AS `GBPCCPTD`,`B`.`GBPCCPRA` AS `GBPCCPRA`,`B`.`GBPCCPRC` AS `GBPCCPRC`,`B`.`GBPCCPRRRP` AS `GBPCCPRRRP`,`B`.`GBPCCPRPN` AS `GBPCCPRPN`,`B`.`USDCCPTC` AS `USDCCPTC`,`B`.`USDCCPTD` AS `USDCCPTD`,`B`.`EURCCPTC` AS `EURCCPTC`,`B`.`EURCCPTD` AS `EURCCPTD`,`B`.`EURCCPRA` AS `EURCCPRA`,`B`.`EURCCPRC` AS `EURCCPRC`,`B`.`EURCCPRRRP` AS `EURCCPRRRP`,`B`.`EURCCPRPN` AS `EURCCPRPN`,`B`.`NBDTOC` AS `NBDTOC`,`B`.`BIC2QC1` AS `BIC2QC1`,`B`.`BIC2QC2` AS `BIC2QC2`,`B`.`BIC2QC3` AS `BIC2QC3`,`B`.`BIC2QT1` AS `BIC2QT1`,`B`.`BIC2QT2` AS `BIC2QT2`,`B`.`BIC2QT3` AS `BIC2QT3`,`B`.`BIC2SC3` AS `BIC2SC3`,`B`.`BIC2ST3` AS `BIC2ST3`,`B`.`BISACC3` AS `BISACC3`,`B`.`BISACSC3` AS `BISACSC3`,`B`.`BISACT3` AS `BISACT3`,`B`.`CRT10` AS `CRT10`,`B`.`CRT4` AS `CRT4`,`B`.`CRT5` AS `CRT5`,`B`.`CRT6` AS `CRT6`,`B`.`CRT7` AS `CRT7`,`B`.`CRT8` AS `CRT8`,`B`.`CRT9` AS `CRT9`,`B`.`EPBIS13` AS `EPBIS13`,`B`.`EPSS` AS `EPSS`,`B`.`EURADI1` AS `EURADI1`,`B`.`EURADI2` AS `EURADI2`,`B`.`EURADI3` AS `EURADI3`,`B`.`EURADN1` AS `EURADN1`,`B`.`EURADN2` AS `EURADN2`,`B`.`EURADN3` AS `EURADN3`,`B`.`EURCCPRRRPLT` AS `EURCCPRRRPLT`,`B`.`EURCCPRTOP` AS `EURCCPRTOP`,`B`.`EURNBDAA` AS `EURNBDAA`,`B`.`EURNBDPAC` AS `EURNBDPAC`,`B`.`EURNBDPAT` AS `EURNBDPAT`,`B`.`EURNBDPQ` AS `EURNBDPQ`,`B`.`GBPCCPRRRPLT` AS `GBPCCPRRRPLT`,`B`.`GBPCCPRTOP` AS `GBPCCPRTOP`,`B`.`ICAFF1` AS `ICAFF1`,`B`.`ICAFF2` AS `ICAFF2`,`B`.`ICAFF3` AS `ICAFF3`,`B`.`ICCY1` AS `ICCY1`,`B`.`ICCY2` AS `ICCY2`,`B`.`ICCY3` AS `ICCY3`,`B`.`ICKNP1` AS `ICKNP1`,`B`.`ICKNS1` AS `ICKNS1`,`B`.`ICKNS10` AS `ICKNS10`,`B`.`ICKNS2` AS `ICKNS2`,`B`.`ICKNS3` AS `ICKNS3`,`B`.`ICKNS4` AS `ICKNS4`,`B`.`ICKNS5` AS `ICKNS5`,`B`.`ICKNS6` AS `ICKNS6`,`B`.`ICLAN1` AS `ICLAN1`,`B`.`ICLAN10` AS `ICLAN10`,`B`.`ICLAN2` AS `ICLAN2`,`B`.`ICLAN3` AS `ICLAN3`,`B`.`ICNAK1` AS `ICNAK1`,`B`.`ICNAK2` AS `ICNAK2`,`B`.`ICNAK3` AS `ICNAK3`,`B`.`ICPP1` AS `ICPP1`,`B`.`ICPP2` AS `ICPP2`,`B`.`ICPP3` AS `ICPP3`,`B`.`ICTAN1` AS `ICTAN1`,`B`.`ICTAN2` AS `ICTAN2`,`B`.`ICTAN3` AS `ICTAN3`,`B`.`ICTBN1` AS `ICTBN1`,`B`.`ICTBN2` AS `ICTBN2`,`B`.`ICTBN3` AS `ICTBN3`,`B`.`ISSN` AS `ISSN`,`B`.`LA` AS `LA`,`B`.`MOPD` AS `MOPD`,`B`.`NAC10` AS `NAC10`,`B`.`NAC2` AS `NAC2`,`B`.`NAC3` AS `NAC3`,`B`.`NAC4` AS `NAC4`,`B`.`NAC5` AS `NAC5`,`B`.`NAC6` AS `NAC6`,`B`.`NAC7` AS `NAC7`,`B`.`NAC8` AS `NAC8`,`B`.`NAC9` AS `NAC9`,`B`.`NAT10` AS `NAT10`,`B`.`NAT2` AS `NAT2`,`B`.`NAT3` AS `NAT3`,`B`.`NAT4` AS `NAT4`,`B`.`NAT5` AS `NAT5`,`B`.`NAT6` AS `NAT6`,`B`.`NAT7` AS `NAT7`,`B`.`NAT8` AS `NAT8`,`B`.`NAT9` AS `NAT9`,`B`.`NWS` AS `NWS`,`B`.`PAGNUM` AS `PAGNUM`,`B`.`PFD3` AS `PFD3`,`B`.`PFD4` AS `PFD4`,`B`.`PFDT3` AS `PFDT3`,`B`.`PFDT4` AS `PFDT4`,`B`.`POP` AS `POP`,`B`.`PS1` AS `PS1`,`B`.`PT1` AS `PT1`,`B`.`PT2` AS `PT2`,`B`.`PTS` AS `PTS`,`B`.`PVNO1` AS `PVNO1`,`B`.`PVNO2` AS `PVNO2`,`B`.`PWTC2` AS `PWTC2`,`B`.`PWTC3` AS `PWTC3`,`B`.`PWTT2` AS `PWTT2`,`B`.`PWTT3` AS `PWTT3`,`B`.`PWU2` AS `PWU2`,`B`.`PWU3` AS `PWU3`,`B`.`REPBIS13` AS `REPBIS13`,`B`.`REPIS13` AS `REPIS13`,`B`.`SLC` AS `SLC`,`B`.`SLT` AS `SLT`,`B`.`SN` AS `SN`,`B`.`ST` AS `ST`,`B`.`UKADI1` AS `UKADI1`,`B`.`UKADI2` AS `UKADI2`,`B`.`UKADN1` AS `UKADN1`,`B`.`UKADN2` AS `UKADN2`,`B`.`UKNBDAA` AS `UKNBDAA`,`B`.`UKNBDEAD` AS `UKNBDEAD`,`B`.`UKNBDOT` AS `UKNBDOT`,`B`.`UKNBDPAC` AS `UKNBDPAC`,`B`.`UKNBDPAT` AS `UKNBDPAT`,`B`.`UKNBDPQ` AS `UKNBDPQ`,`B`.`USADI1` AS `USADI1`,`B`.`USADI2` AS `USADI2`,`B`.`USADI3` AS `USADI3`,`B`.`USADN2` AS `USADN2`,`B`.`USADN3` AS `USADN3`,`B`.`USNBDPQ` AS `USNBDPQ`,`B`.`WSLREXUK` AS `WSLREXUK`,`B`.`WSLRUK` AS `WSLRUK`,`B`.`YS` AS `YS`,`U`.`UitgeverID` AS `UitgeverID`,`U`.`Klantnummer` AS `Klantnummer`,`U`.`Naamuitgever` AS `Naamuitgever`,`U`.`Omschrijving` AS `Omschrijving`,`U`.`Adres` AS `Adres`,`U`.`Postcode` AS `Postcode`,`U`.`Woonplaats` AS `Woonplaats`,`U`.`Telefoon` AS `Telefoon`,`U`.`Fax` AS `Fax`,`U`.`Email` AS `Email`,`U`.`Contactpersoon` AS `Contactpersoon`,`U`.`Kortingmp_a` AS `Kortingmp_a`,`U`.`Kortingmp_s` AS `Kortingmp_s`,`U`.`Kortingmp_w` AS `Kortingmp_w`,`U`.`Kortingmp_o` AS `Kortingmp_o`,`U`.`Kortingmp_g` AS `Kortingmp_g`,`U`.`Kortingmp_e` AS `Kortingmp_e`,`U`.`Kortingmp_NCOI` AS `Kortingmp_NCOI`,`U`.`Magazijnlocatienummer` AS `Magazijnlocatienummer`,`U`.`Magazijnlocatienummerbulk` AS `Magazijnlocatienummerbulk`,`U`.`Magazijnlocatienummercom` AS `Magazijnlocatienummercom`,`U`.`Magazijnlocatienummercombulk` AS `Magazijnlocatienummercombulk`,`U`.`Verborgen` AS `Verborgen`,`U`.`Crediteurnummer` AS `Crediteurnummer`,`U`.`BestelpuntID` AS `BestelpuntID`,`U`.`BestelwijzeID` AS `BestelwijzeID`,`U`.`NCOIBestelpuntID` AS `NCOIBestelpuntID`,`U`.`Minimalebestelhoeveelheid` AS `Minimalebestelhoeveelheid`,`U`.`Feed` AS `Feed`,`U`.`Aanhef` AS `Aanhef`,`U`.`Afsluiting` AS `Afsluiting`,`U`.`Emailvoorvragen` AS `Emailvoorvragen`,`U`.`Afspraak` AS `Afspraak`,`U`.`Ruzie` AS `Ruzie`,`U`.`MagONE` AS `MagONE`,`U`.`Retourneer_min` AS `Retourneer_min`,`U`.`Retourneer_max` AS `Retourneer_max`,`U`.`Email_ebook` AS `Email_ebook`,`U`.`Automatisch_rapporteren` AS `Automatisch_rapporteren`,`U`.`Rapportageviacb` AS `Rapportageviacb`,`U`.`Uitgevers_rapportagevanaf` AS `Uitgevers_rapportagevanaf`,`U`.`Uitgevers_levertijd` AS `Uitgevers_levertijd`,`U`.`Email_abo_bestellen` AS `Email_abo_bestellen`,`U`.`Email_abo_reclameren` AS `Email_abo_reclameren`,`U`.`Abo_aanhef` AS `Abo_aanhef`,`U`.`Abo_afsluiting` AS `Abo_afsluiting`,`U`.`Abo_korting` AS `Abo_korting`,`U`.`Abo_klantnummer_mainpress` AS `Abo_klantnummer_mainpress`,`BB`.`_Value` AS `_Value`,`BB`.`_Description` AS `_Description`,`BB`.`rubriek` AS `rubriek`,`BB`.`rubriekman` AS `rubriekman`,`BB`.`rubriekcom` AS `rubriekcom`,`BB`.`rubriekjur` AS `rubriekjur`,`BB`.`rubriekalg` AS `rubriekalg`,`BB`.`website` AS `website`,`BB`.`NUR` AS `NUR`,`BB`.`extra_check` AS `extra_check`,`BB`.`plts` AS `plts`,`BB`.`level_0` AS `level_0`,`BB`.`level_1` AS `level_1`,`BB`.`level_2` AS `level_2`,`BB`.`level_3` AS `level_3`,`BB`.`level_4` AS `level_4`,`BB`.`level_5` AS `level_5`,`BB`.`level_6` AS `level_6`,`BB`.`in_feed` AS `in_feed`,`BB`.`ranking` AS `ranking`,`BB`.`JuridicaCode` AS `JuridicaCode` from (((((`Feed_Nielsen`.`BoekenWebsite` `B` join `Feed_Nielsen`.`NielsenBestelpunten` `P` on((`B`.`PUBN` = `P`.`NaamUitgever`))) join `Manpo`.`Uitgevers` `U` on((`P`.`UitgeverId` = `U`.`UitgeverID`))) join `Feed_Nielsen`.`NielsenBindwijze` `W` on((`W`.`NielsenBindwijze` = `B`.`PFC`))) join `Feeds`.`bisac` `BB` on((`B`.`BISACC1` = `BB`.`_Value`))) join `Feed_Nielsen`.`NielsenRubrieken` `R` on((`R`.`NielsenRubriek` = `BB`.`rubriek`))) */;

--
-- Current Database: `Feeds`
--

