<?php
$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_list_dir'] = "
SELECT 
   invDetId AS id,
   unitkerjaKode,
   CONCAT(
      LPAD(
         IFNULL(
            EXTRACT(YEAR FROM a.invTglPembelian),
            0
         ),
         4,
         '0'
      ),
      '.',
      IFNULL(ruangKode, 0)
   ) AS tahun,
   invDetKodeBarang
    AS kode_barang 
FROM
   inventarisasi_mst a 
   LEFT JOIN barang_ref 
      ON invBarangId = barangId 
   LEFT JOIN sub_kelompok_barang_ref 
      ON barangSubkelbrgId = subkelbrgId 
   LEFT JOIN kelompok_barang_ref 
      ON subkelbrgKelbrgId = kelbrgId 
   LEFT JOIN bidang_barang_ref 
      ON kelbrgBidangbrgId = bidangbrgId 
   LEFT JOIN golongan_barang_ref 
      ON bidangbrgGolbrgId = golbrgId 
   LEFT JOIN inventarisasi_detail 
      ON invDetMstId = invMstId 
   INNER JOIN ruang 
      ON invDetRuanganId = ruangId 
      AND invDetRuanganId IS NOT NULL 
   LEFT JOIN gedung 
      ON ruangGedungId = gedungId 
   LEFT JOIN unit_kerja_ref 
      ON ruangUnitId = unitkerjaId 
WHERE (ruangGedungId = '%s' 
      OR 'all' = '%s') 
   AND (invDetRuanganId = '%s' 
      OR 'all' = '%s')
   AND (unitkerjaKodeSistem = '%s' OR unitkerjaKodeSistem LIKE '%s')
   AND invDetAsetStatusId = 1 
";
?>
