<?php

class AppSmta extends Database {

	protected $mSqlFile= 'module/smta/business/appsmta.sql.php';
	
	function __construct($connectionNumber=0) {
		parent::__construct($connectionNumber);
		
	}
		
	function GetDataSmta($offset, $limit, $kodeSmta='',$namaSmta='',$kotaKode='') {
      $result =$this->Open($this->mSqlQueries['get_data_smta'], array('%'.$kotaKode.'%','%'.$namaSmta.'%','%'.$kodeSmta.'%', $offset, $limit));
      return $result;
  }
  
	function GetDataKota() {	
      $result =$this->Open($this->mSqlQueries['get_data_kota'], array());
      
      return $result;
  }

	function GetDataKotaById($kotaKode) {	
      $result =$this->Open($this->mSqlQueries['get_data_kota_by_id'], array($kotaKode));
      //print $this->GetLastError();
      return $result;
  }
	function GetCountDataSmta($kodeSmta,$namaSmta,$kotaKode) {
		$result = $this->Open($this->mSqlQueries['get_count_data_smta'], array('%'.$kodeSmta.'%','%'.$namaSmta.'%','%'.$kotaKode.'%'));
		if (!$result) {
			return 0;
		} else {
			return $result[0]['total'];
		}
	}

	function GetDataSmtaById($idSmta) {
		$result = $this->Open($this->mSqlQueries['get_data_smta_by_id'], array($idSmta));
		return $result;
	}

	function GetDataSmtaByArrayId($arrIdSmta) {
		$idSmta = implode("', '", $arrIdSmta);
		$result = $this->Open($this->mSqlQueries['get_data_smta_by_array_id'], array($idSmta));
		return $result;
	}

//===DO==
	
	function DoAddSmta($kodeSmta,$kodeKota,$namaSmta) {
		$result = $this->Execute($this->mSqlQueries['do_add_smta'], array($kodeSmta,$kodeKota,$namaSmta));
		return $result;
	}
	
	function DoUpdateSmta($kodeSmta,$kodeKota, $namaSmta,$smtaId) {
	
		$result = $this->Execute($this->mSqlQueries['do_update_smta'], array($kodeSmta,$kodeKota, $namaSmta,$smtaId));
		return $result;
	}
	
	function DoDeleteSmtaById($idSmta) {
		$result=$this->Execute($this->mSqlQueries['do_delete_smta_by_id'], array($idSmta));
		return $result;
	}

	function DoDeleteSmtaByArrayId($arrIdSmta) {
		$idSmta = implode("', '", $arrIdSmta);
		$result=$this->Execute($this->mSqlQueries['do_delete_smta_by_array_id'], array($idSmta));
		return $result;
	}
}
?>
