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

USE inventory;
-- Dumping structure for procedure inventory.CetakPurchaseOrder
DROP PROCEDURE IF EXISTS `CetakPurchaseOrder`;
DELIMITER //
CREATE PROCEDURE `CetakPurchaseOrder`(
	IN `PNOPO` VARCHAR(50)
)
BEGIN
	SELECT po.NO_PO,po.NO_MR,po.SUPPLIER,po.TANGGAL,po.OLEH, pod.JUMLAH AS JML, br.NAMA , s.NAMA AS SATUAN,sphd.HARGA, sphd.DISKON_PERSEN, sphd.DISKON_RUPIAH,(pod.JUMLAH * sphd.HARGA) AS JmlHrg, ((pod.JUMLAH * sphd.HARGA) - sphd.DISKON_RUPIAH) AS TotalHrg, p.NAMA AS NAMA_SUPPLIER,p.ALAMAT,p.TELEPON, p.FAX, usr.NAMA, usr.NIP
	FROM inventory.purchase_order po
		LEFT JOIN inventory.purchase_order_detil pod ON pod.ID_PO = po.NO_PO AND pod.STATUS = 1
		LEFT JOIN inventory.material_request_detil mrd ON mrd.ID = pod.ID_MR_DETIL
		LEFT JOIN inventory.surat_penawaran_harga_detil sphd ON sphd.ID = mrd.ID_SPH
		LEFT JOIN inventory.penyedia p ON p.ID = po.SUPPLIER
		LEFT JOIN inventory.barang_ruangan bru ON bru.ID = pod.BARANG
		LEFT JOIN inventory.barang br ON br.ID = bru.BARANG
		LEFT JOIN inventory.satuan s ON s.ID = br.SATUAN
		LEFT JOIN aplikasi.pengguna usr ON usr.ID = po.OLEH
	WHERE po.NO_PO = PNOPO;
END//
DELIMITER ;

