USE `inventory`;
DROP TRIGGER IF EXISTS `penerimaan_barang_after_insert`;
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `penerimaan_barang_after_insert` AFTER INSERT ON `penerimaan_barang` FOR EACH ROW BEGIN
	IF EXISTS(SELECT 1 FROM mysql.innodb_table_stats r WHERE r.database_name = 'bridge' AND r.table_name = 'ska_penerimaan') THEN
			IF NEW.STATUS = 1 AND NEW.JENIS = 3 THEN
				CALL bridge.sendBridgePenerimaanSkaDetail(NEW.REF_SKA, NEW.ID, IF(NEW.PPN = 'Ya', 0, 1),0);
			END IF;
	END IF;
END//
DELIMITER ;
