<?php

$sql['template'] =
   ("
      INSERT INTO
      VALUES
      SELECT
      UPDATE
      SET
      DELETE
      FROM
      WHERE
      GROUP BY
      ORDER BY
      LIMIT
   ");
   
// Get query....

$sql['get_combo_golongan'] = 
   "SELECT 
     `golbrgId` as `id`,
	  `golbrgNama` as `name`
   FROM 
      `golongan_barang_ref`
   ORDER BY `golbrgNama`
";

$sql['get_combo_jenis_barang'] = 
   "SELECT 
     `jenisbrgId` as `id`,
	  `jenisbrgNama` as `name`
   FROM 
      `jenis_barang_ref`
   ORDER BY `jenisbrgNama`
";

$sql['get_combo_satuan_barang'] = 
   "SELECT 
     `satuanbrgId` as `id`,
	  `satuanbrgNama` as `name`
   FROM 
      `satuan_barang_ref`
   ORDER BY `satuanbrgNama`
";

$sql['get_data_barang_count'] =
    "
      SELECT 
         COUNT(`nama`) as `total`
	  FROM(
			SELECT
		         `kelbrgId` as `idKelompok`,
		         `subkelbrgId` as `idSubKelompok`,
		         `barangId` as `id`,
		         CONCAT(LPAD(`golbrgKode`,1,0),'.',LPAD(`bidangbrgKode`,2,0),'.',LPAD(`kelbrgKode`,2,0),'.',LPAD(`subkelbrgKode`,2,0),'.',LPAD(`barangKode`,3,0)) as `kode`,
		         `barangNama` as `nama`,
		         `barangSatuanbrgId` as `satuan`,
				 `barangUmurEkonomis` AS umurEkonomis,
				 `barangNilaiResidu` AS nilaiResidu
		    FROM 
		         `golongan_barang_ref`
		         JOIN `bidang_barang_ref` ON (`bidangbrgGolbrgId` = `golbrgId`)
		         JOIN `kelompok_barang_ref` ON (`kelbrgBidangbrgId` = `bidangbrgId`)
		         JOIN `sub_kelompok_barang_ref` ON (`subkelbrgKelbrgId` = `kelbrgId`)
		         JOIN `barang_ref` ON (`barangSubkelbrgId` = `subkelbrgId`)
		         WHERE 
						golbrgId = '%s'
		         )a
	  WHERE kode LIKE '%s' AND
			nama LIKE '%s'	
   ";

$sql['get_data_barang'] =
   "SELECT * FROM(
		SELECT
	         `kelbrgId` as `idKelompok`,
	         `subkelbrgId` as `idSubKelompok`,
	         `barangId` as `id`,
	         CONCAT(LPAD(`golbrgKode`,1,0),'.',LPAD(`bidangbrgKode`,2,0),'.',LPAD(`kelbrgKode`,2,0),'.',LPAD(`subkelbrgKode`,2,0),'.',LPAD(`barangKode`,3,0)) as `kode`,
	         `barangNama` as `nama`,
	         `barangSatuanbrgId` as `satuan`,
			 `barangUmurEkonomis` AS umurEkonomis,
			 `barangNilaiResidu` AS nilaiResidu,
			   barangHps AS hps
	    FROM 
	         `golongan_barang_ref`
	         JOIN `bidang_barang_ref` ON (`bidangbrgGolbrgId` = `golbrgId`)
	         JOIN `kelompok_barang_ref` ON (`kelbrgBidangbrgId` = `bidangbrgId`)
	         JOIN `sub_kelompok_barang_ref` ON (`subkelbrgKelbrgId` = `kelbrgId`)
	         JOIN `barang_ref` ON (`barangSubkelbrgId` = `subkelbrgId`)
	         WHERE 
				golbrgId = '%s'
	         )a
	WHERE kode LIKE '%s' AND
		  nama LIKE '%s'	
    LIMIT
         %d, %d
   ";

$sql['get_kelompok_list'] =
   ("
      SELECT 
         `kelbrgId` as `id`,
         CONCAT(LPAD(`golbrgKode`,1,0),'.',LPAD(`bidangbrgKode`,2,0),'.',LPAD(`kelbrgKode`,2,0)) as `kode`,
         `kelbrgNama` as `nama`
      FROM 
         `golongan_barang_ref`
         JOIN `bidang_barang_ref` ON (`bidangbrgGolbrgId` = `golbrgId`)
         JOIN `kelompok_barang_ref` ON (`kelbrgBidangbrgId` = `bidangbrgId`)
      ORDER BY
         `kelbrgNama`
   ");

$sql['get_sub_kelompok_list'] =
   ("
      SELECT
         `kelbrgId` as `idKelompok`,
         `subkelbrgId` as `id`,
         CONCAT(LPAD(`golbrgKode`,1,0),'.',LPAD(`bidangbrgKode`,2,0),'.',LPAD(`kelbrgKode`,2,0),'.',LPAD(`subkelbrgKode`,2,0)) as `kode`,
         `subkelbrgNama` as `nama`
      FROM 
         `golongan_barang_ref`
         JOIN `bidang_barang_ref` ON (`bidangbrgGolbrgId` = `golbrgId`)
         JOIN `kelompok_barang_ref` ON (`kelbrgBidangbrgId` = `bidangbrgId`)
         JOIN `sub_kelompok_barang_ref` ON (`subkelbrgKelbrgId` = `kelbrgId`)
      ORDER BY
         `subkelbrgNama`
   ");

?>
