<?php	
$sql['kondisi_barang'] = "
	SELECT 
		kondisibrgId AS id,
		kondisibrgNama AS `name` 
	FROM
		kondisi_barang_ref 

";

$sql['get_count']="
SELECT FOUND_ROWS() AS total
";

$sql['get_data_barang'] =
	"
   SELECT 
   	   SQL_CALC_FOUND_ROWS
	   * 
	FROM
	   (SELECT 
		  `invDetId` AS barang_id,
		  `invDetKodeBarang` AS `kode_barang`,
		  `barangNama` AS nama_barang,
		  a.`invDetMstLabel` AS `label`,
		  e.`kondisibrgNama` AS `kondisi`,
		  e.`kondisibrgId` AS `kondisi_id` 
	   FROM `inventarisasi_detail` a 
	   LEFT JOIN `inventarisasi_mst` b ON `invDetMstId` = `invMstId` 
	   LEFT JOIN `barang_ref` c ON `invBarangId` = `barangId` 
	   LEFT JOIN `inv_kondisi_history` d ON `invDetId` = `invKondisiBrgBrgDetId` 
	   LEFT JOIN `kondisi_barang_ref` e	 ON `invKondisiBrgKondId` = `kondisibrgId`
	   LEFT JOIN do_detail_new ON doDetInvDetId = invDetId 
	   /*LEFT JOIN pengendalian_barang_det ON pengBrgInvDetId = a.invDetId*/ 
	   WHERE invDetRuanganId = '%s' 
		  AND invDetUnitKerja = '%s' 
		  AND invDetAsetStatusId = '1' 
		  -- tampilkan hasil konversi dan barang yang sudah di DO
   		  AND (invMstPengadaanId IS NULL OR (invMstPengadaanId IS NOT NULL AND doDetId IS NOT NULL AND doDetRuangId IS NOT NULL)) 
		  /*AND pengBrgDetId IS NULL*/ 
	   ORDER BY `invKondisiBrgId` DESC) a 
	WHERE `kode_barang` LIKE '%s' 
	   AND (kondisi_id = '%s' 
		  OR 'all' = '%s') 
	GROUP BY barang_id
	LIMIT %d, %d
   ";
?>
