-- --------------------------------------------------------
-- Server OS:                    Linux
-- HeidiSQL Version:             11.0.0.5919
-- --------------------------------------------------------

USE inventory;
-- Dumping structure for trigger inventory.surat_penawaran_harga_after_update
DROP TRIGGER IF EXISTS `surat_penawaran_harga_after_update`;
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `surat_penawaran_harga_after_update` AFTER UPDATE ON `surat_penawaran_harga` FOR EACH ROW BEGIN
	IF NEW.STATUS != OLD.STATUS AND NEW.STATUS = 2 THEN
		UPDATE surat_penawaran_harga_detil SET STATUS = 2 WHERE ID_PENAWARAN = NEW.NOMOR AND STATUS = 1;
	END IF;
END//
DELIMITER ;

-- Dumping structure for trigger inventory.surat_penawaran_harga_detil_before_insert
DROP TRIGGER IF EXISTS `surat_penawaran_harga_detil_before_insert`;
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `surat_penawaran_harga_detil_before_insert` BEFORE INSERT ON `surat_penawaran_harga_detil` FOR EACH ROW BEGIN
	IF NEW.DISKON_BELI < 1 THEN
		SET NEW.DISKON_BELI = 1;
	END IF;
END//
DELIMITER ;

