/*
SQLyog Ultimate v13.1.1 (64 bit)
MySQL - 5.7.31 : Database - practicec94_anexa
*********************************************************************
*/



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

USE `practicec94_anexa`;

/*Table structure for table `__log_evento` */


CREATE TABLE `__log_evento` (
  `id_registro` int(11) NOT NULL AUTO_INCREMENT,
  `nombre_evento` varchar(1000) DEFAULT NULL,
  `fe_ejecucion` datetime DEFAULT NULL,
  PRIMARY KEY (`id_registro`)
) ENGINE=InnoDB AUTO_INCREMENT=701 DEFAULT CHARSET=latin1;

/*Table structure for table `af_articulo` */


CREATE TABLE `af_articulo` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `proveedor_id` int(11) NOT NULL,
  `talle_id` int(11) NOT NULL,
  `color_id` int(11) NOT NULL,
  `tags_id` int(11) DEFAULT NULL COMMENT 'Id Tags',
  `disciplina_id` int(11) NOT NULL,
  `marca_id` int(11) NOT NULL,
  `categoria_id` int(11) NOT NULL,
  `grupo_id` int(11) NOT NULL,
  `rubro_id` int(11) NOT NULL,
  `descripcion` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `genero` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `codigo` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stock` int(11) DEFAULT NULL,
  `stock_minimo` int(11) DEFAULT NULL,
  `precio` decimal(10,2) DEFAULT NULL,
  `fe_ult_act_l1` datetime DEFAULT NULL,
  `precio2` decimal(10,2) DEFAULT NULL,
  `fe_ult_act_l2` datetime DEFAULT NULL,
  `precio3` decimal(11,2) DEFAULT NULL,
  `fe_ult_act_l3` datetime DEFAULT NULL,
  `dolar_cotizacion` decimal(11,2) DEFAULT NULL,
  `precio_costo_dolar` decimal(11,2) DEFAULT NULL,
  `costo` decimal(11,2) DEFAULT NULL,
  `stock_minimo_pagina` int(11) DEFAULT NULL,
  `stock_pagina` int(11) DEFAULT NULL,
  `stock_sucursal` int(11) DEFAULT NULL,
  `observaciones` text COLLATE utf8mb4_unicode_ci,
  `transferido` tinyint(1) DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  `anio` int(11) DEFAULT NULL,
  `iva_venta` decimal(10,0) DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `cantidad_imagenes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modificado_local` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `agregado_local` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modificado_stock` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UNIQ_69E94E9120332D99` (`codigo`),
  KEY `IDX_69E94E91CB305D73` (`proveedor_id`),
  KEY `IDX_69E94E91D6F5492C` (`talle_id`),
  KEY `IDX_69E94E917ADA1FB5` (`color_id`),
  KEY `IDX_69E94E918D7B4FB4` (`tags_id`),
  KEY `IDX_69E94E912A30B056` (`disciplina_id`),
  KEY `IDX_69E94E9181EF0041` (`marca_id`),
  KEY `IDX_69E94E913397707A` (`categoria_id`),
  KEY `IDX_69E94E919C833003` (`grupo_id`),
  KEY `IDX_69E94E9196C5081` (`rubro_id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/AF_articulo';

/*Table structure for table `af_categoria` */


CREATE TABLE `af_categoria` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `grupo_id` int(11) NOT NULL,
  `nombre` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_4E10122D9C833003` (`grupo_id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/AF_categoria';

/*Table structure for table `af_color` */


CREATE TABLE `af_color` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `color` varchar(60) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/AF_color';

/*Table structure for table `af_disciplina` */


CREATE TABLE `af_disciplina` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/AF_disciplina';

/*Table structure for table `af_grupo` */


