-- --------------------------------------------------------
-- Host:                         192.168.56.3
-- Server version:               8.0.22 - MySQL Community Server - GPL
-- Server OS:                    Linux
-- HeidiSQL Version:             11.0.0.5919
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
USE inventory;
-- Dumping structure for trigger inventory.purchase_order_detil_after_update
DROP TRIGGER IF EXISTS `purchase_order_detil_after_update`;
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `purchase_order_detil_after_update` AFTER UPDATE ON `purchase_order_detil` FOR EACH ROW BEGIN
	IF OLD.STATUS != NEW.STATUS AND NEW.STATUS = 2 THEN
		-- INSERT KE TABLE PENERIMAAN PO TEMP   
		INSERT INTO inventory.penerimaan_po_temp (ID_PO_DETIL, BARANG, JUMLAH_PESAN, BONUS, JUMLAH_TERIMA, STATUS)
		VALUES(OLD.ID, OLD.BARANG, OLD.JUMLAH, OLD.JUMLAH_BONUS, 0, 1);
		-- ******* ---
		
	END IF;
END//
DELIMITER ;
SET SQL_MODE=@OLDTMP_SQL_MODE;

/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
