<?php

//==========GET DATA ======================================
$sql['get_data_user_by_user_name'] = "
SELECT 
   UserId AS user_id,
   UserName AS user_name,
   RealName AS real_name,
   a.Description AS description,
   Active AS is_active,
   a.GroupId AS group_id,
   GroupName AS group_name,
   unitkerjaId,
   unitkerjaNama,
   userunitkerjaRoleId AS role_id,
   unitkerjaKodeSistem
FROM 
   gtfw_user a
   JOIN gtfw_group b ON b.GroupId = a.GroupId
   LEFT JOIN user_unit_kerja ON UserId = userunitkerjaUserId
   LEFT JOIN unit_kerja_ref ON unitkerjaId = userunitkerjaUnitkerjaId
WHERE
   UserName = %s
";

$sql['get_count_data_lelang_barang'] = "
	SELECT
		COUNT(DISTINCT(transAtkMstId)) AS total
	FROM aset_transaksi_atk
		LEFT JOIN aset_transaksi_atk_detil
		  ON transAtkDetTransMstId = transAtkMstId
		LEFT JOIN inv_atk_det
		  ON invAtkDetId = transAtkDetAtkId
		LEFT JOIN inv_atk_brg
		  ON invDet = invAtkDetId
		LEFT JOIN inv_atk_gudang
		  ON invAtkGudangInvDtlbrgId = invBrgAtkId
		LEFT JOIN ruang
		  ON ruangId = invAtkGudangRuangId
		LEFT JOIN gtfw_user
			ON UserId = transAtkMstUserid
		LEFT JOIN user_unit_kerja
			ON userunitkerjaUserId = UserId
		LEFT JOIN unit_kerja_ref
			ON unitkerjaId = transAtkMstUnitKerjaId
	WHERE transAtkMstNomor LIKE '%s'
		AND (unitkerjaId = %s OR unitkerjaParentId = %s OR 1 = %s)
		AND (unitkerjaId = %s OR '' = %s)
		AND ruangId != '%s'
";
		
$sql['get_data_lelang_barang']="
	SELECT
		unitkerjaNama         AS unit_nama,
		transAtkMstId         AS trans_id,
		transAtkMstTglEntry   AS trans_tanggal,
		transAtkMstNomor      AS trans_nomor,
		transAtkMstKeterangan AS trans_keterangan,
		transAtkNamaPenerima  AS trans_nama
	FROM aset_transaksi_atk
		LEFT JOIN aset_transaksi_atk_detil
		  ON transAtkDetTransMstId = transAtkMstId
		LEFT JOIN inv_atk_det
		  ON invAtkDetId = transAtkDetAtkId
		LEFT JOIN inv_atk_brg
		  ON invDet = invAtkDetId
		LEFT JOIN inv_atk_gudang
		  ON invAtkGudangInvDtlbrgId = invBrgAtkId
		LEFT JOIN ruang
		  ON ruangId = invAtkGudangRuangId
		LEFT JOIN gtfw_user
		 ON UserId = transAtkMstUserid
		LEFT JOIN user_unit_kerja
			ON userunitkerjaUserId = UserId
		LEFT JOIN unit_kerja_ref
			ON unitkerjaId = transAtkMstUnitKerjaId
	WHERE transAtkMstNomor LIKE '%s'
			AND (unitkerjaKodeSistem = '%s' OR unitkerjaKodeSistem LIKE '%s')
			[SEARCH_UNIT] [SEARCH_MONTH] [SEARCH_YEAR]
		    AND ruangId != '%s'
	GROUP BY transAtkMstId
	ORDER BY transAtkMstId DESC
	LIMIT %s, %s
";
 
$sql['get_data_pengelolaan_by_id']=" 	
   SELECT
     transAtkMstId              AS trans_id,
     transAtkMstTglEntry        AS trans_tanggal,
     transAtkMstNomor           AS trans_nomor,
     transAtkMstKeterangan      AS trans_keterangan,
     transAtkNamaPenerima       AS trans_nama,
     transAtkDetAtkId           AS barangId,
     CONCAT(LPAD(golbrgKode, 1, '0'), '.', LPAD(bidangbrgKode, 2, '0'), '.', LPAD(kelbrgKode, 2, '0'), '.', LPAD(subkelbrgKode, 2, '0'), '.', LPAD(barangKode, 3, '0'),'.',invAtkKode) AS barangKode,
     invAtkNama                 AS barangNama,
     transAtkDetKeteranganDetil AS barangDiskripsi,
     transAtkDetJmlAtk          AS jumlah,
     transAtkDetNilaiSatuan     AS lelangBiaya,
     (SELECT
        lelangBiaya*jumlah) AS total,
     unitkerjaNama              AS nama_unit
   FROM aset_transaksi_atk
     LEFT JOIN aset_transaksi_atk_detil
       ON transAtkDetTransMstId = transAtkMstId
     LEFT JOIN inv_atk_det
       ON invAtkDetId = transAtkDetAtkId
     LEFT JOIN inv_atk_master
       ON invAtkMstId = invAtkDetMstId
     LEFT JOIN inv_atk_jenis_ref
       ON invAtkMstJenisPersediaanId = invAtkJenisRefId
     LEFT JOIN barang_ref
       ON invAtkJenisBarangRefId = barangId
     LEFT JOIN sub_kelompok_barang_ref
       ON subkelbrgId = barangSubkelbrgId
     LEFT JOIN kelompok_barang_ref
       ON kelbrgId = subkelbrgKelbrgId
     LEFT JOIN bidang_barang_ref
       ON bidangbrgId = kelbrgBidangbrgId
     LEFT JOIN golongan_barang_ref
       ON golbrgId = bidangbrgGolbrgId
     LEFT JOIN unit_kerja_ref
       ON unitkerjaId = transAtkMstUnitKerjaId
	WHERE 
		transAtkMstId = '%s'		
";
?>
