/*
SQLyog Ultimate
MySQL - 5.7.31 : Database - practicec94
*********************************************************************
*/



/* Trigger structure for table `articulo` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `add_articulo` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `add_articulo` BEFORE INSERT ON `articulo` FOR EACH ROW TheTrigger:BEGIN
	if(NEW.agregado_local='RSP') then
		leave TheTrigger;
	else
		SET NEW.agregado_local = 'AF';
	end if;
    END */$$


DELIMITER ;

/* Trigger structure for table `articulo` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `update_articulo` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `update_articulo` BEFORE UPDATE ON `articulo` FOR EACH ROW TheTrigger:BEGIN
                    IF (NEW.modificado!=OLD.modificado) THEN
                    LEAVE TheTrigger;
	ELSEIF (NEW.modificado_local!=OLD.modificado_local) then
                    LEAVE TheTrigger;                    
        ELSEIF (NEW.updated_at!=OLD.updated_at) THEN #esto permite que no se active el modificado = 1 tan solo por la modificacion desde facturacion del stock
		    SET NEW.modificado_stock = 1;
                    LEAVE TheTrigger;
                    ELSE
                    SET NEW.modificado = 1;
                    SET NEW.modificado_local = "AF";
                    END IF;
    END */$$


DELIMITER ;

/* Trigger structure for table `color` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `add_color` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `add_color` BEFORE INSERT ON `color` FOR EACH ROW TheTrigger:BEGIN

		SET NEW.modificado = 1;

    END */$$


DELIMITER ;

/* Trigger structure for table `color` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `update_color` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `update_color` BEFORE UPDATE ON `color` FOR EACH ROW TheTrigger:BEGIN
	SET NEW.modificado = 1;
    END */$$


DELIMITER ;

/* Trigger structure for table `disciplina` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `add_disciplina` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `add_disciplina` BEFORE INSERT ON `disciplina` FOR EACH ROW TheTrigger:BEGIN


		SET NEW.modificado = 1;
	
    END */$$


DELIMITER ;

/* Trigger structure for table `disciplina` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `update_disciplina` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `update_disciplina` BEFORE UPDATE ON `disciplina` FOR EACH ROW TheTrigger:BEGIN
	SET NEW.modificado = 1;
    END */$$


DELIMITER ;

/* Trigger structure for table `grupo` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `add_grupo` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `add_grupo` BEFORE INSERT ON `grupo` FOR EACH ROW TheTrigger:BEGIN

		SET NEW.modificado = 1;

    END */$$


DELIMITER ;

/* Trigger structure for table `grupo` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `update_grupo` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `update_grupo` BEFORE UPDATE ON `grupo` FOR EACH ROW TheTrigger:BEGIN
	SET NEW.modificado = 1;
    END */$$


DELIMITER ;

/* Trigger structure for table `marca_producto` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `add_marca_producto` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `add_marca_producto` BEFORE INSERT ON `marca_producto` FOR EACH ROW TheTrigger:BEGIN

		SET NEW.modificado = 1;

    END */$$


DELIMITER ;

/* Trigger structure for table `marca_producto` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `update_marca_producto` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `update_marca_producto` BEFORE UPDATE ON `marca_producto` FOR EACH ROW TheTrigger:BEGIN
	SET NEW.modificado = 1;
    END */$$


DELIMITER ;

/* Trigger structure for table `proveedor` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `add_proveedor` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `add_proveedor` BEFORE INSERT ON `proveedor` FOR EACH ROW TheTrigger:BEGIN
 
		SET NEW.modificado = 1;
    END */$$


DELIMITER ;

/* Trigger structure for table `proveedor` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `update_proveedor` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `update_proveedor` BEFORE UPDATE ON `proveedor` FOR EACH ROW TheTrigger:BEGIN
	SET NEW.modificado = 1;
    END */$$


DELIMITER ;

/* Trigger structure for table `rubro` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `add_rubro` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `add_rubro` BEFORE INSERT ON `rubro` FOR EACH ROW TheTrigger:BEGIN

		SET NEW.modificado = 1;

    END */$$


DELIMITER ;

/* Trigger structure for table `rubro` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `update_rubro` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `update_rubro` BEFORE UPDATE ON `rubro` FOR EACH ROW TheTrigger:BEGIN
	SET NEW.modificado = 1;
    END */$$


DELIMITER ;

/* Trigger structure for table `tags` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `add_tags` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `add_tags` BEFORE INSERT ON `tags` FOR EACH ROW TheTrigger:BEGIN

		SET NEW.modificado = 1;

    END */$$


DELIMITER ;

/* Trigger structure for table `tags` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `update_tags` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `update_tags` BEFORE UPDATE ON `tags` FOR EACH ROW TheTrigger:BEGIN
	SET NEW.modificado = 1;
    END */$$


DELIMITER ;

/* Trigger structure for table `talle` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `add_talle` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `add_talle` BEFORE INSERT ON `talle` FOR EACH ROW TheTrigger:BEGIN

		SET NEW.modificado = 1;

    END */$$


DELIMITER ;

/* Trigger structure for table `talle` */

DELIMITER $$

/*!50003 DROP TRIGGER*//*!50032 IF EXISTS */ /*!50003 `update_talle` */$$

/*!50003 CREATE */ /*!50017 DEFINER = 'root'@'localhost' */ /*!50003 TRIGGER `update_talle` BEFORE UPDATE ON `talle` FOR EACH ROW TheTrigger:BEGIN
	SET NEW.modificado = 1;
    END */$$


DELIMITER ;

