<?php

//===GET===
//old sql
$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
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'] = 
   "SELECT 
      count(gedungId) AS total
   FROM
      ruang
      LEFT JOIN gedung ON gedungId = ruangGedungId
		LEFT JOIN unit_kerja_ref ON unitkerjaId = gedungUnitkerjaId
   WHERE
      gedungKode LIKE '%s' AND
      ruangKode LIKE '%s' AND
      (gedungNama LIKE '%s' OR ruangNama LIKE '%s')
		AND (gedungUnitkerjaId = %s OR unitkerjaParentId = %s OR '1' = %s)
";

$sql['get_data'] = "
   SELECT
      gedungId,
      gedungKode,
      gedungNama,
      ruangId,
      ruangKode,
      ruangNama
   FROM
      ruang
      LEFT JOIN gedung ON gedungId = ruangGedungId
		LEFT JOIN unit_kerja_ref ON unitkerjaId = gedungUnitkerjaId
   WHERE
      gedungKode LIKE '%s' AND
      ruangKode LIKE '%s' AND
      (gedungNama LIKE '%s' OR ruangNama LIKE '%s')
		AND (gedungUnitkerjaId = %s OR unitkerjaParentId = %s OR '1' = %s)
	ORDER BY gedungKode, gedungNama
	LIMIT %s, %s
";

?>
