-- --------------------------------------------------------
-- Server OS:                    Linux
-- HeidiSQL Version:             12.0.0.6468
-- --------------------------------------------------------


USE `laundry`;

-- Dumping structure for table laundry.reject
CREATE TABLE IF NOT EXISTS `reject` (
  `NOMOR` char(21) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `RUANGAN` char(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `TANGGAL` datetime NOT NULL,
  `OLEH` smallint NOT NULL,
  `STATUS` tinyint NOT NULL DEFAULT '1',
  PRIMARY KEY (`NOMOR`) USING BTREE,
  KEY `TANGGAL` (`TANGGAL`) USING BTREE,
  KEY `STATUS` (`STATUS`) USING BTREE,
  KEY `RUANGAN` (`RUANGAN`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- Data exporting was unselected.

-- Dumping structure for trigger laundry.reject_after_update
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `reject_after_update` AFTER UPDATE ON `reject` FOR EACH ROW BEGIN
	IF NEW.STATUS = 2 THEN
		UPDATE laundry.detil_reject dr 
		   SET dr.STATUS = 2
		 WHERE dr.REJECT = OLD.NOMOR AND dr.STATUS=1;
	END IF;
	
	IF NEW.STATUS = 1 THEN
		UPDATE laundry.detil_reject dr 
		   SET dr.STATUS = 1
		 WHERE dr.REJECT = OLD.NOMOR AND dr.STATUS=2;
	END IF;
END//
DELIMITER ;

