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

USE inventory;
-- Dumping structure for procedure inventory.CetakMaterialRequest
DROP PROCEDURE IF EXISTS `CetakMaterialRequest`;
DELIMITER //
CREATE PROCEDURE `CetakMaterialRequest`(
	IN `PNOMOR` VARCHAR(50)
)
BEGIN
	SELECT m.NO_MR, m.TANGGAL, m.`STATUS`, b.NAMA, md.KATEGORI
		, IF(md.RATAPENJUALAN IS NULL,0,md.RATAPENJUALAN) QTY, (IF(md.RATAPENJUALAN IS NULL,0,md.RATAPENJUALAN) * 3) QTY3BULAN
		, 0 QTYBUFFER
		, md.SISA_STOK STOKAKHIR, md.JML_RUMUS JUMLAHORDER
		, k.NAMA KATEGORIOBAT, 0 HARGAESTIMASI, md.JUMLAH QTYDIRENCANAKAN 
	FROM inventory.material_request m
	   , inventory.material_request_detil md
		, inventory.barang b
		  LEFT JOIN inventory.kategori k ON b.KATEGORI=k.ID
	WHERE b.ID = md.BARANG AND md.NO_MR = m.NO_MR AND md.STATUS IN (1,2) AND m.NO_MR = PNOMOR;
END//
DELIMITER ;