CREATE TABLE `af_grupo` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `rubro_id` int(11) DEFAULT NULL,
  `nom_grupo` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `nom_grupo` (`nom_grupo`),
  KEY `IDX_8C0E9BD396C5081` (`rubro_id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/AF_grupo';

/*Table structure for table `af_marca_producto` */


CREATE TABLE `af_marca_producto` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/AF_marca_producto';

/*Table structure for table `af_proveedor` */


CREATE TABLE `af_proveedor` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `cond_iva_id` int(11) DEFAULT NULL,
  `nombre` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `domicilio` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ciudad` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `provincia` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pais` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telefonos` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tel_comercial` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `comentarios` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fax` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cod_postal` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `web` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `porc_lista1` int(11) DEFAULT NULL,
  `porc_lista2` int(11) DEFAULT NULL,
  `porc_lista3` int(11) DEFAULT NULL,
  `no_acepta_descuentos` tinyint(1) DEFAULT NULL,
  `cuilt` varchar(11) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `nom_banco` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `num_banco` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cbu` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `razon_social` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `id_cond_ante_iva` int(11) DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `IDX_16C068CED433B4B8` (`cond_iva_id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/AF_proveedor';

/*Table structure for table `af_rubro` */


CREATE TABLE `af_rubro` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/AF_rubro';

/*Table structure for table `af_tags` */


CREATE TABLE `af_tags` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Id Tags',
  `descripcion` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Descripcion Tag',
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/AF_tags';

/*Table structure for table `af_talle` */


CREATE TABLE `af_talle` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `talle` varchar(60) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/AF_talle';

/*Table structure for table `rsp_articulo` */


CREATE TABLE `rsp_articulo` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `proveedor_id` int(11) NOT NULL,
  `talle_id` int(11) NOT NULL,
  `color_id` int(11) NOT NULL,
  `tags_id` int(11) DEFAULT NULL COMMENT 'Id Tags',
  `disciplina_id` int(11) NOT NULL,
  `marca_id` int(11) NOT NULL,
  `categoria_id` int(11) NOT NULL,
  `grupo_id` int(11) NOT NULL,
  `rubro_id` int(11) NOT NULL,
  `descripcion` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `genero` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `codigo` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stock` int(11) DEFAULT NULL,
  `stock_minimo` int(11) DEFAULT NULL,
  `precio` decimal(10,2) DEFAULT NULL,
  `fe_ult_act_l1` datetime DEFAULT NULL,
  `precio2` decimal(10,2) DEFAULT NULL,
  `fe_ult_act_l2` datetime DEFAULT NULL,
  `precio3` decimal(11,2) DEFAULT NULL,
  `fe_ult_act_l3` datetime DEFAULT NULL,
  `dolar_cotizacion` decimal(11,2) DEFAULT NULL,
  `precio_costo_dolar` decimal(11,2) DEFAULT NULL,
  `costo` decimal(11,2) DEFAULT NULL,
  `stock_minimo_pagina` int(11) DEFAULT NULL,
  `stock_pagina` int(11) DEFAULT NULL,
  `stock_sucursal` int(11) DEFAULT NULL,
  `observaciones` text COLLATE utf8mb4_unicode_ci,
  `transferido` tinyint(1) DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  `anio` int(11) DEFAULT NULL,
  `iva_venta` decimal(10,0) DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `cantidad_imagenes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modificado_local` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `agregado_local` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modificado_stock` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UNIQ_69E94E9120332D99` (`codigo`),
  KEY `IDX_69E94E91CB305D73` (`proveedor_id`),
  KEY `IDX_69E94E91D6F5492C` (`talle_id`),
  KEY `IDX_69E94E917ADA1FB5` (`color_id`),
  KEY `IDX_69E94E918D7B4FB4` (`tags_id`),
  KEY `IDX_69E94E912A30B056` (`disciplina_id`),
  KEY `IDX_69E94E9181EF0041` (`marca_id`),
  KEY `IDX_69E94E913397707A` (`categoria_id`),
  KEY `IDX_69E94E919C833003` (`grupo_id`),
  KEY `IDX_69E94E9196C5081` (`rubro_id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/RSP_articulo';

/*Table structure for table `rsp_categoria` */


CREATE TABLE `rsp_categoria` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `grupo_id` int(11) NOT NULL,
  `nombre` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_4E10122D9C833003` (`grupo_id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/RSP_categoria';

/*Table structure for table `rsp_color` */


CREATE TABLE `rsp_color` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `color` varchar(60) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/RSP_color';

/*Table structure for table `rsp_disciplina` */


CREATE TABLE `rsp_disciplina` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/RSP_disciplina';

/*Table structure for table `rsp_grupo` */


CREATE TABLE `rsp_grupo` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `rubro_id` int(11) DEFAULT NULL,
  `nom_grupo` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `nom_grupo` (`nom_grupo`),
  KEY `IDX_8C0E9BD396C5081` (`rubro_id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/RSP_grupo';

/*Table structure for table `rsp_marca_producto` */


CREATE TABLE `rsp_marca_producto` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/RSP_marca_producto';

/*Table structure for table `rsp_proveedor` */


CREATE TABLE `rsp_proveedor` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `cond_iva_id` int(11) DEFAULT NULL,
  `nombre` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `domicilio` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ciudad` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `provincia` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pais` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telefonos` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tel_comercial` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `comentarios` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fax` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cod_postal` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `web` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `porc_lista1` int(11) DEFAULT NULL,
  `porc_lista2` int(11) DEFAULT NULL,
  `porc_lista3` int(11) DEFAULT NULL,
  `no_acepta_descuentos` tinyint(1) DEFAULT NULL,
  `cuilt` varchar(11) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `nom_banco` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `num_banco` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cbu` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `razon_social` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `id_cond_ante_iva` int(11) DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `IDX_16C068CED433B4B8` (`cond_iva_id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/RSP_proveedor';

/*Table structure for table `rsp_rubro` */


CREATE TABLE `rsp_rubro` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/RSP_rubro';

/*Table structure for table `rsp_tags` */


CREATE TABLE `rsp_tags` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Id Tags',
  `descripcion` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Descripcion Tag',
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/RSP_tags';

/*Table structure for table `rsp_talle` */


CREATE TABLE `rsp_talle` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `talle` varchar(60) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CONNECTION='mysql://club94sp:ZVR.)wSWno&h!!!@158.69.1.60:3306/club94sp_intermedia/RSP_talle';

/*Table structure for table `tmp_art_updateables` */


CREATE TABLE `tmp_art_updateables` (
  `id` int(11) NOT NULL DEFAULT '0',
  `proveedor_id` int(11) NOT NULL,
  `talle_id` int(11) NOT NULL,
  `color_id` int(11) NOT NULL,
  `tags_id` int(11) DEFAULT NULL COMMENT 'Id Tags',
  `disciplina_id` int(11) NOT NULL,
  `marca_id` int(11) NOT NULL,
  `categoria_id` int(11) NOT NULL,
  `grupo_id` int(11) NOT NULL,
  `rubro_id` int(11) NOT NULL,
  `descripcion` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `genero` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `codigo` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stock` int(11) DEFAULT NULL,
  `stock_minimo` int(11) DEFAULT NULL,
  `precio` decimal(10,2) DEFAULT NULL,
  `fe_ult_act_l1` datetime DEFAULT NULL,
  `precio2` decimal(10,2) DEFAULT NULL,
  `fe_ult_act_l2` datetime DEFAULT NULL,
  `precio3` decimal(11,2) DEFAULT NULL,
  `fe_ult_act_l3` datetime DEFAULT NULL,
  `dolar_cotizacion` decimal(11,2) DEFAULT NULL,
  `precio_costo_dolar` decimal(11,2) DEFAULT NULL,
  `costo` decimal(11,2) DEFAULT NULL,
  `stock_minimo_pagina` int(11) DEFAULT NULL,
  `stock_pagina` int(11) DEFAULT NULL,
  `stock_sucursal` int(11) DEFAULT NULL,
  `observaciones` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `transferido` tinyint(1) DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  `anio` int(11) DEFAULT NULL,
  `iva_venta` decimal(10,0) DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `cantidad_imagenes` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modificado_local` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `agregado_local` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modificado_stock` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `tmp_articulos` */


CREATE TABLE `tmp_articulos` (
  `id` int(11) NOT NULL DEFAULT '0',
  `proveedor_id` int(11) NOT NULL,
  `talle_id` int(11) NOT NULL,
  `color_id` int(11) NOT NULL,
  `tags_id` int(11) DEFAULT NULL COMMENT 'Id Tags',
  `disciplina_id` int(11) NOT NULL,
  `marca_id` int(11) NOT NULL,
  `categoria_id` int(11) NOT NULL,
  `grupo_id` int(11) NOT NULL,
  `rubro_id` int(11) NOT NULL,
  `descripcion` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `genero` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `codigo` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stock` int(11) DEFAULT NULL,
  `stock_minimo` int(11) DEFAULT NULL,
  `precio` decimal(10,2) DEFAULT NULL,
  `fe_ult_act_l1` datetime DEFAULT NULL,
  `precio2` decimal(10,2) DEFAULT NULL,
  `fe_ult_act_l2` datetime DEFAULT NULL,
  `precio3` decimal(11,2) DEFAULT NULL,
  `fe_ult_act_l3` datetime DEFAULT NULL,
  `dolar_cotizacion` decimal(11,2) DEFAULT NULL,
  `precio_costo_dolar` decimal(11,2) DEFAULT NULL,
  `costo` decimal(11,2) DEFAULT NULL,
  `stock_minimo_pagina` int(11) DEFAULT NULL,
  `stock_pagina` int(11) DEFAULT NULL,
  `stock_sucursal` int(11) DEFAULT NULL,
  `observaciones` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `transferido` tinyint(1) DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  `anio` int(11) DEFAULT NULL,
  `iva_venta` decimal(10,0) DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `cantidad_imagenes` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modificado_local` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `agregado_local` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modificado_stock` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `tmp_articulos2` */


CREATE TABLE `tmp_articulos2` (
  `id` int(11) NOT NULL DEFAULT '0',
  `proveedor_id` int(11) NOT NULL,
  `talle_id` int(11) NOT NULL,
  `color_id` int(11) NOT NULL,
  `tags_id` int(11) DEFAULT NULL COMMENT 'Id Tags',
  `disciplina_id` int(11) NOT NULL,
  `marca_id` int(11) NOT NULL,
  `categoria_id` int(11) NOT NULL,
  `grupo_id` int(11) NOT NULL,
  `rubro_id` int(11) NOT NULL,
  `descripcion` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `genero` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `codigo` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stock` int(11) DEFAULT NULL,
  `stock_minimo` int(11) DEFAULT NULL,
  `precio` decimal(10,2) DEFAULT NULL,
  `fe_ult_act_l1` datetime DEFAULT NULL,
  `precio2` decimal(10,2) DEFAULT NULL,
  `fe_ult_act_l2` datetime DEFAULT NULL,
  `precio3` decimal(11,2) DEFAULT NULL,
  `fe_ult_act_l3` datetime DEFAULT NULL,
  `dolar_cotizacion` decimal(11,2) DEFAULT NULL,
  `precio_costo_dolar` decimal(11,2) DEFAULT NULL,
  `costo` decimal(11,2) DEFAULT NULL,
  `stock_minimo_pagina` int(11) DEFAULT NULL,
  `stock_pagina` int(11) DEFAULT NULL,
  `stock_sucursal` int(11) DEFAULT NULL,
  `observaciones` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `transferido` tinyint(1) DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL,
  `anio` int(11) DEFAULT NULL,
  `iva_venta` decimal(10,0) DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `cantidad_imagenes` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modificado_local` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `agregado_local` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modificado_stock` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `tmp_categoriaes` */


CREATE TABLE `tmp_categoriaes` (
  `id` int(11) NOT NULL DEFAULT '0',
  `grupo_id` int(11) NOT NULL,
  `nombre` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `tmp_colores` */


CREATE TABLE `tmp_colores` (
  `id` int(11) NOT NULL DEFAULT '0',
  `color` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `tmp_disciplinaes` */


CREATE TABLE `tmp_disciplinaes` (
  `id` int(11) NOT NULL DEFAULT '0',
  `nombre` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `tmp_grupoes` */


CREATE TABLE `tmp_grupoes` (
  `id` int(11) NOT NULL DEFAULT '0',
  `rubro_id` int(11) DEFAULT NULL,
  `nom_grupo` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `tmp_marca_productoes` */


CREATE TABLE `tmp_marca_productoes` (
  `id` int(11) NOT NULL DEFAULT '0',
  `nombre` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `tmp_proveedores` */


CREATE TABLE `tmp_proveedores` (
  `id` int(11) NOT NULL DEFAULT '0',
  `cond_iva_id` int(11) DEFAULT NULL,
  `nombre` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `domicilio` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ciudad` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `provincia` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pais` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telefonos` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tel_comercial` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `comentarios` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fax` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cod_postal` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `web` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `porc_lista1` int(11) DEFAULT NULL,
  `porc_lista2` int(11) DEFAULT NULL,
  `porc_lista3` int(11) DEFAULT NULL,
  `no_acepta_descuentos` tinyint(1) DEFAULT NULL,
  `cuilt` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `nom_banco` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `num_banco` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cbu` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `razon_social` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `id_cond_ante_iva` int(11) DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `tmp_rubroes` */


CREATE TABLE `tmp_rubroes` (
  `id` int(11) NOT NULL DEFAULT '0',
  `descripcion` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `modificado` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `tmp_tagses` */


CREATE TABLE `tmp_tagses` (
  `id` int(11) NOT NULL DEFAULT '0' COMMENT 'Id Tags',
  `descripcion` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Descripcion Tag',
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*Table structure for table `tmp_tallees` */


CREATE TABLE `tmp_tallees` (
  `id` int(11) NOT NULL DEFAULT '0',
  `talle` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activo` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `modificado` tinyint(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*!50106 set global event_scheduler = 1*/;

/* Event structure for event `pull_articulos` */

/*!50106 DROP EVENT IF EXISTS `pull_articulos`*/;

DELIMITER $$

/*!50106 CREATE DEFINER=`root`@`localhost` EVENT `pull_articulos` ON SCHEDULE EVERY 15 MINUTE STARTS '2021-11-02 00:20:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
	CALL `practicec94_anexa`.articulo_pull_updates();
	CALL `practicec94_anexa`.articulo_pull_new(-20);
	END */$$
DELIMITER ;

/* Event structure for event `push_articulos` */

/*!50106 DROP EVENT IF EXISTS `push_articulos`*/;

DELIMITER $$

/*!50106 CREATE DEFINER=`root`@`localhost` EVENT `push_articulos` ON SCHEDULE EVERY 15 MINUTE STARTS '2021-11-02 00:05:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
		CALL `practicec94_anexa`.rubro_push();
		CALL `practicec94_anexa`.grupo_push();
		CALL `practicec94_anexa`.categoria_push();
		CALL `practicec94_anexa`.color_push();
		CALL `practicec94_anexa`.talle_push();
		CALL `practicec94_anexa`.disciplina_push();
		CALL `practicec94_anexa`.tags_push();
		CALL `practicec94_anexa`.proveedor_push();
		CALL `practicec94_anexa`.marca_producto_push();
		CALL `practicec94_anexa`.articulo_push_updates();
		CALL `practicec94_anexa`.articulo_push_new(-20);
	END */$$
DELIMITER ;

/* Procedure structure for procedure `articulo_pull_new` */

/*!50003 DROP PROCEDURE IF EXISTS  `articulo_pull_new` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `articulo_pull_new`(dias_atras INT)
BEGIN
	DECLARE reg_insertados INT;
	DECLARE mensaje NVARCHAR(1000);
	SET reg_insertados=0;
	
	/*creo una tabla temporal en memoria de los ultimos 'dias_atras' articulos insertados, a partir de ahi, veo las diferencias*/
	DROP TABLE IF EXISTS tmp_articulos;
	CREATE TABLE tmp_articulos SELECT * FROM `practicec94_anexa`.rsp_articulo WHERE created_at>=ADDDATE(NOW(),INTERVAL dias_atras DAY) AND agregado_local = "RSP";
	
	
	/*creo una tabla temporal2 con la diferencia de los articulos que faltan en Avenida Freyre de las listadas anteriormente*/
	DROP TABLE IF EXISTS tmp_articulos2;
	CREATE TABLE tmp_articulos2 (
		SELECT * FROM tmp_articulos WHERE NOT EXISTS (SELECT * FROM practicec94.articulo WHERE articulo.codigo = tmp_articulos.codigo)
	);
	
	UPDATE tmp_articulos2 SET stock = 0;
		
	ALTER TABLE tmp_articulos2 DROP id;
	insert INTO `practicec94`.articulo SELECT '',tmp_articulos2.* FROM tmp_articulos2;
	 
	SET reg_insertados=ROW_COUNT();
	SET mensaje=CONCAT('PROCEDURE articulo_pull_new(). insertados:', CAST(reg_insertados AS CHAR(50)) );
	INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
	
	END */$$
DELIMITER ;

/* Procedure structure for procedure `articulo_pull_updates` */

/*!50003 DROP PROCEDURE IF EXISTS  `articulo_pull_updates` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `articulo_pull_updates`()
BEGIN
		DECLARE insert_error BOOL DEFAULT 0; 
		DECLARE reg_actualizados INT;
		DECLARE mensaje NVARCHAR(1000);
		DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET insert_error=1;
		START TRANSACTION;
		SET reg_actualizados=0;
		
		#DROP TABLE IF EXISTS tmp_art_updateables;	
		#CREATE TABLE tmp_art_updateables (SELECT * FROM rsp_articulo WHERE modificado=1 AND modificado_local = "RSP");
		
		/*actualizo practicec94.articulo*/	
		UPDATE `practicec94`.articulo a, tmp_art_updateables b 
		SET a.`proveedor_id` = b.proveedor_id,a.`talle_id`=b.talle_id,a.`color_id`=b.color_id,a.`tags_id`=b.tags_id,a.`disciplina_id`=b.`disciplina_id`,
		a.`marca_id`=b.`marca_id`,a.`categoria_id`=b.`categoria_id`,a.`grupo_id`=b.`grupo_id`,a.`rubro_id`=b.`rubro_id`,
		a.`descripcion`=b.`descripcion`,a.`genero`=b.`genero`,a.`stock_minimo`=b.`stock_minimo`,a.`precio` = b.`precio`,
		a.`fe_ult_act_l1`=b.`fe_ult_act_l1`,a.`precio2`=b.`precio2`,a.`fe_ult_act_l2` = b.`fe_ult_act_l2`,a.`precio3`=b.`precio3`,a.`fe_ult_act_l3` = b.`fe_ult_act_l3`,
		a.`costo`=b.`costo`,a.`stock_minimo_pagina`=b.`stock_minimo_pagina`,a.`stock_pagina` = b.`stock_pagina`,a.`observaciones` = b.`observaciones`,
		a.`transferido`=b.`transferido`,a.`modificado`=b.`modificado`,a.`anio` = b.`anio`,a.`iva_venta` = b.`iva_venta`,a.`activo` = b.`activo`,
		a.`created_at`=b.`created_at`,a.`updated_at`=b.`updated_at`,a.`deleted_at` = b.`deleted_at`,a.`cantidad_imagenes` = b.`cantidad_imagenes`,
		a.`modificado_local` = b.`modificado_local`,a.`agregado_local` = b.`agregado_local`,a.`modificado_stock` = b.`modificado_stock`	
		WHERE a.codigo = b.codigo;
		
		SET reg_actualizados=ROW_COUNT();
		
		/*actualizo en DB => `practicec94` el BIT a modificado = 0 de los articulos que fueron actualizados en practicec94_anexa 
		/*para que no los actualice mas luego de este procedimiento con esto me aseguro que no se vuelva a actualizar rsp_articulo*/
		UPDATE practicec94.articulo a, tmp_art_updateables b 
		SET a.modificado=0 WHERE a.codigo=b.codigo;
		
		SET mensaje=CONCAT('PROCEDURE articulo_pull_updates(). actualizados:', CAST(reg_actualizados AS CHAR(50)) );
		/*actualizo log_evento*/	
		INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
		IF insert_error=1 THEN		
		ROLLBACK;
		INSERT INTO log_evento(nombre_evento,fe_ejecucion) VALUES('#Error en articulo_push_updates(). Los cambios no se realizaron.',NOW());	
		ELSE	
		COMMIT;
		END IF;
	    END */$$
DELIMITER ;

/* Procedure structure for procedure `articulo_push_new` */

/*!50003 DROP PROCEDURE IF EXISTS  `articulo_push_new` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `articulo_push_new`(dias_atras int)
BEGIN
    /*
    el proposito de esta funcion es tomar los articulos de `practicec94`.articulo
    y compararlos contra los que estan en `practice_toelvo_anexa`.af_articulo
    y actualizar `practice_toelvo_anexa`.af_articulo con los nuevos registros
    */
	DECLARE reg_insertados INT;
	DECLARE mensaje NVARCHAR(1000);
	SET reg_insertados=0;
	
	/*creo una tabla temporal en memoria de los ultimos 'dias_atras' articulos insertados, a partir de ahi, veo las diferencias*/
	DROP TABLE IF EXISTS tmp_articulos;
	CREATE TABLE tmp_articulos SELECT * FROM `practicec94_anexa`.af_articulo WHERE created_at>=ADDDATE(NOW(),INTERVAL dias_atras DAY) AND agregado_local="AF";
	
	/*creo una tabla temporal2 con la diferencia de los articulos que faltan*/
	DROP TABLE IF EXISTS tmp_articulos2;
	CREATE TABLE tmp_articulos2 SELECT tdesde.*
	FROM `practicec94`.articulo tdesde 
	LEFT JOIN tmp_articulos thasta ON tdesde.codigo=thasta.codigo 
	WHERE thasta.codigo IS NULL AND tdesde.created_at>=ADDDATE(NOW(),INTERVAL dias_atras DAY);
	
	REPLACE INTO af_articulo select * from tmp_articulos2;
	/*actualizo en DB => `practicec94` el BIT a modificado = 0 de los articulos que fueron actualizados en practicec94_anexa 
	/*para que no los actualice mas luego de este procedimiento con esto me aseguro que no se vuelva a actualizar af_articulo*/
	UPDATE practicec94.articulo a, tmp_articulos2 b 
	SET a.agregado_local="AF->RSP" WHERE a.codigo=b.codigo;
	UPDATE practicec94.articulo a, tmp_articulos2 b 
	SET a.modificado_local="" WHERE a.codigo=b.codigo;		
	UPDATE practicec94.articulo a, tmp_articulos2 b 
	SET a.modificado=0 WHERE a.codigo=b.codigo;	
	SET reg_insertados=ROW_COUNT();
	SET mensaje=CONCAT('PROCEDURE articulo_push_new(). insertados:', CAST(reg_insertados AS CHAR(50)) );
	INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
	END */$$
DELIMITER ;

/* Procedure structure for procedure `articulo_push_updates` */

/*!50003 DROP PROCEDURE IF EXISTS  `articulo_push_updates` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `articulo_push_updates`()
BEGIN
	DECLARE insert_error BOOL DEFAULT 0; 
	declare reg_actualizados int;
	declare mensaje nvarchar(1000);
	DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET insert_error=1;
	START TRANSACTION;
	set reg_actualizados=0;
	
	drop table if exists tmp_art_updateables;	
	create table tmp_art_updateables (SELECT * FROM `practicec94`.articulo WHERE modificado=1 and modificado_local = "AF");
	
	/*actualizo practicec94_anexa.fs_articulo*/	
	UPDATE `practicec94_anexa`.af_articulo a, tmp_art_updateables b 
	SET a.`proveedor_id` = b.proveedor_id,a.`talle_id`=b.talle_id,a.`color_id`=b.color_id,a.`tags_id`=b.tags_id,a.`disciplina_id`=b.`disciplina_id`,
	a.`marca_id`=b.`marca_id`,a.`categoria_id`=b.`categoria_id`,a.`grupo_id`=b.`grupo_id`,a.`rubro_id`=b.`rubro_id`,
	a.`descripcion`=b.`descripcion`,a.`genero`=b.`genero`,a.`stock` = b.`stock`,a.`stock_minimo`=b.`stock_minimo`,a.`precio` = b.`precio`,
	a.`fe_ult_act_l1`=b.`fe_ult_act_l1`,a.`precio2`=b.`precio2`,a.`fe_ult_act_l2` = b.`fe_ult_act_l2`,a.`precio3`=b.`precio3`,a.`fe_ult_act_l3` = b.`fe_ult_act_l3`,
	a.`costo`=b.`costo`,a.`stock_minimo_pagina`=b.`stock_minimo_pagina`,a.`stock_pagina` = b.`stock_pagina`,a.`observaciones` = b.`observaciones`,
	a.`transferido`=b.`transferido`,a.`modificado`=b.`modificado`,a.`anio` = b.`anio`,a.`iva_venta` = b.`iva_venta`,a.`activo` = b.`activo`,
	a.`created_at`=b.`created_at`,a.`updated_at`=b.`updated_at`,a.`deleted_at` = b.`deleted_at`,a.`cantidad_imagenes` = b.`cantidad_imagenes`,
	a.`modificado_local` = b.`modificado_local`,a.`agregado_local` = b.`agregado_local`,a.`modificado_stock` = b.`modificado_stock`	
	WHERE a.codigo = b.codigo;
	
	SET reg_actualizados=ROW_COUNT();
	
	/*actualizo en DB => `practicec94` el BIT a modificado = 0 de los articulos que fueron actualizados en practicec94_anexa 
	/*para que no los actualice mas luego de este procedimiento con esto me aseguro que no se vuelva a actualizar af_articulo*/
	UPDATE practicec94.articulo a, tmp_art_updateables b 
	SET a.modificado=0 WHERE a.codigo=b.codigo;
	
	set mensaje=concat('PROCEDURE articulo_push_updates(). actualizados:', cast(reg_actualizados as char(50)) );
	/*actualizo log_evento*/	
	insert into `__log_evento` (nombre_evento,fe_ejecucion) values(mensaje,now());
	IF insert_error=1 THEN		
	ROLLBACK;
        insert into log_evento(nombre_evento,fe_ejecucion) values('#Error en articulo_push_updates(). Los cambios no se realizaron.',now());	
	ELSE	
	COMMIT;
	END IF;
    END */$$
DELIMITER ;

/* Procedure structure for procedure `categoria_push` */

/*!50003 DROP PROCEDURE IF EXISTS  `categoria_push` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `categoria_push`()
BEGIN
 
	DECLARE reg_push INT;
	DECLARE mensaje NVARCHAR(1000);
	SET reg_push=0;
		
	/*creo una tabla temporal2 con la diferencia de los articulos que faltan*/
	DROP TABLE IF EXISTS tmp_categoriaes;
	CREATE TABLE tmp_categoriaes (SELECT * FROM practicec94.categoria WHERE id > (SELECT MAX(id) FROM af_categoria) OR modificado = 1);
	
	REPLACE INTO af_categoria SELECT * FROM tmp_categoriaes;
	UPDATE practicec94.categoria SET modificado = 0 WHERE modificado = 1;
	
	SET reg_push=ROW_COUNT();
	SET mensaje=CONCAT('PROCEDURE categoria_push(). insertados y/o modificados:', CAST(reg_push AS CHAR(50)) );
	INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
	END */$$
DELIMITER ;

/* Procedure structure for procedure `color_push` */

/*!50003 DROP PROCEDURE IF EXISTS  `color_push` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `color_push`()
BEGIN
 
	DECLARE reg_push INT;
	DECLARE mensaje NVARCHAR(1000);
	SET reg_push=0;
		
	/*creo una tabla temporal2 con la diferencia de los articulos que faltan*/
	DROP TABLE IF EXISTS tmp_colores;
	CREATE TABLE tmp_colores (SELECT * FROM practicec94.color WHERE id > (SELECT MAX(id) FROM af_color) OR modificado = 1);
	
	REPLACE INTO af_color SELECT * FROM tmp_colores;
	UPDATE practicec94.color set modificado = 0 where modificado = 1;
	
	SET reg_push=ROW_COUNT();
	SET mensaje=CONCAT('PROCEDURE color_push(). insertados y/o modificados:', CAST(reg_push AS CHAR(50)) );
	INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
	END */$$
DELIMITER ;

/* Procedure structure for procedure `disciplina_push` */

/*!50003 DROP PROCEDURE IF EXISTS  `disciplina_push` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `disciplina_push`()
BEGIN
 
	DECLARE reg_push INT;
	DECLARE mensaje NVARCHAR(1000);
	SET reg_push=0;
		
	/*creo una tabla temporal2 con la diferencia de los articulos que faltan*/
	DROP TABLE IF EXISTS tmp_disciplinaes;
	CREATE TABLE tmp_disciplinaes (SELECT * FROM practicec94.disciplina WHERE id > (SELECT MAX(id) FROM af_disciplina) OR modificado = 1);
	
	REPLACE INTO af_disciplina SELECT * FROM tmp_disciplinaes;
	UPDATE practicec94.disciplina SET modificado = 0 WHERE modificado = 1;
	
	SET reg_push=ROW_COUNT();
	SET mensaje=CONCAT('PROCEDURE disciplina_push(). insertados y/o modificados:', CAST(reg_push AS CHAR(50)) );
	INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
	END */$$
DELIMITER ;

/* Procedure structure for procedure `grupo_push` */

/*!50003 DROP PROCEDURE IF EXISTS  `grupo_push` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `grupo_push`()
BEGIN
 
	DECLARE reg_push INT;
	DECLARE mensaje NVARCHAR(1000);
	SET reg_push=0;
		
	/*creo una tabla temporal2 con la diferencia de los articulos que faltan*/
	DROP TABLE IF EXISTS tmp_grupoes;
	CREATE TABLE tmp_grupoes (SELECT * FROM practicec94.grupo WHERE id > (SELECT MAX(id) FROM af_grupo) OR modificado = 1);
	
	REPLACE INTO af_grupo SELECT * FROM tmp_grupoes;
	UPDATE practicec94.grupo SET modificado = 0 WHERE modificado = 1;
	
	SET reg_push=ROW_COUNT();
	SET mensaje=CONCAT('PROCEDURE grupo_push(). insertados y/o modificados:', CAST(reg_push AS CHAR(50)) );
	INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
	END */$$
DELIMITER ;

/* Procedure structure for procedure `marca_producto_push` */

/*!50003 DROP PROCEDURE IF EXISTS  `marca_producto_push` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `marca_producto_push`()
BEGIN
 
	DECLARE reg_push INT;
	DECLARE mensaje NVARCHAR(1000);
	SET reg_push=0;
		
	/*creo una tabla temporal2 con la diferencia de los articulos que faltan*/
	DROP TABLE IF EXISTS tmp_marca_productoes;
	CREATE TABLE tmp_marca_productoes (SELECT * FROM practicec94.marca_producto WHERE id > (SELECT MAX(id) FROM af_marca_producto) OR modificado = 1);
	
	REPLACE INTO af_marca_producto SELECT * FROM tmp_marca_productoes;
	UPDATE practicec94.marca_producto SET modificado = 0 WHERE modificado = 1;
	
	SET reg_push=ROW_COUNT();
	SET mensaje=CONCAT('PROCEDURE marca_producto_push(). insertados y/o modificados:', CAST(reg_push AS CHAR(50)) );
	INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
	END */$$
DELIMITER ;

/* Procedure structure for procedure `proveedor_push` */

/*!50003 DROP PROCEDURE IF EXISTS  `proveedor_push` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `proveedor_push`()
BEGIN
 
	DECLARE reg_push INT;
	DECLARE mensaje NVARCHAR(1000);
	SET reg_push=0;
		
	/*creo una tabla temporal2 con la diferencia de los articulos que faltan*/
	DROP TABLE IF EXISTS tmp_proveedores;
	CREATE TABLE tmp_proveedores (SELECT * FROM practicec94.proveedor WHERE id > (SELECT MAX(id) FROM af_proveedor) OR modificado = 1);
	
	REPLACE INTO af_proveedor SELECT * FROM tmp_proveedores;
	UPDATE practicec94.proveedor SET modificado = 0 WHERE modificado = 1;
	
	SET reg_push=ROW_COUNT();
	SET mensaje=CONCAT('PROCEDURE proveedor_push(). insertados y/o modificados:', CAST(reg_push AS CHAR(50)) );
	INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
	END */$$
DELIMITER ;

/* Procedure structure for procedure `rubro_push` */

/*!50003 DROP PROCEDURE IF EXISTS  `rubro_push` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `rubro_push`()
BEGIN
 
	DECLARE reg_push INT;
	DECLARE mensaje NVARCHAR(1000);
	SET reg_push=0;
		
	/*creo una tabla temporal2 con la diferencia de los articulos que faltan*/
	DROP TABLE IF EXISTS tmp_rubroes;
	CREATE TABLE tmp_rubroes (SELECT * FROM practicec94.rubro WHERE id > (SELECT MAX(id) FROM af_rubro) OR modificado = 1);
	
	REPLACE INTO af_rubro SELECT * FROM tmp_rubroes;
	UPDATE practicec94.rubro SET modificado = 0 WHERE modificado = 1;
	
	SET reg_push=ROW_COUNT();
	SET mensaje=CONCAT('PROCEDURE rubro_push(). insertados y/o modificados:', CAST(reg_push AS CHAR(50)) );
	INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
	END */$$
DELIMITER ;

/* Procedure structure for procedure `tags_push` */

/*!50003 DROP PROCEDURE IF EXISTS  `tags_push` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `tags_push`()
BEGIN
 
	DECLARE reg_push INT;
	DECLARE mensaje NVARCHAR(1000);
	SET reg_push=0;
		
	/*creo una tabla temporal2 con la diferencia de los articulos que faltan*/
	DROP TABLE IF EXISTS tmp_tagses;
	CREATE TABLE tmp_tagses (SELECT * FROM practicec94.tags WHERE id > (SELECT MAX(id) FROM af_tags) OR modificado = 1);
	
	REPLACE INTO af_tags SELECT * FROM tmp_tagses;
	UPDATE practicec94.tags SET modificado = 0 WHERE modificado = 1;
	
	SET reg_push=ROW_COUNT();
	SET mensaje=CONCAT('PROCEDURE tags_push(). insertados y/o modificados:', CAST(reg_push AS CHAR(50)) );
	INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
	END */$$
DELIMITER ;

/* Procedure structure for procedure `talle_push` */

/*!50003 DROP PROCEDURE IF EXISTS  `talle_push` */;

DELIMITER $$

/*!50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `talle_push`()
BEGIN
 
	DECLARE reg_push INT;
	DECLARE mensaje NVARCHAR(1000);
	SET reg_push=0;
		
	/*creo una tabla temporal2 con la diferencia de los articulos que faltan*/
	DROP TABLE IF EXISTS tmp_tallees;
	CREATE TABLE tmp_tallees (SELECT * FROM practicec94.talle WHERE id > (SELECT MAX(id) FROM af_talle) OR modificado = 1);
	
	REPLACE INTO af_talle SELECT * FROM tmp_tallees;
	UPDATE practicec94.talle SET modificado = 0 WHERE modificado = 1;
	
	SET reg_push=ROW_COUNT();
	SET mensaje=CONCAT('PROCEDURE talle_push(). insertados y/o modificados:', CAST(reg_push AS CHAR(50)) );
	INSERT INTO `__log_evento` (nombre_evento,fe_ejecucion) VALUES(mensaje,NOW());
	END */$$
DELIMITER ;

