-- http://www.phpmyadmin.net
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 15-09-2015 a las 16:13:10
-- Versión del servidor: 5.6.20
-- Versión de PHP: 5.5.15




--
-- Base de datos: `conalot_db`
--
CREATE DATABASE IF NOT EXISTS `conalot_db` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `conalot_db`;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `aportes_especiales`
--

CREATE TABLE IF NOT EXISTS `aportes_especiales` (
  `RIF` varchar(13) DEFAULT NULL,
  `Fecha` varchar(10) DEFAULT NULL,
  `Detalle_Concepto` varchar(69) DEFAULT NULL,
  `Monto_num` int(5) DEFAULT NULL,
  `CA_pagados` int(3) DEFAULT NULL,
  `Mes_pagado` varchar(10) DEFAULT NULL,
  `ano` int(4) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `banco`
--

CREATE TABLE IF NOT EXISTS `banco` (
  `banco_id` int(3) NOT NULL DEFAULT '0',
  `banco_nombre` varchar(250) DEFAULT NULL,
  `banco_estatus` int(3) DEFAULT NULL,
  `banco_id_contribuyente` varchar(50) DEFAULT NULL,
  `banco_direccion_web` varchar(50) DEFAULT NULL,
  `banco_imagen_logo` varchar(50) DEFAULT NULL,
  `banco_habilitado` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `centros_autorizados`
--

CREATE TABLE IF NOT EXISTS `centros_autorizados` (
  `cenau_rif_centro_apuesta` varchar(12) NOT NULL,
  `cenau_numero_patente` varchar(20) NOT NULL,
  `cenau_id_sucursal` int(3) NOT NULL,
  `cenau_razon_social` varchar(200) NOT NULL,
  `cenau_estado` varchar(200) NOT NULL,
  `cenau_municipio` varchar(200) NOT NULL,
  `cenau_parroquia` varchar(200) NOT NULL,
  `cenau_ciudad` varchar(200) NOT NULL,
  `cenau_numero_taquillas` int(3) NOT NULL,
  `cenau_fecha_autorizacion` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `cenau_enviado` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `centro_apuesta`
--

CREATE TABLE IF NOT EXISTS `centro_apuesta` (
  `cenap_rif` varchar(12) NOT NULL,
  `cenap_razon_social` varchar(200) NOT NULL,
  `cenap_fecha_vencim_rif` date NOT NULL,
  `cenap_tipo_empresa` varchar(20) NOT NULL,
  `cenap_fecha_hora` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `cenap_oficina_registro` varchar(100) NOT NULL,
  `cenap_fecha_registro` date NOT NULL,
  `cenap_num_registro` int(5) NOT NULL,
  `cenap_tomo_registro` varchar(15) NOT NULL,
  `cenap_folio_registro` varchar(15) DEFAULT NULL,
  `cenap_registro_sistema` varchar(16) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `comercializadores`
--

CREATE TABLE IF NOT EXISTS `comercializadores` (
  `comer_rif` varchar(12) NOT NULL,
  `comer_razon_social` varchar(200) NOT NULL,
  `comer_fecha_vencim_rif` date NOT NULL,
  `comer_tipo_empresa` varchar(20) NOT NULL,
  `comer_patente` varchar(20) NOT NULL,
  `comer_fecha_hora` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `comer_punto_referencia` varchar(200) NOT NULL,
  `comer_avenida_calle` varchar(100) NOT NULL,
  `comer_local_oficina` varchar(30) NOT NULL,
  `comer_urbanizacion` varchar(50) NOT NULL,
  `comer_telf_oficina` varchar(20) NOT NULL,
  `comer_telf_fax` varchar(20) NOT NULL,
  `comer_pagina_web` varchar(50) NOT NULL,
  `comer_ciudad` varchar(50) NOT NULL,
  `comer_id_parroquia` int(4) NOT NULL,
  `comer_id_municipio` int(4) NOT NULL,
  `comer_id_estado` int(4) NOT NULL,
  `comer_id_zona_postal` int(4) NOT NULL,
  `comer_oficina_registro` varchar(100) NOT NULL,
  `comer_fecha_registro` date NOT NULL,
  `comer_num_registro` int(5) NOT NULL,
  `comer_tomo_registro` varchar(15) NOT NULL,
  `comer_folio_registro` varchar(15) DEFAULT NULL,
  `comer_registro_sistema` varchar(16) NOT NULL,
  `comer_fecha_registro_actual` date NOT NULL,
  `comer_id_estatus` int(1) NOT NULL DEFAULT '0',
  `adm_id_t` int(10) unsigned zerofill NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura Stand-in para la vista `datos_basicos_ca`
--
DROP VIEW IF EXISTS `datos_basicos_ca`;
CREATE TABLE IF NOT EXISTS `datos_basicos_ca` (
`tipo` varchar(2)
,`adm_id_t` int(10) unsigned zerofill
,`rif` varchar(12)
,`razon_social` varchar(200)
,`sucursal` int(3)
,`avenida` varchar(100)
,`pto_referencia` varchar(200)
,`local` varchar(30)
,`urbanizacion` varchar(50)
,`ciudad` varchar(50)
,`telefono` varchar(20)
,`fax` varchar(20)
);
-- --------------------------------------------------------

--
-- Estructura Stand-in para la vista `datos_basicos_com`
--
DROP VIEW IF EXISTS `datos_basicos_com`;
CREATE TABLE IF NOT EXISTS `datos_basicos_com` (
`tipo` varchar(3)
,`adm_id_t` int(10) unsigned zerofill
,`rif` varchar(12)
,`razon_social` varchar(200)
,`sucursal` int(1)
,`avenida` varchar(100)
,`pto_referencia` varchar(200)
,`local` varchar(30)
,`urbanizacion` varchar(50)
,`ciudad` varchar(50)
,`telefono` varchar(20)
,`fax` varchar(20)
);
-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `datos_creacion`
--

CREATE TABLE IF NOT EXISTS `datos_creacion` (
  `rif` varchar(12) NOT NULL,
  `num_decreto` varchar(8) DEFAULT NULL,
  `fecha_decreto` date DEFAULT NULL,
  `num_gaceta` varchar(8) NOT NULL,
  `fecha_gaceta` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `datos_direccion`
--

CREATE TABLE IF NOT EXISTS `datos_direccion` (
  `rif` varchar(12) NOT NULL,
  `avenida_calle_direccion` varchar(100) NOT NULL,
  `local_oficina_direccion` varchar(30) NOT NULL,
  `urb_direccion` varchar(50) NOT NULL,
  `telefono_oficina` varchar(20) NOT NULL,
  `telefono_fax` varchar(20) DEFAULT NULL,
  `pagina_web` varchar(50) DEFAULT NULL,
  `id_ciudad` varchar(50) DEFAULT NULL,
  `id_parroquia` int(4) NOT NULL,
  `id_municipio` int(4) NOT NULL,
  `id_estado` int(4) NOT NULL,
  `id_zona_postal` int(4) NOT NULL,
  `id_sujeto_pasivo` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `datos_junta_directiva`
--

CREATE TABLE IF NOT EXISTS `datos_junta_directiva` (
  `rif` varchar(12) NOT NULL,
  `cedula` varchar(10) NOT NULL,
  `nombre_apellido` varchar(50) NOT NULL,
  `cargo` varchar(50) NOT NULL,
  `num_gaceta_estadal` varchar(8) NOT NULL,
  `fecha_gaceta_estadal` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `datos_pago`
--

CREATE TABLE IF NOT EXISTS `datos_pago` (
  `rif` varchar(12) NOT NULL,
  `num_deposito` varchar(20) NOT NULL,
  `fecha_deposito` date NOT NULL,
  `id_banco` int(4) NOT NULL,
  `monto` int(20) NOT NULL DEFAULT '0',
  `id_sujeto_pasivo` int(1) NOT NULL,
  `id_sucursal` int(3) NOT NULL DEFAULT '0',
  `rif_iobpas_original` varchar(12) NOT NULL,
  `liqui_secuencial` int(11) DEFAULT NULL,
  `liqui_año` int(4) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura Stand-in para la vista `datos_pago_2`
--
DROP VIEW IF EXISTS `datos_pago_2`;
CREATE TABLE IF NOT EXISTS `datos_pago_2` (
);
-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `datos_programa`
--

CREATE TABLE IF NOT EXISTS `datos_programa` (
  `pro_rif` varchar(12) NOT NULL,
  `pro_nombre` varchar(50) NOT NULL,
  `pro_version` varchar(8) NOT NULL,
  `pro_licencia` varchar(15) NOT NULL,
  `pro_lenguaje` varchar(30) NOT NULL,
  `pro_base_datos` varchar(30) NOT NULL,
  `pro_transacciones_dia` int(10) NOT NULL,
  `pro_so_servidor` varchar(30) NOT NULL,
  `pro_so_centroapuesta` varchar(30) NOT NULL,
  `pro_hosting` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `pro_num_registro` int(3) NOT NULL,
  `pro_estatus` int(1) NOT NULL,
  `adm_id_t` int(10) unsigned zerofill NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `datos_usuario`
--

CREATE TABLE IF NOT EXISTS `datos_usuario` (
  `datos_rif` varchar(12) NOT NULL,
  `datos_cedula` varchar(10) NOT NULL,
  `datos_nombres` varchar(20) NOT NULL,
  `datos_apellidos` varchar(20) NOT NULL,
  `datos_cargo` varchar(50) NOT NULL,
  `datos_codigo` varchar(10) DEFAULT NULL,
  `datos_rif_iobpas` varchar(12) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `estado`
--

CREATE TABLE IF NOT EXISTS `estado` (
  `id_estado` int(4) NOT NULL,
  `descripcion_estado` varchar(40) NOT NULL,
  `id_region_estado` int(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `historico_registro`
--

CREATE TABLE IF NOT EXISTS `historico_registro` (
  `hisre_usuario` varchar(12) NOT NULL,
  `hisre_fecha_hora` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `hisre_estatus_registro` int(3) NOT NULL,
  `hisre_rif_comercializador` varchar(12) NOT NULL,
  `hisre_rif_pst` varchar(12) NOT NULL,
  `hisre_pro_num_registro` int(3) NOT NULL,
  `hisre_rif_operador` varchar(12) NOT NULL,
  `hisre_rif_iobpas` varchar(12) NOT NULL,
  `hisre_id_juego` int(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `historico_registro_centro`
--

CREATE TABLE IF NOT EXISTS `historico_registro_centro` (
  `hisrecen_usuario` varchar(12) NOT NULL,
  `hisrecen_fecha_hora` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `hisrecen_estatus_registro` int(3) NOT NULL,
  `hisrecen_rif_centroapuesta` varchar(12) NOT NULL,
  `hisrecen_rif_comercializador` varchar(12) NOT NULL,
  `hisrecen_rif_pst` varchar(12) NOT NULL,
  `hisrecen_pro_num_registro` int(3) NOT NULL,
  `hisrecen_rif_operador` varchar(12) NOT NULL,
  `hisrecen_rif_iobpas` varchar(12) NOT NULL,
  `hisrecen_id_juego` int(4) NOT NULL,
  `hisrecen_id_sucursal` int(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `iobpas`
--

CREATE TABLE IF NOT EXISTS `iobpas` (
  `rif` varchar(12) NOT NULL,
  `razon_social` varchar(200) NOT NULL,
  `fecha_vencimiento_rif` date NOT NULL,
  `num_registro` varchar(6) NOT NULL,
  `nombre_abrev` varchar(20) NOT NULL,
  `id_estatus` int(1) NOT NULL DEFAULT '1',
  `adm_id_t` int(10) unsigned zerofill NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `juegos`
--

CREATE TABLE IF NOT EXISTS `juegos` (
  `juego_rif_iobpas` varchar(12) NOT NULL,
  `juego_id` int(4) NOT NULL,
  `juego_descripcion` varchar(40) NOT NULL,
  `juego_estatus` int(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `liquidacion`
--

CREATE TABLE IF NOT EXISTS `liquidacion` (
  `liqui_rif` varchar(12) NOT NULL,
  `liqui_secuencial` int(11) NOT NULL,
  `liqui_año` int(4) NOT NULL,
  `liqui_fecha` date NOT NULL,
  `liqui_id_sujeto_pasivo` int(4) NOT NULL,
  `liqui_id_sucursal` int(3) NOT NULL DEFAULT '0',
  `liqui_codigo_concepto` int(3) NOT NULL,
  `liqui_monto` float NOT NULL,
  `liqui_rif_usuario` varchar(12) NOT NULL,
  `liqui_estatus` int(3) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `listas`
--

CREATE TABLE IF NOT EXISTS `listas` (
  `lista_id` int(3) NOT NULL,
  `lista_desclista` varchar(100) NOT NULL,
  `lista_codigo` int(3) NOT NULL,
  `lista_desccodigo` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `logs`
--

CREATE TABLE IF NOT EXISTS `logs` (
`logs_id` int(11) NOT NULL,
  `logs_fecha_hora` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `logs_rif_usuario` varchar(12) NOT NULL,
  `logs_descripcion` varchar(512) NOT NULL
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=24400 ;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `maquina_fiscal_apuesta`
--

CREATE TABLE IF NOT EXISTS `maquina_fiscal_apuesta` (
  `mfa_rif_ca` varchar(12) NOT NULL,
  `mfa_sucursal` int(11) NOT NULL,
  `mfa_razon_social` varchar(200) NOT NULL,
  `mfa_rif_proveedor` varchar(200) NOT NULL,
  `mfa_rif_distribuidor` varchar(200) NOT NULL,
  `mfa_num_patente` varchar(200) NOT NULL,
  `mfa_fecha_instalacion` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `mfa_num_maquina` varchar(30) NOT NULL,
  `mfa_fecha_declaracion` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `mfa_avenida_calle` varchar(100) NOT NULL,
  `mfa_local_oficina` varchar(30) NOT NULL,
  `mfa_telefono_oficina` varchar(20) NOT NULL,
  `mfa_ciudad` varchar(50) NOT NULL,
  `mfa_parroquia` varchar(30) NOT NULL,
  `mfa_municipio` varchar(30) NOT NULL,
  `mfa_estado` varchar(30) NOT NULL,
  `mfa_nro_taquilla` int(11) DEFAULT NULL,
  `mfa_sector` varchar(256) DEFAULT NULL,
  `mfa_fecha_distribuidor` date DEFAULT NULL,
  `mfa_fecha_proveedor` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `morosos`
--

CREATE TABLE IF NOT EXISTS `morosos` (
  `moros_rif_cedula` varchar(12) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `moros_estatus` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `municipio`
--

CREATE TABLE IF NOT EXISTS `municipio` (
  `id_municipio` int(4) NOT NULL,
  `id_estado_municipio` int(4) NOT NULL,
  `descripcion_municipio` varchar(80) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `opciones`
--

CREATE TABLE IF NOT EXISTS `opciones` (
`op_id` int(3) NOT NULL,
  `op_nombre` varchar(200) NOT NULL,
  `op_ruta` varchar(200) NOT NULL,
  `op_modulo_ruta` varchar(100) NOT NULL,
  `op_estado` int(1) NOT NULL DEFAULT '1',
  `op_modulo` int(2) NOT NULL
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=93 ;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `operadoras`
--

CREATE TABLE IF NOT EXISTS `operadoras` (
  `rif` varchar(12) NOT NULL,
  `razon_social` varchar(200) NOT NULL,
  `fecha_vencimiento_rif` date NOT NULL,
  `fecha_registro` date NOT NULL,
  `hora_registro` time NOT NULL,
  `id_estatus` int(1) NOT NULL,
  `adm_id_t` int(10) unsigned zerofill NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `operadoras_juegos`
--

CREATE TABLE IF NOT EXISTS `operadoras_juegos` (
  `rif_operador` varchar(12) NOT NULL,
  `rif_iobpas` varchar(12) NOT NULL,
  `id_juego` int(4) NOT NULL,
  `oficina_registro` varchar(250) NOT NULL,
  `fecha_registro` date NOT NULL,
  `num_registro` int(5) NOT NULL,
  `tomo_registro` varchar(15) NOT NULL,
  `folio_registro` varchar(5) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  `id_estatus` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura Stand-in para la vista `pago_x_ano2`
--
DROP VIEW IF EXISTS `pago_x_ano2`;
CREATE TABLE IF NOT EXISTS `pago_x_ano2` (
`rif` varchar(12)
,`sucursal` int(11)
,`dep_2009` varchar(20)
,`m09` decimal(41,0)
,`dep_2010` varchar(20)
,`m10` decimal(41,0)
,`dep_2011` varchar(20)
,`m11` decimal(41,0)
,`dep_2012` varchar(20)
,`m12` decimal(41,0)
,`dep_2013` varchar(20)
,`m13` decimal(41,0)
,`dep_2014` varchar(20)
,`m14` decimal(41,0)
);
-- --------------------------------------------------------

--
-- Estructura Stand-in para la vista `pago_x_año`
--
DROP VIEW IF EXISTS `pago_x_año`;
CREATE TABLE IF NOT EXISTS `pago_x_año` (
);
-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `parroquia`
--

CREATE TABLE IF NOT EXISTS `parroquia` (
  `id_parroquia` int(4) NOT NULL,
  `id_municipio_parroquia` int(4) NOT NULL,
  `id_estado_parroquia` int(4) NOT NULL,
  `descripcion_parroquia` varchar(60) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `permisos`
--

CREATE TABLE IF NOT EXISTS `permisos` (
`pe_id_permiso` int(2) NOT NULL,
  `pe_id_permiso_usuario` int(2) NOT NULL,
  `pe_tipo_sujeto` int(2) NOT NULL,
  `pe_id_opcion` int(2) NOT NULL,
  `pe_estado` int(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=141 ;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `pst`
--

CREATE TABLE IF NOT EXISTS `pst` (
  `pst_rif` varchar(12) NOT NULL,
  `pst_razon_social` varchar(200) NOT NULL,
  `pst_fecha_vencimiento_rif` date NOT NULL,
  `pst_cant_centro_apuesta` int(6) NOT NULL,
  `pst_ventas_dia` int(10) NOT NULL,
  `pst_fecha_hora` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `pst_maquina`
--

CREATE TABLE IF NOT EXISTS `pst_maquina` (
  `rif_pst` varchar(12) COLLATE utf8_spanish_ci NOT NULL,
  `num_programa` int(3) NOT NULL,
  `rif_com` varchar(12) COLLATE utf8_spanish_ci NOT NULL,
  `rif_ca` varchar(12) COLLATE utf8_spanish_ci NOT NULL,
  `id_sucur` int(3) NOT NULL,
  `num_maquina` varchar(30) COLLATE utf8_spanish_ci NOT NULL,
  `cedula_tecnico` varchar(10) COLLATE utf8_spanish_ci NOT NULL,
  `estatus` int(1) NOT NULL,
  `fecha_hora` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `pst_operador`
--

CREATE TABLE IF NOT EXISTS `pst_operador` (
  `rif_pst` varchar(12) NOT NULL,
  `pro_num_registro` int(3) NOT NULL,
  `rif_operador` varchar(12) NOT NULL,
  `rif_iobpas` varchar(12) NOT NULL,
  `id_juego` int(4) NOT NULL,
  `id_estatus` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `registro_centro_apuesta`
--

CREATE TABLE IF NOT EXISTS `registro_centro_apuesta` (
  `recen_rif_centroapuesta` varchar(12) NOT NULL,
  `recen_rif_comercializador` varchar(12) NOT NULL,
  `recen_rif_pst` varchar(12) NOT NULL,
  `recen_pro_num_registro` int(3) NOT NULL,
  `recen_rif_operador` varchar(12) NOT NULL,
  `recen_rif_iobpas` varchar(12) NOT NULL,
  `recen_id_juego` int(4) NOT NULL,
  `recen_estatus_registro` int(3) NOT NULL,
  `recen_id_sucursal` int(3) NOT NULL,
  `recen_fecha_autorizacion_iobpas` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `recen_folios_expediente` int(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `registro_comercializador`
--

CREATE TABLE IF NOT EXISTS `registro_comercializador` (
  `recom_rif_comercializador` varchar(12) NOT NULL,
  `recom_rif_pst` varchar(12) NOT NULL,
  `recom_pro_num_registro` int(3) NOT NULL,
  `recom_rif_operador` varchar(12) NOT NULL,
  `recom_rif_iobpas` varchar(12) NOT NULL,
  `recom_id_juego` int(4) NOT NULL,
  `recom_estatus_registro` int(3) NOT NULL,
  `recom_fecha_autorizacion_iobpas` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `recom_folios_expediente` int(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `representante_legal`
--

CREATE TABLE IF NOT EXISTS `representante_legal` (
  `rif` varchar(12) NOT NULL,
  `cedula` varchar(10) NOT NULL,
  `apellidos` varchar(30) NOT NULL,
  `nombres` varchar(30) NOT NULL,
  `telefono_celular` varchar(20) NOT NULL,
  `correo` varchar(50) NOT NULL,
  `id_sujeto_pasivo` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura Stand-in para la vista `sts_juegos`
--
DROP VIEW IF EXISTS `sts_juegos`;
CREATE TABLE IF NOT EXISTS `sts_juegos` (
`tipo` varchar(3)
,`adm_id_t` int(11) unsigned
,`rif_ca_com` varchar(12)
,`razon_social_ca_com` varchar(200)
,`sucursal` bigint(20)
,`razon_social_com_oper` varchar(200)
,`pst` varchar(50)
,`iobpas` varchar(12)
,`juego` varchar(40)
,`estatus` varchar(255)
);
-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `sucursal`
--

CREATE TABLE IF NOT EXISTS `sucursal` (
  `sucur_rif` varchar(12) NOT NULL,
  `sucur_id` int(3) NOT NULL,
  `sucur_denominacion` varchar(100) DEFAULT NULL,
  `sucur_patente` varchar(20) NOT NULL,
  `sucur_avenida_calle` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `sucur_punto_referencia` varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `sucur_local_oficina` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `sucur_urbanizacion` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `sucur_telf_oficina` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `sucur_telf_fax` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `sucur_pagina_web` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `sucur_ciudad` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `sucur_id_parroquia` int(4) NOT NULL,
  `sucur_id_municipio` int(4) NOT NULL,
  `sucur_id_estado` int(4) NOT NULL,
  `sucur_id_zona_postal` int(4) NOT NULL,
  `sucur_fecha_hora` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `sucur_estatus` int(1) NOT NULL,
  `sucur_taquillas` int(3) NOT NULL,
  `adm_id_t` int(10) unsigned zerofill NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `sujetos_pasivos`
--

CREATE TABLE IF NOT EXISTS `sujetos_pasivos` (
  `id_sujeto_pasivo` int(1) NOT NULL,
  `sujeto_pasivo` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura Stand-in para la vista `todo`
--
DROP VIEW IF EXISTS `todo`;
CREATE TABLE IF NOT EXISTS `todo` (
);
-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `usuario`
--

CREATE TABLE IF NOT EXISTS `usuario` (
  `rif` varchar(12) NOT NULL,
  `correo` varchar(50) NOT NULL,
  `correo_alt` varchar(50) NOT NULL,
  `clave` varchar(32) NOT NULL,
  `id_sujeto_pasivo` int(4) NOT NULL,
  `fecha_registro` date NOT NULL,
  `hora_registro` time NOT NULL,
  `ip` varchar(15) NOT NULL,
  `id_permiso` int(11) NOT NULL,
  `id_estatus` int(2) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `zona_postal`
--

CREATE TABLE IF NOT EXISTS `zona_postal` (
`id_postal` int(4) NOT NULL,
  `id_zona_postal` int(4) NOT NULL,
  `descripcion_zona_postal` varchar(60) NOT NULL,
  `id_estado_zona_postal` int(4) NOT NULL
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2128 ;

-- --------------------------------------------------------

--
-- Estructura para la vista `datos_basicos_ca`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`conalot`@`localhost` SQL SECURITY DEFINER VIEW `datos_basicos_ca` AS select 'CA' AS `tipo`,`s`.`adm_id_t` AS `adm_id_t`,`s`.`sucur_rif` AS `rif`,`ca`.`cenap_razon_social` AS `razon_social`,`s`.`sucur_id` AS `sucursal`,`s`.`sucur_avenida_calle` AS `avenida`,`s`.`sucur_punto_referencia` AS `pto_referencia`,`s`.`sucur_local_oficina` AS `local`,`s`.`sucur_urbanizacion` AS `urbanizacion`,`s`.`sucur_ciudad` AS `ciudad`,`s`.`sucur_telf_oficina` AS `telefono`,`s`.`sucur_telf_fax` AS `fax` from (`sucursal` `s` join `centro_apuesta` `ca`) where (`ca`.`cenap_rif` = `s`.`sucur_rif`);

-- --------------------------------------------------------

--
-- Estructura para la vista `datos_basicos_com`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`conalot`@`localhost` SQL SECURITY DEFINER VIEW `datos_basicos_com` AS select 'COM' AS `tipo`,`comercializadores`.`adm_id_t` AS `adm_id_t`,`comercializadores`.`comer_rif` AS `rif`,`comercializadores`.`comer_razon_social` AS `razon_social`,0 AS `sucursal`,`comercializadores`.`comer_avenida_calle` AS `avenida`,`comercializadores`.`comer_punto_referencia` AS `pto_referencia`,`comercializadores`.`comer_local_oficina` AS `local`,`comercializadores`.`comer_urbanizacion` AS `urbanizacion`,`comercializadores`.`comer_ciudad` AS `ciudad`,`comercializadores`.`comer_telf_oficina` AS `telefono`,`comercializadores`.`comer_telf_fax` AS `fax` from `comercializadores`;

-- --------------------------------------------------------

--
-- Estructura para la vista `datos_pago_2`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`conalot`@`localhost` SQL SECURITY DEFINER VIEW `datos_pago_2` AS select `todo`.`rif` AS `rif`,`todo`.`sucursal` AS `sucursal`,`todo`.`razon_social` AS `razon_social`,sum(`todo`.`m09`) AS `a_2009`,sum(`todo`.`d09`) AS `d_2009`,sum(`todo`.`m10`) AS `a_2010`,sum(`todo`.`d10`) AS `d_2010`,sum(`todo`.`m11`) AS `a_2011`,sum(`todo`.`d11`) AS `d_2011`,sum(`todo`.`m12`) AS `a_2012`,sum(`todo`.`d12`) AS `d_2012`,sum(`todo`.`m13`) AS `a_2013`,sum(`todo`.`d13`) AS `d_2013`,sum(`todo`.`m14`) AS `a_2014`,sum(`todo`.`d14`) AS `d_2014`,sum(`todo`.`m15`) AS `a_2015`,sum(`todo`.`d15`) AS `d_2015`,sum(`todo`.`sin_año`) AS `sinAno`,sum(`todo`.`dSin`) AS `d_Sin` from `todo` group by 1,2 order by 1;

-- --------------------------------------------------------

--
-- Estructura para la vista `pago_x_ano2`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`cpses_conQOSq8Nx`@`localhost` SQL SECURITY DEFINER VIEW `pago_x_ano2` AS select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `sucursal`,`datos_pago`.`num_deposito` AS `dep_2009`,sum(`datos_pago`.`monto`) AS `m09`,' ' AS `dep_2010`,0 AS `m10`,' ' AS `dep_2011`,0 AS `m11`,' ' AS `dep_2012`,0 AS `m12`,' ' AS `dep_2013`,0 AS `m13`,' ' AS `dep_2014`,0 AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2009')) union select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `id_sucursal`,' ' AS `dep_2009`,0 AS `m09`,`datos_pago`.`num_deposito` AS `dep_2010`,sum(`datos_pago`.`monto`) AS `m10`,' ' AS `dep_2011`,0 AS `m11`,' ' AS `dep_2012`,0 AS `m12`,' ' AS `dep_2013`,0 AS `m13`,' ' AS `dep_2014`,0 AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2010')) union select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `id_sucursal`,' ' AS `dep_2009`,0 AS `m09`,' ' AS `dep_2010`,0 AS `m10`,`datos_pago`.`num_deposito` AS `dep_2011`,sum(`datos_pago`.`monto`) AS `m11`,' ' AS `dep_2012`,0 AS `m12`,' ' AS `dep_2013`,0 AS `m13`,' ' AS `dep_2014`,0 AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2011')) union select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `id_sucursal`,' ' AS `dep_2009`,0 AS `m09`,' ' AS `dep_2010`,0 AS `m10`,' ' AS `dep_2011`,0 AS `m11`,`datos_pago`.`num_deposito` AS `dep_2012`,sum(`datos_pago`.`monto`) AS `m12`,' ' AS `dep_2013`,0 AS `m13`,' ' AS `dep_2014`,0 AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2012')) union select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `id_sucursal`,' ' AS `dep_2009`,0 AS `m09`,' ' AS `dep_2010`,0 AS `m10`,' ' AS `dep_2011`,0 AS `m11`,' ' AS `dep_2012`,0 AS `m12`,`datos_pago`.`num_deposito` AS `dep_2013`,sum(`datos_pago`.`monto`) AS `m13`,' ' AS `dep_2014`,0 AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2013')) union select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `id_sucursal`,' ' AS `dep_2009`,0 AS `m09`,' ' AS `dep_2010`,0 AS `m10`,' ' AS `dep_2011`,0 AS `m11`,' ' AS `dep_2012`,0 AS `m12`,' ' AS `dep_2013`,0 AS `m13`,`datos_pago`.`num_deposito` AS `dep_2014`,sum(`datos_pago`.`monto`) AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2014'));

-- --------------------------------------------------------

--
-- Estructura para la vista `pago_x_año`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`cpses_conQOSq8Nx`@`localhost` SQL SECURITY DEFINER VIEW `pago_x_año` AS select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `sucursal`,sum(`datos_pago`.`monto`) AS `m09`,0 AS `m10`,0 AS `m11`,0 AS `m12`,0 AS `m13`,0 AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2009')) group by `datos_pago`.`id_sucursal` union select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `id_sucursal`,0 AS `m09`,sum(`datos_pago`.`monto`) AS `m10`,0 AS `m11`,0 AS `m12`,0 AS `m13`,0 AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2010')) group by `datos_pago`.`id_sucursal` union select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `id_sucursal`,0 AS `m09`,0 AS `m10`,sum(`datos_pago`.`monto`) AS `m11`,0 AS `m12`,0 AS `m13`,0 AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2011')) group by `datos_pago`.`id_sucursal` union select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `id_sucursal`,0 AS `m09`,0 AS `m10`,0 AS `m11`,sum(`datos_pago`.`monto`) AS `m12`,0 AS `m13`,0 AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2012')) group by `datos_pago`.`id_sucursal` union select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `id_sucursal`,0 AS `m09`,0 AS `m10`,0 AS `m11`,0 AS `m12`,sum(`datos_pago`.`monto`) AS `m13`,0 AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2013')) group by `datos_pago`.`id_sucursal` union select `datos_pago`.`rif` AS `rif`,`datos_pago`.`id_sucursal` AS `id_sucursal`,0 AS `m09`,0 AS `m10`,0 AS `m11`,0 AS `m12`,0 AS `m13`,sum(`datos_pago`.`monto`) AS `m14` from `datos_pago` where ((`datos_pago`.`rif` = 'J-29827593-6') and (year(`datos_pago`.`fecha_deposito`) = '2014')) group by `datos_pago`.`id_sucursal`;

-- --------------------------------------------------------

--
-- Estructura para la vista `sts_juegos`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`conalot`@`localhost` SQL SECURITY DEFINER VIEW `sts_juegos` AS select 'CA' AS `tipo`,`s`.`adm_id_t` AS `adm_id_t`,`rca`.`recen_rif_centroapuesta` AS `rif_ca_com`,`ca`.`cenap_razon_social` AS `razon_social_ca_com`,`rca`.`recen_id_sucursal` AS `sucursal`,`com`.`comer_razon_social` AS `razon_social_com_oper`,`dp`.`pro_nombre` AS `pst`,`rca`.`recen_rif_iobpas` AS `iobpas`,`j`.`juego_descripcion` AS `juego`,`l`.`lista_desccodigo` AS `estatus` from ((((((`registro_centro_apuesta` `rca` join `centro_apuesta` `ca`) join `comercializadores` `com`) join `datos_programa` `dp`) join `juegos` `j`) join `listas` `l`) join `sucursal` `s`) where ((`ca`.`cenap_rif` = `rca`.`recen_rif_centroapuesta`) and (`com`.`comer_rif` = `rca`.`recen_rif_comercializador`) and (`dp`.`pro_rif` = `rca`.`recen_rif_pst`) and (`j`.`juego_rif_iobpas` = `rca`.`recen_rif_iobpas`) and (`j`.`juego_id` = `rca`.`recen_id_juego`) and (`l`.`lista_codigo` = `rca`.`recen_estatus_registro`) and (`l`.`lista_id` = 1) and (`s`.`sucur_rif` = `rca`.`recen_rif_centroapuesta`) and (`s`.`sucur_id` = `rca`.`recen_id_sucursal`)) union all select 'COM' AS `tipo`,`c`.`adm_id_t` AS `adm_id_t`,`rc`.`recom_rif_comercializador` AS `recom_rif_comercializador`,`c`.`comer_razon_social` AS `comer_razon_social`,0 AS `recom_id_sucursal`,`o`.`razon_social` AS `razon_social`,`dp`.`pro_nombre` AS `pro_nombre`,`rc`.`recom_rif_iobpas` AS `recom_rif_iobpas`,`j`.`juego_descripcion` AS `juego_descripcion`,`l`.`lista_desccodigo` AS `lista_desccodigo` from (((((`registro_comercializador` `rc` join `comercializadores` `c`) join `operadoras` `o`) join `datos_programa` `dp`) join `juegos` `j`) join `listas` `l`) where ((`c`.`comer_rif` = `rc`.`recom_rif_comercializador`) and (`o`.`rif` = `rc`.`recom_rif_operador`) and (`dp`.`pro_rif` = `rc`.`recom_rif_pst`) and (`j`.`juego_rif_iobpas` = `rc`.`recom_rif_iobpas`) and (`j`.`juego_id` = `rc`.`recom_id_juego`) and (`l`.`lista_codigo` = `rc`.`recom_estatus_registro`) and (`l`.`lista_id` = 1));

-- --------------------------------------------------------

--
-- Estructura para la vista `todo`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`conalot`@`localhost` SQL SECURITY DEFINER VIEW `todo` AS select `a`.`sucur_rif` AS `rif`,`ca`.`cenap_razon_social` AS `razon_social`,`a`.`sucur_id` AS `sucursal`,`a`.`sucur_denominacion` AS `denominacion`,`b`.`liqui_año` AS `año`,sum(`b`.`monto`) AS `m09`,`b`.`num_deposito` AS `d09`,0 AS `m10`,0 AS `d10`,0 AS `m11`,0 AS `d11`,0 AS `m12`,0 AS `d12`,0 AS `m13`,0 AS `d13`,0 AS `m14`,0 AS `d14`,0 AS `m15`,0 AS `d15`,0 AS `sin_año`,0 AS `dSin` from ((`sucursal` `a` left join `datos_pago` `b` on(((`a`.`sucur_rif` = `b`.`rif`) and (`a`.`sucur_id` = `b`.`id_sucursal`)))) join `centro_apuesta` `ca`) where ((`b`.`liqui_año` = 2009) and (`ca`.`cenap_rif` = `a`.`sucur_rif`)) group by `a`.`sucur_rif`,`a`.`sucur_id`,`a`.`sucur_denominacion`,`b`.`liqui_año` union select `a`.`sucur_rif` AS `sucur_rif`,`ca`.`cenap_razon_social` AS `cenap_razon_social`,`a`.`sucur_id` AS `sucur_id`,`a`.`sucur_denominacion` AS `sucur_denominacion`,`b`.`liqui_año` AS `liqui_año`,0 AS `m09`,0 AS `d09`,sum(`b`.`monto`) AS `m10`,`b`.`num_deposito` AS `d10`,0 AS `m11`,0 AS `d11`,0 AS `m12`,0 AS `d12`,0 AS `m13`,0 AS `d13`,0 AS `m14`,0 AS `d14`,0 AS `m15`,0 AS `d15`,0 AS `sin_año`,0 AS `dSin` from ((`sucursal` `a` left join `datos_pago` `b` on(((`a`.`sucur_rif` = `b`.`rif`) and (`a`.`sucur_id` = `b`.`id_sucursal`)))) join `centro_apuesta` `ca`) where ((`b`.`liqui_año` = 2010) and (`ca`.`cenap_rif` = `a`.`sucur_rif`)) group by `a`.`sucur_rif`,`a`.`sucur_id`,`a`.`sucur_denominacion`,`b`.`liqui_año` union select `a`.`sucur_rif` AS `sucur_rif`,`ca`.`cenap_razon_social` AS `cenap_razon_social`,`a`.`sucur_id` AS `sucur_id`,`a`.`sucur_denominacion` AS `sucur_denominacion`,`b`.`liqui_año` AS `liqui_año`,0 AS `m09`,0 AS `d09`,0 AS `m10`,0 AS `d10`,sum(`b`.`monto`) AS `m11`,`b`.`num_deposito` AS `d11`,0 AS `m12`,0 AS `d12`,0 AS `m13`,0 AS `d13`,0 AS `m14`,0 AS `d14`,0 AS `m15`,0 AS `d15`,0 AS `sin_año`,0 AS `dSin` from ((`sucursal` `a` left join `datos_pago` `b` on(((`a`.`sucur_rif` = `b`.`rif`) and (`a`.`sucur_id` = `b`.`id_sucursal`)))) join `centro_apuesta` `ca`) where ((`b`.`liqui_año` = 2011) and (`ca`.`cenap_rif` = `a`.`sucur_rif`)) group by `a`.`sucur_rif`,`a`.`sucur_id`,`a`.`sucur_denominacion`,`b`.`liqui_año` union select `a`.`sucur_rif` AS `sucur_rif`,`ca`.`cenap_razon_social` AS `cenap_razon_social`,`a`.`sucur_id` AS `sucur_id`,`a`.`sucur_denominacion` AS `sucur_denominacion`,`b`.`liqui_año` AS `liqui_año`,0 AS `m09`,0 AS `d09`,0 AS `m10`,0 AS `d10`,0 AS `m11`,0 AS `d11`,sum(`b`.`monto`) AS `m12`,`b`.`num_deposito` AS `d12`,0 AS `m13`,0 AS `d13`,0 AS `m14`,0 AS `d14`,0 AS `m15`,0 AS `d15`,0 AS `sin_año`,0 AS `dSin` from ((`sucursal` `a` left join `datos_pago` `b` on(((`a`.`sucur_rif` = `b`.`rif`) and (`a`.`sucur_id` = `b`.`id_sucursal`)))) join `centro_apuesta` `ca`) where ((`b`.`liqui_año` = 2012) and (`ca`.`cenap_rif` = `a`.`sucur_rif`)) group by `a`.`sucur_rif`,`a`.`sucur_id`,`a`.`sucur_denominacion`,`b`.`liqui_año` union select `a`.`sucur_rif` AS `sucur_rif`,`ca`.`cenap_razon_social` AS `cenap_razon_social`,`a`.`sucur_id` AS `sucur_id`,`a`.`sucur_denominacion` AS `sucur_denominacion`,`b`.`liqui_año` AS `liqui_año`,0 AS `m09`,0 AS `d09`,0 AS `m10`,0 AS `d10`,0 AS `m11`,0 AS `d11`,0 AS `m12`,0 AS `d12`,sum(`b`.`monto`) AS `m13`,`b`.`num_deposito` AS `d13`,0 AS `m14`,0 AS `d14`,0 AS `m15`,0 AS `d15`,0 AS `sin_año`,0 AS `dSin` from ((`sucursal` `a` left join `datos_pago` `b` on(((`a`.`sucur_rif` = `b`.`rif`) and (`a`.`sucur_id` = `b`.`id_sucursal`)))) join `centro_apuesta` `ca`) where ((`b`.`liqui_año` = 2013) and (`ca`.`cenap_rif` = `a`.`sucur_rif`)) group by `a`.`sucur_rif`,`a`.`sucur_id`,`a`.`sucur_denominacion`,`b`.`liqui_año` union select `a`.`sucur_rif` AS `sucur_rif`,`ca`.`cenap_razon_social` AS `cenap_razon_social`,`a`.`sucur_id` AS `sucur_id`,`a`.`sucur_denominacion` AS `sucur_denominacion`,`b`.`liqui_año` AS `liqui_año`,0 AS `m09`,0 AS `d09`,0 AS `m10`,0 AS `d10`,0 AS `m11`,0 AS `d11`,0 AS `m12`,0 AS `d12`,0 AS `m13`,0 AS `d13`,sum(`b`.`monto`) AS `m14`,`b`.`num_deposito` AS `d14`,0 AS `m15`,0 AS `d15`,0 AS `sin_año`,0 AS `dSin` from ((`sucursal` `a` left join `datos_pago` `b` on(((`a`.`sucur_rif` = `b`.`rif`) and (`a`.`sucur_id` = `b`.`id_sucursal`)))) join `centro_apuesta` `ca`) where ((`b`.`liqui_año` = 2014) and (`ca`.`cenap_rif` = `a`.`sucur_rif`)) group by `a`.`sucur_rif`,`a`.`sucur_id`,`a`.`sucur_denominacion`,`b`.`liqui_año` union select `a`.`sucur_rif` AS `sucur_rif`,`ca`.`cenap_razon_social` AS `cenap_razon_social`,`a`.`sucur_id` AS `sucur_id`,`a`.`sucur_denominacion` AS `sucur_denominacion`,`b`.`liqui_año` AS `liqui_año`,0 AS `m09`,0 AS `d09`,0 AS `m10`,0 AS `d10`,0 AS `m11`,0 AS `d11`,0 AS `m12`,0 AS `d12`,0 AS `m13`,0 AS `d13`,0 AS `m14`,0 AS `d14`,sum(`b`.`monto`) AS `m15`,`b`.`num_deposito` AS `d15`,0 AS `sin_año`,0 AS `dSin` from ((`sucursal` `a` left join `datos_pago` `b` on(((`a`.`sucur_rif` = `b`.`rif`) and (`a`.`sucur_id` = `b`.`id_sucursal`)))) join `centro_apuesta` `ca`) where ((`b`.`liqui_año` = 2015) and (`ca`.`cenap_rif` = `a`.`sucur_rif`)) group by `a`.`sucur_rif`,`a`.`sucur_id`,`a`.`sucur_denominacion`,`b`.`liqui_año` union select `a`.`sucur_rif` AS `sucur_rif`,`ca`.`cenap_razon_social` AS `cenap_razon_social`,`a`.`sucur_id` AS `sucur_id`,`a`.`sucur_denominacion` AS `sucur_denominacion`,`b`.`liqui_año` AS `liqui_año`,0 AS `m09`,0 AS `d09`,0 AS `m10`,0 AS `d10`,0 AS `m11`,0 AS `d11`,0 AS `m12`,0 AS `d12`,0 AS `m13`,0 AS `d13`,0 AS `m14`,0 AS `d14`,0 AS `m15`,0 AS `d15`,sum(`b`.`monto`) AS `sin_año`,count(`b`.`monto`) AS `dSin` from ((`sucursal` `a` left join `datos_pago` `b` on(((`a`.`sucur_rif` = `b`.`rif`) and (`a`.`sucur_id` = `b`.`id_sucursal`)))) join `centro_apuesta` `ca`) where ((`b`.`liqui_año` = 0) and (`ca`.`cenap_rif` = `a`.`sucur_rif`)) group by `a`.`sucur_rif`,`a`.`sucur_id`,`a`.`sucur_denominacion`,`b`.`liqui_año`;

--
-- Índices para tablas volcadas
--

--
-- Indices de la tabla `banco`
--
ALTER TABLE `banco`
 ADD PRIMARY KEY (`banco_id`);

--
-- Indices de la tabla `centros_autorizados`
--
ALTER TABLE `centros_autorizados`
 ADD PRIMARY KEY (`cenau_rif_centro_apuesta`,`cenau_id_sucursal`);

--
-- Indices de la tabla `centro_apuesta`
--
ALTER TABLE `centro_apuesta`
 ADD PRIMARY KEY (`cenap_rif`);

--
-- Indices de la tabla `comercializadores`
--
ALTER TABLE `comercializadores`
 ADD PRIMARY KEY (`comer_rif`);

--
-- Indices de la tabla `datos_creacion`
--
ALTER TABLE `datos_creacion`
 ADD PRIMARY KEY (`rif`);

--
-- Indices de la tabla `datos_direccion`
--
ALTER TABLE `datos_direccion`
 ADD PRIMARY KEY (`rif`,`id_sujeto_pasivo`), ADD KEY `id_parroquia` (`id_parroquia`), ADD KEY `id_municipio` (`id_municipio`), ADD KEY `id_estado` (`id_estado`), ADD KEY `id_zona_postal` (`id_zona_postal`), ADD KEY `id_sujeto_pasivo` (`id_sujeto_pasivo`), ADD KEY `urb_direccion` (`urb_direccion`);

--
-- Indices de la tabla `datos_junta_directiva`
--
ALTER TABLE `datos_junta_directiva`
 ADD PRIMARY KEY (`rif`,`cedula`);

--
-- Indices de la tabla `datos_pago`
--
ALTER TABLE `datos_pago`
 ADD PRIMARY KEY (`rif`,`num_deposito`,`fecha_deposito`,`id_sujeto_pasivo`,`id_sucursal`), ADD KEY `id_surcursal` (`id_sucursal`), ADD KEY `fecha_deposito` (`fecha_deposito`), ADD KEY `num_deposito` (`num_deposito`), ADD KEY `id_sujeto_pasivo` (`id_sujeto_pasivo`);

--
-- Indices de la tabla `datos_programa`
--
ALTER TABLE `datos_programa`
 ADD PRIMARY KEY (`pro_num_registro`,`pro_rif`), ADD KEY `pro_rif` (`pro_rif`);

--
-- Indices de la tabla `datos_usuario`
--
ALTER TABLE `datos_usuario`
 ADD PRIMARY KEY (`datos_rif`);

--
-- Indices de la tabla `estado`
--
ALTER TABLE `estado`
 ADD PRIMARY KEY (`id_estado`);

--
-- Indices de la tabla `historico_registro`
--
ALTER TABLE `historico_registro`
 ADD PRIMARY KEY (`hisre_usuario`,`hisre_fecha_hora`,`hisre_estatus_registro`,`hisre_rif_comercializador`,`hisre_rif_pst`,`hisre_pro_num_registro`,`hisre_rif_operador`,`hisre_rif_iobpas`,`hisre_id_juego`), ADD KEY `hisre_rif_pst` (`hisre_rif_pst`), ADD KEY `hisre_rif_comercializador` (`hisre_rif_comercializador`), ADD KEY `hisre_pro_num_registro` (`hisre_pro_num_registro`), ADD KEY `hisre_rif_operador` (`hisre_rif_operador`), ADD KEY `hisre_rif_iobpas` (`hisre_rif_iobpas`), ADD KEY `hisre_id_juego` (`hisre_id_juego`);

--
-- Indices de la tabla `historico_registro_centro`
--
ALTER TABLE `historico_registro_centro`
 ADD KEY `hisrecen_rif_comercializador` (`hisrecen_rif_comercializador`), ADD KEY `hisrecen_rif_pst` (`hisrecen_rif_pst`), ADD KEY `hisrecen_pro_num_registro` (`hisrecen_pro_num_registro`), ADD KEY `hisrecen_rif_operador` (`hisrecen_rif_operador`), ADD KEY `hisrecen_rif_iobpas` (`hisrecen_rif_iobpas`), ADD KEY `hisrecen_id_juego` (`hisrecen_id_juego`), ADD KEY `hisrecen_rif_centroapuesta` (`hisrecen_rif_centroapuesta`);

--
-- Indices de la tabla `iobpas`
--
ALTER TABLE `iobpas`
 ADD PRIMARY KEY (`rif`), ADD KEY `num_registro` (`num_registro`);

--
-- Indices de la tabla `juegos`
--
ALTER TABLE `juegos`
 ADD PRIMARY KEY (`juego_id`,`juego_rif_iobpas`), ADD KEY `juego_rif_iobpas` (`juego_rif_iobpas`);

--
-- Indices de la tabla `liquidacion`
--
ALTER TABLE `liquidacion`
 ADD PRIMARY KEY (`liqui_secuencial`,`liqui_año`);

--
-- Indices de la tabla `listas`
--
ALTER TABLE `listas`
 ADD PRIMARY KEY (`lista_id`,`lista_codigo`);

--
-- Indices de la tabla `logs`
--
ALTER TABLE `logs`
 ADD PRIMARY KEY (`logs_id`);

--
-- Indices de la tabla `maquina_fiscal_apuesta`
--
ALTER TABLE `maquina_fiscal_apuesta`
 ADD PRIMARY KEY (`mfa_num_maquina`), ADD KEY `fk_centros_autorizados` (`mfa_rif_ca`,`mfa_sucursal`);

--
-- Indices de la tabla `municipio`
--
ALTER TABLE `municipio`
 ADD PRIMARY KEY (`id_municipio`,`id_estado_municipio`);

--
-- Indices de la tabla `opciones`
--
ALTER TABLE `opciones`
 ADD PRIMARY KEY (`op_id`);

--
-- Indices de la tabla `operadoras`
--
ALTER TABLE `operadoras`
 ADD PRIMARY KEY (`rif`);

--
-- Indices de la tabla `operadoras_juegos`
--
ALTER TABLE `operadoras_juegos`
 ADD PRIMARY KEY (`rif_operador`,`rif_iobpas`,`id_juego`), ADD KEY `opjue_rif_iobpas` (`rif_iobpas`), ADD KEY `opjue_id_juego` (`id_juego`);

--
-- Indices de la tabla `parroquia`
--
ALTER TABLE `parroquia`
 ADD PRIMARY KEY (`id_parroquia`,`id_municipio_parroquia`,`id_estado_parroquia`);

--
-- Indices de la tabla `permisos`
--
ALTER TABLE `permisos`
 ADD PRIMARY KEY (`pe_id_permiso`,`pe_id_permiso_usuario`,`pe_tipo_sujeto`,`pe_id_opcion`), ADD KEY `pe_id_opcion` (`pe_id_opcion`);

--
-- Indices de la tabla `pst`
--
ALTER TABLE `pst`
 ADD PRIMARY KEY (`pst_rif`);

--
-- Indices de la tabla `pst_maquina`
--
ALTER TABLE `pst_maquina`
 ADD PRIMARY KEY (`rif_pst`,`num_programa`,`rif_com`,`rif_ca`,`id_sucur`,`num_maquina`,`cedula_tecnico`);

--
-- Indices de la tabla `pst_operador`
--
ALTER TABLE `pst_operador`
 ADD PRIMARY KEY (`rif_pst`,`pro_num_registro`,`rif_iobpas`,`id_juego`), ADD KEY `pro_num_registro` (`pro_num_registro`), ADD KEY `rif_iobpas` (`rif_iobpas`), ADD KEY `id_juego` (`id_juego`), ADD KEY `rif_operador` (`rif_operador`);

--
-- Indices de la tabla `registro_centro_apuesta`
--
ALTER TABLE `registro_centro_apuesta`
 ADD PRIMARY KEY (`recen_rif_centroapuesta`,`recen_rif_comercializador`,`recen_rif_pst`,`recen_pro_num_registro`,`recen_rif_operador`,`recen_rif_iobpas`,`recen_id_juego`,`recen_id_sucursal`), ADD KEY `recen_rif_pst` (`recen_rif_pst`), ADD KEY `recen_pro_num_registro` (`recen_pro_num_registro`), ADD KEY `recen_rif_operador` (`recen_rif_operador`), ADD KEY `recen_rif_iobpas` (`recen_rif_iobpas`), ADD KEY `recen_id_juego` (`recen_id_juego`), ADD KEY `recen_id_sucursal` (`recen_id_sucursal`), ADD KEY `recen_estatus_registro` (`recen_estatus_registro`);

--
-- Indices de la tabla `registro_comercializador`
--
ALTER TABLE `registro_comercializador`
 ADD PRIMARY KEY (`recom_rif_comercializador`,`recom_rif_pst`,`recom_pro_num_registro`,`recom_rif_operador`,`recom_rif_iobpas`,`recom_id_juego`), ADD KEY `recom_rif_pst` (`recom_rif_pst`), ADD KEY `recom_pro_num_registro` (`recom_pro_num_registro`), ADD KEY `recom_rif_operador` (`recom_rif_operador`), ADD KEY `recom_rif_iobpas` (`recom_rif_iobpas`), ADD KEY `recom_id_juego` (`recom_id_juego`);

--
-- Indices de la tabla `representante_legal`
--
ALTER TABLE `representante_legal`
 ADD PRIMARY KEY (`cedula`,`id_sujeto_pasivo`,`rif`), ADD KEY `id_sujeto_pasivo` (`id_sujeto_pasivo`);

--
-- Indices de la tabla `sucursal`
--
ALTER TABLE `sucursal`
 ADD PRIMARY KEY (`sucur_rif`,`sucur_id`), ADD KEY `sucur_id` (`sucur_id`);

--
-- Indices de la tabla `sujetos_pasivos`
--
ALTER TABLE `sujetos_pasivos`
 ADD PRIMARY KEY (`id_sujeto_pasivo`);

--
-- Indices de la tabla `usuario`
--
ALTER TABLE `usuario`
 ADD PRIMARY KEY (`rif`,`id_sujeto_pasivo`), ADD KEY `id_sujeto_pasivo` (`id_sujeto_pasivo`);

--
-- Indices de la tabla `zona_postal`
--
ALTER TABLE `zona_postal`
 ADD PRIMARY KEY (`id_postal`);

--
-- AUTO_INCREMENT de las tablas volcadas
--

--
-- AUTO_INCREMENT de la tabla `logs`
--
ALTER TABLE `logs`
MODIFY `logs_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=24400;
--
-- AUTO_INCREMENT de la tabla `opciones`
--
ALTER TABLE `opciones`
MODIFY `op_id` int(3) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=93;
--
-- AUTO_INCREMENT de la tabla `permisos`
--
ALTER TABLE `permisos`
MODIFY `pe_id_permiso` int(2) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=141;
--
-- AUTO_INCREMENT de la tabla `zona_postal`
--
ALTER TABLE `zona_postal`
MODIFY `id_postal` int(4) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2128;
--
-- Restricciones para tablas volcadas
--

--
-- Filtros para la tabla `datos_creacion`
--
ALTER TABLE `datos_creacion`
ADD CONSTRAINT `datos_creacion` FOREIGN KEY (`rif`) REFERENCES `iobpas` (`rif`) ON DELETE CASCADE ON UPDATE NO ACTION;

--
-- Filtros para la tabla `datos_junta_directiva`
--
ALTER TABLE `datos_junta_directiva`
ADD CONSTRAINT `datos_junta_directiva_ibfk_1` FOREIGN KEY (`rif`) REFERENCES `iobpas` (`rif`) ON UPDATE NO ACTION;

--
-- Filtros para la tabla `datos_programa`
--
ALTER TABLE `datos_programa`
ADD CONSTRAINT `datos_programa_ibfk_1` FOREIGN KEY (`pro_rif`) REFERENCES `pst` (`pst_rif`) ON UPDATE CASCADE;

--
-- Filtros para la tabla `historico_registro`
--
ALTER TABLE `historico_registro`
ADD CONSTRAINT `historico_registro_ibfk_20` FOREIGN KEY (`hisre_usuario`) REFERENCES `usuario` (`rif`) ON UPDATE CASCADE;

--
-- Filtros para la tabla `juegos`
--
ALTER TABLE `juegos`
ADD CONSTRAINT `juegos_ibfk_1` FOREIGN KEY (`juego_rif_iobpas`) REFERENCES `iobpas` (`rif`) ON UPDATE CASCADE;

--
-- Filtros para la tabla `maquina_fiscal_apuesta`
--
ALTER TABLE `maquina_fiscal_apuesta`
ADD CONSTRAINT `maquina_fiscal_apuesta_ibfk_1` FOREIGN KEY (`mfa_rif_ca`) REFERENCES `centros_autorizados` (`cenau_rif_centro_apuesta`) ON UPDATE CASCADE;

--
-- Filtros para la tabla `operadoras_juegos`
--
ALTER TABLE `operadoras_juegos`
ADD CONSTRAINT `operadoras_juegos_ibfk_1` FOREIGN KEY (`rif_operador`) REFERENCES `operadoras` (`rif`) ON UPDATE CASCADE,
ADD CONSTRAINT `operadoras_juegos_ibfk_2` FOREIGN KEY (`rif_iobpas`) REFERENCES `juegos` (`juego_rif_iobpas`) ON UPDATE CASCADE,
ADD CONSTRAINT `operadoras_juegos_ibfk_3` FOREIGN KEY (`id_juego`) REFERENCES `juegos` (`juego_id`) ON UPDATE CASCADE;

--
-- Filtros para la tabla `permisos`
--
ALTER TABLE `permisos`
ADD CONSTRAINT `permisos_ibfk_1` FOREIGN KEY (`pe_id_opcion`) REFERENCES `opciones` (`op_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

--
-- Filtros para la tabla `pst_operador`
--
ALTER TABLE `pst_operador`
ADD CONSTRAINT `pst_operador_ibfk_1` FOREIGN KEY (`rif_pst`) REFERENCES `datos_programa` (`pro_rif`) ON UPDATE CASCADE,
ADD CONSTRAINT `pst_operador_ibfk_2` FOREIGN KEY (`pro_num_registro`) REFERENCES `datos_programa` (`pro_num_registro`) ON UPDATE CASCADE,
ADD CONSTRAINT `pst_operador_ibfk_3` FOREIGN KEY (`rif_operador`) REFERENCES `operadoras_juegos` (`rif_operador`) ON UPDATE CASCADE,
ADD CONSTRAINT `pst_operador_ibfk_4` FOREIGN KEY (`rif_iobpas`) REFERENCES `operadoras_juegos` (`rif_iobpas`) ON UPDATE CASCADE,
ADD CONSTRAINT `pst_operador_ibfk_5` FOREIGN KEY (`id_juego`) REFERENCES `operadoras_juegos` (`id_juego`) ON UPDATE CASCADE;

--
-- Filtros para la tabla `registro_centro_apuesta`
--
ALTER TABLE `registro_centro_apuesta`
ADD CONSTRAINT `registro_centro_apuesta_ibfk_1` FOREIGN KEY (`recen_rif_centroapuesta`) REFERENCES `centro_apuesta` (`cenap_rif`) ON UPDATE CASCADE;

--
-- Filtros para la tabla `registro_comercializador`
--
ALTER TABLE `registro_comercializador`
ADD CONSTRAINT `registro_comercializador_ibfk_1` FOREIGN KEY (`recom_rif_comercializador`) REFERENCES `comercializadores` (`comer_rif`) ON UPDATE CASCADE,
ADD CONSTRAINT `registro_comercializador_ibfk_2` FOREIGN KEY (`recom_pro_num_registro`) REFERENCES `pst_operador` (`pro_num_registro`) ON UPDATE CASCADE,
ADD CONSTRAINT `registro_comercializador_ibfk_3` FOREIGN KEY (`recom_rif_operador`) REFERENCES `pst_operador` (`rif_operador`) ON UPDATE CASCADE,
ADD CONSTRAINT `registro_comercializador_ibfk_4` FOREIGN KEY (`recom_rif_iobpas`) REFERENCES `pst_operador` (`rif_iobpas`) ON UPDATE CASCADE,
ADD CONSTRAINT `registro_comercializador_ibfk_5` FOREIGN KEY (`recom_id_juego`) REFERENCES `pst_operador` (`id_juego`) ON UPDATE CASCADE;

--
-- Filtros para la tabla `representante_legal`
--
ALTER TABLE `representante_legal`
ADD CONSTRAINT `representante_legal_ibfk_1` FOREIGN KEY (`id_sujeto_pasivo`) REFERENCES `sujetos_pasivos` (`id_sujeto_pasivo`) ON UPDATE CASCADE;

--
-- Filtros para la tabla `sucursal`
--
ALTER TABLE `sucursal`
ADD CONSTRAINT `sucursal_ibfk_1` FOREIGN KEY (`sucur_rif`) REFERENCES `centro_apuesta` (`cenap_rif`) ON UPDATE CASCADE;

--
-- Filtros para la tabla `usuario`
--
ALTER TABLE `usuario`
ADD CONSTRAINT `usuario_ibfk_1` FOREIGN KEY (`id_sujeto_pasivo`) REFERENCES `sujetos_pasivos` (`id_sujeto_pasivo`) ON UPDATE CASCADE;

