<?php
class AppStatusBayar extends Database {
   
	protected $mSqlFile= 'module/status_bayar/business/appstatusbayar.sql.php';

	function __construct($connectionNumber=0) {
		parent::__construct($connectionNumber);
		//$this->SetDebugOn();
	}
	
	function getPeriodeAktifForQuery(){
		$result=$this->Open($this->mSqlQueries['get_periode_aktif_for_query'],array());
      return $result[0];	
	}

	function GetCountStatusBayarMahasiswa($tahun,$periode,$prodi,$nama,$notes_nim,$status_byr,$status_reg){
		$prdAktif = $this->getPeriodeAktifForQuery();
		
		//bentuk sql where mahasiswa registrasi
		switch($status_reg){
			case 'all':
				$sqlStatusReg = "";
			break;
			case 'B':
				$sqlStatusReg = " AND mhsRegId IS NULL ";
			break;
			case 'S':
				$sqlStatusReg = " AND mhsRegId IS NOT NULL ";	
			break;
		}
		$sql = str_replace('{WHERE_UTK_STS_REGISTRASI}',$sqlStatusReg,$this->mSqlQueries['get_count_status_bayar_mahasiswa']);
		
		$param = array(
			$periode,
			$tahun,
			$prodi,
			'%'.$notes_nim.'%',
			'%'.$nama.'%',
			$status_byr,
			$prdAktif['prdId'],
			$prdAktif['prdSemId']			
		);		       
      $result =$this->Open($sql,$param);
      
	   if (!$result) {
			return 0;
		} else {
			return $result[0]['BANYAK'];
		}
   }
   
   function GetDataStatusBayarMahasiswa($tahun,$periode,$prodi,$nama,$notes_nim,$status_byr,$status_reg,$offset,$limit){
   	$prdAktif = $this->getPeriodeAktifForQuery();
   	
		//bentuk sql where mahasiswa registrasi
		switch($status_reg){
			case 'all':
				$sqlStatusReg = "";
			break;
			case 'B':
				$sqlStatusReg = " AND mhsRegId IS NULL ";
			break;
			case 'S':
				$sqlStatusReg = " AND mhsRegId IS NOT NULL ";	
			break;
		}
		$sql = str_replace('{WHERE_UTK_STS_REGISTRASI}',$sqlStatusReg,$this->mSqlQueries['get_status_bayar_mahasiswa']);
		
		$param = array(
			$periode,
			$tahun,
			$prodi,
			'%'.$notes_nim.'%',
			'%'.$nama.'%',
			$status_byr,			
			$offset,
			$limit,
			$prdAktif['prdId'],
			$prdAktif['prdSemId']			
		);
				       
      $result =$this->Open($sql,$param);				      
      return $result;
   }
   
   function GetDataMahasiswa($mhsId){
      $result=$this->Open($this->mSqlQueries['get_data_mahasiswa'],array($mhsId));
      return $result;
   }
   
   function GetDetilStatusBayar($mhsId,$mhsId){
   	$prdAktif = $this->getPeriodeAktifForQuery();
   	
      $result=$this->Open($this->mSqlQueries['get_detil_status_bayar'],array($mhsId,$prdAktif['prdSemId']));				      
      return $result;
   }
   
   function GetDataTahun(){
      $result=$this->Open($this->mSqlQueries['get_data_tahun'],array());
      return $result;
   }
   
   function GetPeriodeAktif(){
      $result=$this->Open($this->mSqlQueries['get_periode_aktif'],array());
      return $result;
   }
   
   function GetNamaPeriode(){
      $result=$this->Open($this->mSqlQueries['get_nama_periode'],array());
      return $result;
   }
   
   function GetDataPeriode(){
      $result=$this->Open($this->mSqlQueries['get_data_periode'], array());
      return $result;
   }
   
   function GetDataProdi(){
      $result=$this->Open($this->mSqlQueries['get_data_prodi'], array());
      return $result;
   }
   
   function GetDataProdiById($idProdi){
      $result=$this->Open($this->mSqlQueries['get_data_prodi_by_id'], array($idProdi));
      return $result;
   }
   
   function GetStatusBayar(){
      $statusBayar[0]['id']="BB";
      $statusBayar[0]['name']="Belum Bayar";
      $statusBayar[1]['id']="BL";
      $statusBayar[1]['name']="Belum Lunas";
      $statusBayar[2]['id']="L";
      $statusBayar[2]['name']="Lunas";
      return $statusBayar;
   }
   
   function GetStatusRegistrasi(){
      $statusRegistrasi[0]['id']="S";
      $statusRegistrasi[0]['name']="Sudah";
      $statusRegistrasi[1]['id']="B";
      $statusRegistrasi[1]['name']="Belum";      
      return $statusRegistrasi;
   }
   
//===DO===
   
}
?>
