<?php
   $sql['penambahan_atk_mst'] ="
      INSERT IGNORE INTO `inv_atk_master`
      SET `invAtkMstJenisPersediaanId` = '%s',
         `invAtkMstSatuanBarang` = '%s',
         `invAtkMstKeteranganLain` = '%s',
         `invAtkMstUserId` = '%s'
   ";

   $sql['penambahan_atk_detil']="
      INSERT IGNORE INTO `inv_atk_det`
      SET
         `invAtkDetMstId` = %s,
         `invAtkDetBarcode` = '%s',
         `invAtkDetLabel` = '%s',
         `invAtkDetMerk` = '%s',
         `invAtkDetSpesifikasi` = '%s',
         `invAtkDetUserId` = '%s'
   ";

   $sql['penambahan_atk_biaya'] = "
      INSERT IGNORE INTO `inv_atk_biaya`
	   SET
	   `invAtkBiayaAktId` = %s,
	   `invAtkBiayaBiayaId` = '1' ,
	   `invAtkBiayaNominal` = '%s'
   ";

   $sql['update_atk_biaya'] = "
      UPDATE `inv_atk_biaya`
	   SET
	   `invAtkBiayaAktId` = %s,
	   `invAtkBiayaBiayaId` = '1' ,
	   `invAtkBiayaNominal` = '%s'
	   WHERE
	      invAtkBiayaId = '%s'
   ";

   $sql['get_atk_biaya_by_mst_id'] = "
      SELECT
         `invAtkBiayaId`
      FROM `inv_atk_biaya`
      WHERE invAtkBiayaAktId = '%s'
   ";
	
	$sql['get_atk_brg_by_mst_id'] = "
      SELECT
		  invBrgAtkId
		FROM inv_atk_brg
		  LEFT JOIN inv_atk_det
			 ON invAtkDetId = invdet
		WHERE invAtkDetMstId = '%s'
   ";

   $sql['penambahan_atk_brg']="
      INSERT IGNORE INTO `inv_atk_brg`
	   SET
	   `invDet` = '%s' ,
	   `tglPengadaan` = DATE(NOW()) ,
	   `biaya` = '%s' ,
	   `jumlahSatuan` = '%s'
   ";
	
	$sql['perubahan_atk_brg']="
      UPDATE `inv_atk_brg`
	   SET
	   `biaya` = '%s' ,
	   `jumlahSatuan` = '%s',
	   `tglPengadaan` = DATE(NOW())
	   WHERE
	      invDet = '%s'	   
   ";

   $sql['get_atk_max_brg']="
      SELECT MAX(invBrgAtkId) AS invBrgAtkId FROM inv_atk_brg
   ";
	
	$sql['get_atk_max_gdg_by_det_id']="
      SELECT
		  invAtkGudangJumlah AS jumlah
		FROM inv_atk_gudang
		WHERE invAtkGudangInvDtlbrgId = %s
			 AND invAtkGudangRuangId = %s
   ";

   $sql['add_log_atk'] = "
      INSERT INTO `log_atk`
	   SET
	   `logAtkRuangId` = '%s' ,
	   `logAtkAtkId` = '%s' ,
	   `logAtkJmlBrg` = '%s' ,
	   `logAtkStatus` = 'Penambahan Stock Tanpa Pengadaan' ,
	   `logAtkTgl` = NOW(),
	   `logAtkKeterangan` = '%s'
   ";
	
	$sql['add_log_atk_update'] = "
      INSERT INTO `log_atk`
	   SET
	   `logAtkRuangId` = '%s' ,
	   `logAtkAtkId` = '%s' ,
	   `logAtkJmlBrg` = '%s' ,
	   `logAtkStatus` = 'Adjustment Stock' ,
	   `logAtkTgl` = NOW(),
	   `logAtkKeterangan` = '%s'
   ";

   $sql['penambahan_atk_gudang'] = "
      INSERT IGNORE INTO `inv_atk_gudang`
	   SET
	   `invAtkGudangRuangId` = '%s' ,
	   `invAtkGudangInvDtlbrgId` = '%s' ,
	   `invAtkGudangJumlah` = '%s' ,
	   `invAtkGudangNilaiSatuan` = '%s';
   ";
	
	$sql['update_atk_gudang_max'] = "
      UPDATE inv_atk_gudang
			SET invAtkGudangJumlah = '%s'
			WHERE invAtkGudangRuangId = '%s'
				 AND invAtkGudangInvDtlbrgId = '%s'
   ";
	
	$sql['perubahan_atk_gudang'] = "
      UPDATE `inv_atk_gudang`
	   SET
			`invAtkGudangJumlah` = '%s' ,
			`invAtkGudangNilaiSatuan` = '%s'
		WHERE
			`invAtkGudangRuangId` = '%s' AND 
			`invAtkGudangInvDtlbrgId` = '%s'
   ";

   $sql['get_atk_mst_id'] = "
      SELECT invAtkMstId FROM inv_atk_master WHERE invAtkMstJenisPersediaanId = '%s'
   ";

   $sql['get_atk_det_id'] = "
      SELECT invAtkDetId FROM inv_atk_det WHERE (invAtkDetBarcode='%s' OR ''='%s') AND invAtkDetMstId='%s';
   ";

   $sql['update_atk_detil'] = "
      UPDATE `inv_atk_det`
      SET
      `invAtkDetMstId` = '%s' ,
      `invAtkDetLabel` = '%s' ,
      `invAtkDetMerk` = '%s' ,
      `invAtkDetSpesifikasi` = '%s' ,
      `invAtkDetUserId` = '%s'
      WHERE
      `invAtkDetId` = '%s' ;
   ";
?>