<?php
class AppStatus extends Database {

	protected $mSqlFile= 'module/status/business/appstatus.sql.php';

	function __construct($connectionNumber=1) {
		parent::__construct($connectionNumber);
		
	}
	function GetCountDataMahasiswa($periode,$tahun,$prodi,$nama,$notes_nim,$notes_nim){        
      $result =$this->Open($this->mSqlQueries['get_count_data_mahasiswa'], array('%'.$periode.'%','%'.$tahun.'%','%'.$prodi.'%','%'.$nama.'%','%'.$notes_nim.'%','%'.$notes_nim.'%'));
      #print($this->GetLastError());
	   if (!$result) {
			return 0;
		} else {
			return $result[0]['total'];
		}
   }
   
   function GetDataStatusMahasiswa($periode,$tahun,$prodi,$nama,$notes_nim,$notes_nim,$offset,$limit){
      $result =$this->Open($this->mSqlQueries['get_data_status_mahasiswa'], array('%'.$periode.'%','%'.$tahun.'%','%'.$prodi.'%','%'.$nama.'%','%'.$notes_nim.'%','%'.$notes_nim.'%',$offset,$limit));   
      #print($this->GetLastError());
      return $result;
   }
   function GetDetailMahasiswa($idMhs){
      $result=$this->Open($this->mSqlQueries['get_detail_mahasiswa'],array($idMhs));
      #print($this->GetLastError());
      return $result;
   }
   function GetRiwayatMahasiswa($mhsId,$mhsId){   	  
   	  $sql = $this->mSqlQueries['get_riwayat_mahasiswa'];  
   	
   	  //cek apakah mahasiswa ini sudah lulus ato belum
   	  $cekLulus = $this->Open($this->mSqlQueries['get_sem_id_lulus'],array($mhsId));
   	  if($cekLulus[0]['SEMID_LULUS'] != ''){
   	  	$sql = $sql." AND semId <= '".$cekLulus[0]['SEMID_LULUS']."'";
   	  }
   	  
   	  //cek apakah mahasiswa ini termasuk mahasiswa yang sudah keluar (drop out ataupun keluar sendiri)
   	  $cekKeluar = $this->Open($this->mSqlQueries['get_sem_id_mhs_keluar'],array($mhsId));
   	  if($cekKeluar[0]['SEMID_KELUAR'] != ''){
   	  	$sql = $sql." AND semId <= '".$cekKeluar[0]['SEMID_KELUAR']."'";
   	  }
   	  
      $result=$this->Open($sql,array($mhsId,$mhsId));
      #print($this->GetLastError());
      return $result;
   }
   function GetSemesterAktif(){
      $result=$this->Open($this->mSqlQueries['get_semester_aktif'], array());
      #print($this->GetLastError());
      return $result;
   }
   function GetNamaSemester($semAktif){
      $result=$this->Open($this->mSqlQueries['get_nama_semester'], array($semAktif));
      return $result;
   }
   function GetDataPeriode(){
      $result=$this->Open($this->mSqlQueries['get_data_periode'], array());
      return $result;
   }
   function GetDataPeriodeById($idPrd){
      $result=$this->Open($this->mSqlQueries['get_data_periode_by_id'], array($idPrd));
      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 GetNamaPeriode(){
      $result=$this->Open($this->mSqlQueries['get_nama_periode'], array());
      return $result;
   }
   
//===DO===
   
}
?>
