<?php
class AppPesertaLolos extends Database{
   protected $mSqlFile= 'module/peserta_lolos/business/apppesertalolos.sql.php';
   function __construct($connectionNumber=0) {      
      parent::__construct($connectionNumber);
      
   }

//=========Get===========
   function GetCountDataMahasiswa($thnMasuk,$nim_notest,$isCalon,$programStudi,$nama,$semsMasuk){
      if($nim_notest!=""){
         $new_sql = "AND(
         mhsNiu  LIKE '%s' OR
         mhsNomorTes LIKE '%s') ";         
      }      
      
      $sql = $this->mSqlQueries['get_count_data_mahasiswa']. $new_sql;
      if($nim_notest==""){
      
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       '%'.$programStudi.'%',
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%'));
      }else{
      
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       '%'.$programStudi.'%',
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%',
                                       '%'.$nim_notest.'%',
                                       '%'.$nim_notest.'%'));
      }
      
      //print($this->GetLastError());exit;
      
      if(!$result){
         return 0;
      }else{
         return $result[0]['total'];
      } 
   }

   function GetDataMahasiswa($thnMasuk,$nim_notest,$isCalon,$programStudi,$nama,$semsMasuk,$offset,$limit){
   
	  if($programStudi==""){$programStudi='%'.$programStudi.'%';}

      // pengurutan tahun terbaru paling atas, nama prodi, nim, nomor tes
      if($nim_notest==""){
      
          $new_sql=" ORDER BY CONCAT(mhsTahunAjaran, mhsSemesterMasuk) DESC, prodiNama, mhsNiu, mhsNomorTes LIMIT %s, %s";
      }else{
      
         $new_sql = "AND(
         mhsNiu  LIKE '%s'OR
         mhsNomorTes LIKE '%s') 
         ORDER BY CONCAT(mhsTahunAjaran, mhsSemesterMasuk) DESC, prodiNama, mhsNiu, mhsNomorTes LIMIT %s, %s";
         
      }      
      
      $sql = $this->mSqlQueries['get_data_mahasiswa']. $new_sql;
      
      if($nim_notest==""){
      
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       $programStudi,
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%'
                                       ,$offset,
                                       $limit));
      }else{
      
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       $programStudi,
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%',
                                       '%'.$nim_notest.'%',
                                       '%'.$nim_notest.'%',
                                       $offset,
                                       $limit));
      }
     //print($this->GetLastError());
      return $result;

   }
   
   function GetCountMahasiswaDataInduk($thnMasuk,$nim_notest,$isCalon,$programStudi,$nama,$semsMasuk){
      if($nim_notest!=""){
         $new_sql = "AND(
         mhsNiu  LIKE '%s' OR
         mhsNomorTes LIKE '%s') ";
         
      }      
      
      $sql = $this->mSqlQueries['get_count_mahasiswa_data_induk']. $new_sql;
          if($nim_notest==""){
      
      $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                    '%'.$isCalon.'%',
                                    '%'.$programStudi.'%',
                                    '%'.$nama.'%',
                                    '%'.$semsMasuk.'%'));
      }else{
      
      $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                    '%'.$isCalon.'%',
                                    '%'.$programStudi.'%',
                                    '%'.$nama.'%',
                                    '%'.$semsMasuk.'%',
                                    '%'.$nim_notest.'%',
                                    '%'.$nim_notest.'%'));
      }
#print($this->GetLastError());
      if(!$result){
         return 0;
      }else{
         return $result[0]['total'];
      } 
   }
   
   function GetMahasiswaDataInduk($thnMasuk,$nim_notest,$isCalon,$programStudi,$nama,$semsMasuk,$offset,$limit){
      if($nim_notest==""){
          $new_sql=" ORDER BY mhsNomorTes LIMIT %s, %s";
      }else{
         $new_sql = "AND(
         mhsNiu  LIKE '%s'OR
         mhsNomorTes LIKE '%s') 
         ORDER BY mhsNomorTes LIMIT %s, %s";
      }      
      
      $sql = $this->mSqlQueries['get_mahasiswa_data_induk']. $new_sql;
      
      if($nim_notest==""){
      
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       '%'.$programStudi.'%',
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%'
                                       ,$offset,
                                       $limit));
      }else{
      
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       '%'.$programStudi.'%',
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%',
                                       '%'.$nim_notest.'%',
                                       '%'.$nim_notest.'%',
                                       $offset,
                                       $limit));
      }
     #A print($this->GetLastError());
      return $result;
   }
   
   function GetPrintMahasiswaDataInduk($thnMasuk,$nim_notest,$isCalon,$programStudi,$nama,$semsMasuk){
      if($nim_notest==""){
          $new_sql=" ORDER BY mhsNomorTes ";
      }else{
         $new_sql = "AND(
         mhsNiu  LIKE '%s'OR
         mhsNomorTes LIKE '%s') 
         ORDER BY ";
      }      
      
      $sql = $this->mSqlQueries['get_mahasiswa_data_induk']. $new_sql;
      
      if($nim_notest==""){
      
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       '%'.$programStudi.'%',
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%'
));
      }else{
      
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       '%'.$programStudi.'%',
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%'
                        ));
      }
      return $result;
   }
   
   function GetTotalMahasiswa(){
      $result=$this->Open($this->mSqlQueries['get_total_mahasiswa'],array());
      
      if(!$result){
         return 0;
      }else{
         return $result[0]['jumlah_mhs'];
      } 
   }

   function GetDataDetailMahasiswa($idMhs){
      $result=$this->Open($this->mSqlQueries['get_detail_data_mahasiswa'],array($idMhs));
      return $result;
   }

   function GetDataPrintDetilDaftarMahasiswa($thnMasuk,$nim_notest,$isCalon,$programStudi,$nama,$semsMasuk){
   
      if($nim_notest==""){
          $new_sql="";
      }else{
         $new_sql = "AND(
         mhsNiu  LIKE '%s' OR
         mhsNomorTes LIKE '%s') ";
      }
      
      $sql = $this->mSqlQueries['get_data_print_detil_daftar_mahasiswa']. $new_sql;
      
      if($nim_notest==""){
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       '%'.$programStudi.'%',
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%'));
      }else{
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       '%'.$programStudi.'%',
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%',
                                       '%'.$nim_notest.'%',
                                       '%'.$nim_notest.'%'));
      } 
      
      return $result;
   }   
   
	function GetFoto($arrDara){
      $result=$this->Open($this->mSqlQueries['get_foto'],array($arrDara));
      //print($this->GetLastError());
      return $result; 
   }
   
   function GetDataPrintDaftarMahasiswa($thnMasuk,$nim_notest,$isCalon,$programStudi,$nama,$semsMasuk){
   
      if($nim_notest==""){
          $new_sql="";
      }else{
         $new_sql = "AND(
         mhsNiu  LIKE '%s' OR
         mhsNomorTes LIKE '%s') ";
      }
      
      $sql = $this->mSqlQueries['get_data_print_daftar_mahasiswa']. $new_sql;
      
      if($nim_notest==""){
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       '%'.$programStudi.'%',
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%'));
      }else{
         $result=$this->Open($sql,array('%'.$thnMasuk.'%',
                                       '%'.$isCalon.'%',
                                       '%'.$programStudi.'%',
                                       '%'.$nama.'%',
                                       '%'.$semsMasuk.'%',
                                       '%'.$nim_notest.'%',
                                       '%'.$nim_notest.'%'));
      } 
      return $result;
   }
   
   function GetStatusTaruna(){
      $dataStatus[0]['id']="1";
      $dataStatus[0]['name']="Calon Taruna";
      $dataStatus[1]['id']="0";
      $dataStatus[1]['name']="Taruna";      
      return $dataStatus;
   }
   
   function GetNimMhsById($id){
      $result=$this->Open($this->mSqlQueries['get_nim_by_id'],array($id));
      return $result;
   }
   
   function GetNimMhsByArrayId($arrIdMhs){
      $idMhs = implode("', '", $arrIdMhs);
      
      $result=$this->Open($this->mSqlQueries['get_nim_by_array_id'],array($idMhs));
      
      for($i=0;$i<sizeOf($result);$i++)
         $finalResult[$i]=$result[$i]['mhs_niu'];
      
      return $finalResult;
   }
   
   function GetSemesterMasuk(){
   
      $result=$this->Open($this->mSqlQueries['get_sems_masuk'],array($id));
      
      return $result;
   }
   
   function GetTahun($id) {
   
      $awalTahunAjaran = $id;
      $tahun = date("Y")+1;
      $tahunAjaran = $tahun;
      $cnt = 0;
      
      while ($tahunAjaran >= $awalTahunAjaran) {
         $result_array[$cnt][id] = $tahunAjaran;
         $result_array[$cnt][name] = $tahunAjaran.'/'.($tahunAjaran+1);
         $tahunAjaran--;
         $cnt++;
      }
      return $result_array;
   }
   
   function GetBiayaKuliah(){
      $data[0]['id']="1";
      $data[0]['name']="Sendiri";
      $data[1]['id']="2";
      $data[1]['name']="Orang Tua";
      $data[2]['id']="3";
      $data[2]['name']="Lainnya";
      return $data;
   }
   
   function GetStatusSmta(){
      $result=$this->Open($this->mSqlQueries['get_status_smta'],array());
      return $result;
   }   
   
   function GetGelombang(){
      $result=$this->Open($this->mSqlQueries['get_gelombang'],array());
      return $result;
   }
   
   function GetStatusAkreditasiSmta(){
      $result=$this->Open($this->mSqlQueries['get_status_akreditasi_smta'],array());
      return $result;
   }
   
   function GetTahunMasuk(){
      $result=$this->Open($this->mSqlQueries['get_tahun_masuk'],array());
      return $result;
   }
   
   function GetTahunPeriode(){
      $result=$this->Open($this->mSqlQueries['get_tahun_periode'],array());
      return $result;
   }
   
   function GetDataMahasiswaById($idMhs){       
      $result=$this->Open($this->mSqlQueries['get_data_mahasiswa_by_id'],array($idMhs));      
      
      return $result;
   }
   
//    function GetDataProdi(){
//       $result=$this->Open($this->mSqlQueries['get_data_prodi'],array());
//       return $result;
//    }

   function GetDataProdi(){
      $dataProdi[0]['id']="1";
      $dataProdi[0]['name']="NAUTIKA";
      $dataProdi[1]['id']="2";
      $dataProdi[1]['name']="TEKNIKA";
      $dataProdi[2]['id']="3";
      $dataProdi[2]['name']="KALK";
      return $dataProdi;
   }


   
//    function GetDataTahap(){
//       $dataTahap[0]['id']="1";
//       $dataTahap[0]['name']="Tahap 1";
//       $dataTahap[1]['id']="2";
//       $dataTahap[1]['name']="Tahap 2";
//       $dataTahap[2]['id']="3";
//       $dataTahap[2]['name']="Tahap 3";
//       return $dataTahap;
//    }
   
   function GetDataJalur(){
      $result=$this->Open($this->mSqlQueries['get_data_jalur'],array());
      return $result;
   }
   
   function GetDataNegara(){
      $result=$this->Open($this->mSqlQueries['get_data_negara'],array());
     
      return $result;
   }
   
   function GetDataKota(){
      $result=$this->Open($this->mSqlQueries['get_data_kota'],array());
      return $result;     
   }
   
   function GetStatusRumah(){
      $result=$this->Open($this->mSqlQueries['get_status_rumah'],array());
      return $result;        
   }
 
   function GetWargaNegara(){
      $result=$this->Open($this->mSqlQueries['get_warga_negara'],array());
      return $result;    
   }
   
   function GetAgama(){
      $result=$this->Open($this->mSqlQueries['get_agama'],array());
      return $result;   
   }
   
   function GetStatusNikah(){
      $result=$this->Open($this->mSqlQueries['get_status_nikah'],array());
      return $result; 
   }
   
   function GetSmta($namaProp,$namaKota,$namaSmta,$start,$limit){
      $result=$this->Open($this->mSqlQueries['get_smta'],array('%'.$namaProp.'%',
                                                               '%'.$namaKota.'%',
                                                               '%'.$namaSmta.'%',$start,$limit));
      //print_r($this->GetLastError());
      return $result;    
   }
   
   function GetCountSmta($namaProp,$namaKota,$namaSmta){
      $result=$this->Open($this->mSqlQueries['get_count_smta'],array('%'.$namaProp.'%',
                                                                  '%'.$namaKota.'%',
                                                                  '%'.$namaSmta.'%'));
     
     if(!$result){
         return 0;
      }else{
         return $result[0]['total'];
      } 
      return $result;
   }
   
   function GetSumberDana(){
      $result=$this->Open($this->mSqlQueries['get_sumber_dana'],array());
      return $result;    
   }
   
   function GetHubunganBiaya(){
      $result=$this->Open($this->mSqlQueries['get_hubungan_biaya'],array());
      return $result;
   }
   
   function GetJurusanSmta(){
      $result=$this->Open($this->mSqlQueries['get_jurusan_smta'],array());
      return $result;   
   }
   
   function GetJenisSmta(){
      $result=$this->Open($this->mSqlQueries['get_jenis_smta'],array());
      return $result;
      
   }
   
   function GetKelasMasukSmta(){
      for($i=0;$i<3;$i++){
         $result[$i]['id']=$i+1;
         $result[$i]['name']=$i+1;
      }
      return $result;
   }
   
   function GetPendidikan(){
      $result=$this->Open($this->mSqlQueries['get_pendidikan'],array());
      return $result;   
   }
   
   function GetPekerjaan(){
      $result=$this->Open($this->mSqlQueries['get_pekerjaan'],array());
      return $result;  
   }
   
   function GetPenghasilan(){
      $result=$this->Open($this->mSqlQueries['get_penghasilan'],array());
      return $result;  
   }
   
   function GetStatusAktif(){
      $result=$this->Open($this->mSqlQueries['get_status_aktif'],array());
      return $result; 
   }
   
   function GetPropinsiByKodeNegara($idNegara){
      $result=$this->Open($this->mSqlQueries['get_propinsi_by_id_neg'],array($idNegara));
      return $result; 
   }
   
   function GetPropinsi(){
      $result=$this->Open($this->mSqlQueries['get_propinsi'],array());
      return $result; 
   }
   
   function GetKotaByKodePropinsi($idProp){
      $result=$this->Open($this->mSqlQueries['get_kota'],array($idProp));
      return $result; 
   }
   
   function GetPropinsiByKodeKota($idKota){
      $result=$this->Open($this->mSqlQueries['get_propinsi_by_id'],array('%'.$idProp.'%'));
      return $result; 
   }
   
   function GetPropinsiNegaraByKodeKota($idKota){
      $result=$this->Open($this->mSqlQueries['get_prop_negara_by_kota_kode'],array($idKota));
      return $result; 
   }
   
   function GetPropinsiByKodeSmta($idSmta){
      $result=$this->Open($this->mSqlQueries['get_propinsi_by_smta_kode'],array($idSmta));
      return $result; 
   }
   
   function GetJumlahSdr($max){
      for($i=0;$i<$max;$i++){
         $data[$i]['id']=$i;
         $data[$i]['name']=$i;
      }   
      return $data;
   }
   
   function GetUserIdByUserName($username){
      $result=$this->Open($this->mSqlQueries['get_user_id_by_username'],array($username));
      return $result;
   }   
   
   function GetJenjangPendidikanDasar(){
      $result=$this->Open($this->mSqlQueries['get_jenjang_pendidikan_dasar'],array());
      //print($this->GetLastError());
      return $result;
   }
   
   function GetMhsId(){
      $result=$this->Open($this->mSqlQueries['get_id_mahasiswa'],array());
      //print($this->getLastEr);
      return $result;
   }  
   
   function GetPeriodeAktif(){
      $result=$this->Open($this->mSqlQueries['get_periode_aktif'],array());
      return $result[0]['nama'];
   }
   
   function GetTahunPeriodeAktif(){
      $result=$this->Open($this->mSqlQueries['get_tahun_periode_aktif'],array());
      return $result[0]['tahun'];
   }
   
   function GetPengalamanOrganisasiByIdMhs($idMhs){
      $result=$this->Open($this->mSqlQueries['get_pengalaman_organisasi_by_id'],array($idMhs));
      return $result;
   }      

   function GetIdPengalamanOrganisasi($tempat,$org,$idMhs){
      $result=$this->Open($this->mSqlQueries['get_id_pengalaman_organisasi'],array($tempat,$org,$idMhs));
     // print($this->GetLastError());
      return $result;
   }   
   
   function GetMaxIdPengalamanOrganisasi(){
      $result=$this->Open($this->mSqlQueries['get_max_id_organisasi'],array());
      //print($this->GetLastError());
      return $result;   
   }
   
   function GetRiwayatPendidikanByIdMhs($idMhs){
      $result=$this->Open($this->mSqlQueries['get_riwayat_pendidikan_by_mhs_id'],array($idMhs));
      return $result;
   }   
   
   function GetMaxIdRiwayatPendidikan(){
      $result=$this->Open($this->mSqlQueries['get_max_id_riwayat'],array());
      //print($this->GetLastError());
      return $result;
   }
   
   function GetSesiKuliah(){
		$result=$this->Open($this->mSqlQueries['get_sesi_kuliah'], array());
		//print($this->GetLastError());
		return $result;
   }
   
   function GetSesiKuliahSettingAktif(){
		$result=$this->Open($this->mSqlQueries['get_sesi_kuliah_setting_aktif'], array());
		
		return $result;
   }
   
   function GetStatusMasuk(){
		$result=$this->Open($this->mSqlQueries['get_status_masuk'], array());
		
		return $result;
   }
   
   function GetCurrentJumlahPesertaSesi($idSesi, $tahunAjaran, $prodiKode){
      $result=$this->Open($this->mSqlQueries['get_current_jumlah_peserta_sesi'], array($idSesi, $tahunAjaran, $prodiKode));
      
      return $result;
   }
   
   function GetTotalKuotaKelas($idSesi, $tahunAjaran, $prodiKode){
      $result=$this->Open($this->mSqlQueries['get_total_kuota_kelas'], array($idSesi, $tahunAjaran, $prodiKode));
      
      return $result;
   }

   function GetStatusKeluarga(){
      $result=$this->Open($this->mSqlQueries['get_status_keluarga'], array());		
		return $result;
   }
   
   function GetDataEditStatusKeluarga($mhsId){
      $result=$this->Open($this->mSqlQueries['get_dataedit_status_keluarga'], array($mhsId));		
      return $result;
   }
   
   function GetDataDetailStatusKeluarga($mhsId){
      $result=$this->Open($this->mSqlQueries['get_datadetail_status_keluarga'], array($mhsId));		
      return $result;
   }
   
   
//===============do==============
   function DoAddMahasiswa($arrData){      
      // default saat tambah data
      $arrData['mhs_status_aktif'] = 'N';
      $result = $this->Execute($this->mSqlQueries['do_add_mahasiswa'],array(                  
                  $arrData['mhs_nama'],
                  $arrData['mhs_jenis_kelamin'],
                  $arrData['mhs_kota_lahir'],
                  $arrData['mhs_tempat_lahir'],
                  $arrData['mhs_gol_darah'],
                  $arrData['mhs_prodi'],
                  $arrData['mhs_sesi_kuliah'],
                  $arrData['mhs_sems_masuk'],
                  $arrData['mhs_thn_masuk'],
                  $arrData['mhs_nama_angkatan'],
                  $arrData['mhs_no_tes'],
                  $arrData['mhs_jalur_masuk'],
                  $arrData['mhs_gel_daftar'],
                  $arrData['mhs_status_aktif'],
                  $arrData['mhs_is_calon'],
                  $arrData['mhs_status_masuk'],
                  $arrData['mhs_agama'],
                  $arrData['mhs_status_nikah'],
                  $arrData['mhs_warga_negara'],
                  $arrData['mhs_status_rumah'],
                  $arrData['mhs_kota_tinggal'],
                  $arrData['mhs_alamat'],
                  $arrData['mhs_kelurahan'],
                  $arrData['mhs_kecamatan'],
                  $arrData['mhs_kode_pos'],
                  $arrData['mhs_negara'],
                  $arrData['mhs_no_telp'],
                  $arrData['mhs_email'],
                  $arrData['mhs_syarat'],
                  $arrData['mhs_hubungan_biaya'],
                  $arrData['mhs_sumber_dana'],
                  $arrData['ipp_kwitansi'],
                  $arrData['mhs_beasiswa'],
                  $arrData['saudara_laki'],
                  $arrData['saudara_perempuan'],
                  $arrData['mhs_jumlah_sdr'],
                  $arrData['mhs_is_kerja'],
                  $arrData['mhs_jenis_kerja'],
                  $arrData['mhs_tempat_kerja'],
                  $arrData['mhs_alamat_kantor'],
                  $arrData['mhs_no_askes'],
                  $arrData['mhs_hobi'],
                  $arrData['mhs_smbr_info'],
                  $arrData['mhs_niu_lama'],
                  $arrData['nama_pt'],
                  $arrData['kode_pt'],
                  $arrData['kode_prodi'],
                  $arrData['nama_prodi'],
                  $arrData['tahun_pindah'],
                  $arrData['mhs_tahun_daftar_smta'],
                  $arrData['mhs_tahun_lulus_smta'],
                  $arrData['mhs_kelas_masuk_smta'],
                  $arrData['mhs_jurusan_smta'],
                  $arrData['mhs_jenis_smta'],
                  $arrData['mhs_smta'],
                  $arrData['smta_lain'],
                  $arrData['mhs_propinsi_smta'],
                  $arrData['mhs_alamat_smta'],
                  $arrData['mhs_no_ijazah_smta'],
                  $arrData['mhs_ijazah_smta'],
                  $arrData['mhs_status_smta'],
                  $arrData['mhs_akreditasi_smta'],
                  $arrData['mhs_nilai_uas_smta'],
                  $arrData['mhs_tgl_daftar'],
                  $arrData['mhs_tgl_lahir'],
                  $arrData['mhs_tgl_ijazah_smta'],
                  $arrData['mhs_user_pengubah'],
                  $arrData['mhs_tgl_bayar_ipp']
                  ));      
      return $result;
   }
   
   function DoUpdatePhotoMahasiswa($nama_file,$niu){
		$result = $this->Execute($this->mSqlQueries['update_foto_mhs'],array($nama_file,$niu));
		
		return $result;
   }
   
   function DoAddOrangTuaMahasiswa($arrData){
      for ($i=0;$i<sizeof($arrData);$i++){
         if($arrData[$i]==''){
            if($i==0){
               $arrData[$i]=0;
            }else{
            $arrData[$i]=NULL;
            }
         }
      }
      //print_r($arrData);
      $result = $this->Execute($this->mSqlQueries['do_add_ortu_mahasiswa'],($arrData));
      //print($this->GetLastError());
      return $result;
   }
   

   /*
   function DoUpdatePengalamanOrganisasi($tempat,$organisasi,$mhsId,$idPeng){
      $result = $this->Execute($this->mSqlQueries['do_update_pengalaman_organisasi'],array($tempat,$organisasi,$mhsId,$idPeng));
      print($this->GetLastError());
      return $result;
   }*/
   
   function DoImportMahasiswa($arrData){
      for($i=0;$i<sizeof($arrData);$i++){
         if($arrData[$i]==''){
            $arrData[$i]=NULL;
         }
      }
      
      //cek jika ada nim maka set adalah mahasiswa bukan calon mahasiswa lagi
      if($arrData[0] != ''){
         $arrData[] = '0';
      }else{
         $arrData[] = '1';
      }
      
      $result = $this->Execute($this->mSqlQueries['do_import_mahasiswa'],($arrData));
     //print($this->GetLastError());
      return $result;
   }   
   
   function DoImportOrtu($arrData){
      $dataOrtu=array_values($arrData);
      
      if($dataOrtu[33]===NULL){
         $dataOrtu[33]=0;
      }        
    
      if(($dataOrtu[31]===0)or($dataOrtu[31]===null)){
         $dataOrtu[31]=null;
      }
      
      for ($i=2;$i<=7;$i++) {
         if ($dataOrtu[$i] == '') {
            $dataOrtu[$i] = NULL;
         }
      }

      $result = $this->Execute($this->mSqlQueries['do_import_ortu'],($dataOrtu));
     //print($this->GetLastError());exit;
      return $result;
   }
   
   function DoUpdateMahasiswa($arrData){
      //filter data yang null
      $tempArrData = $arrData;
      foreach($arrData as $key => $value){
         if($value == ''){
            $tempArrData[$key] = NULL;
         }
      }
      $arrData = $tempArrData;            
         
      $result = $this->Execute($this->mSqlQueries['do_update_mahasiswa'],array(
                  $arrData['mhs_nama'],
                  $arrData['mhs_jenis_kelamin'],
                  $arrData['mhs_kota_lahir'],
                  $arrData['mhs_tempat_lahir'],
                  $arrData['mhs_gol_darah'],
                  $arrData['mhs_prodi'],
                  $arrData['mhs_sesi_kuliah'],
                  $arrData['mhs_sems_masuk'],
                  $arrData['mhs_thn_masuk'],
                  $arrData['mhs_nama_angkatan'],
                  $arrData['mhs_no_tes'],
                  $arrData['mhs_jalur_masuk'],
                  $arrData['mhs_gel_daftar'],
                  $arrData['mhs_status_aktif'],
                  $arrData['mhs_is_calon'],
                  $arrData['mhs_status_masuk'],
                  $arrData['mhs_agama'],
                  $arrData['mhs_status_nikah'],
                  $arrData['mhs_warga_negara'],
                  $arrData['mhs_status_rumah'],
                  $arrData['mhs_kota_tinggal'],
                  $arrData['mhs_alamat'],
                  $arrData['mhs_kelurahan'],
                  $arrData['mhs_kecamatan'],
                  $arrData['mhs_kode_pos'],
                  $arrData['mhs_negara'],
                  $arrData['mhs_no_telp'],
                  $arrData['mhs_email'],
                  $arrData['mhs_syarat'],
                  $arrData['mhs_hubungan_biaya'],
                  $arrData['mhs_sumber_dana'],
                  $arrData['ipp_kwitansi'],
                  $arrData['mhs_beasiswa'],
                  $arrData['saudara_laki'],
                  $arrData['saudara_perempuan'],
                  $arrData['mhs_jumlah_sdr'],
                  $arrData['mhs_is_kerja'],
                  $arrData['mhs_jenis_kerja'],
                  $arrData['mhs_tempat_kerja'],
                  $arrData['mhs_alamat_kantor'],
                  $arrData['mhs_no_askes'],
                  $arrData['mhs_hobi'],
                  $arrData['mhs_smbr_info'],
                  $arrData['mhs_niu_lama'],
                  $arrData['nama_pt'],
                  $arrData['kode_pt'],
                  $arrData['kode_prodi'],
                  $arrData['nama_prodi'],
                  $arrData['tahun_pindah'],
                  $arrData['mhs_tahun_daftar_smta'],
                  $arrData['mhs_tahun_lulus_smta'],
                  $arrData['mhs_kelas_masuk_smta'],
                  $arrData['mhs_jurusan_smta'],
                  $arrData['mhs_jenis_smta'],
                  $arrData['mhs_smta'],
                  $arrData['smta_lain'],
                  $arrData['mhs_propinsi_smta'],
                  $arrData['mhs_alamat_smta'],
                  $arrData['mhs_no_ijazah_smta'],
                  $arrData['mhs_ijazah_smta'],
                  $arrData['mhs_status_smta'],
                  $arrData['mhs_akreditasi_smta'],
                  $arrData['mhs_nilai_uas_smta'],
                  $arrData['mhs_tgl_daftar'],
                  $arrData['mhs_tgl_lahir'],
                  $arrData['mhs_tgl_ijazah_smta'],
                  $arrData['mhs_user_pengubah'],                  
                  $arrData['decId'],                  
                  ));      
      //print($this->GetLastError());
      return $result;   
   }
   
   function DoUpdateOrangTuaMahasiswa($arrData){
   
      for ($i=0;$i<sizeof($arrData);$i++){
         if($arrData[$i]==''){
            if($i==19){
               $arrData[$i]=0;
            }else{
            $arrData[$i]=NULL;
            }
         }
      }   
       
      $result = $this->Execute($this->mSqlQueries['do_update_ortu_mahasiswa'],($arrData));
    //  print($this->GetLastError());
      return $result; 
   }
   
   function DoDeleteMahasiswaById($idMhs){
      $result=$this->Execute($this->mSqlQueries['do_delete_mahasiswa_by_id'],array($idMhs));
      //print($this->GetLastError());exit;
      return $result;
   }
   
   function DoDeleteOrangTuaMahasiswaById($idMhs){
      $result=$this->Execute($this->mSqlQueries['do_delete_ortu_mahasiswa_by_id'],array($idMhs));
      return $result;
   }
   
   function DoDeleteMahasiswaByArrayId($arrIdMhs){
      $idMhs = implode("', '", $arrIdMhs);
      $result=$this->Execute($this->mSqlQueries['do_delete_mahasiswa_by_array_id'],array($idMhs));

      return $result;
   }
   
   function DoDeleteOrangTuaMahasiswaByArrayId($arrIdMhs){
      $idMhs = implode("', '", $arrIdMhs);
      $result=$this->Execute($this->mSqlQueries['do_delete_ortu_mahasiswa_by__array_id'],array($idMhs));

      return $result;  
   }   
   
   function DoAddPengalamanOrganisasi($id,$tempat,$organisasi,$mhsId){
      $result = $this->Execute($this->mSqlQueries['do_add_pengalaman_organisasi'],array($id,$tempat,$organisasi,$mhsId));
      //print($this->GetLastError());
      return $result;
   }  
   
   function DoDeletePengalamanOrganisasiByMhsId($IdMhs){
      $result=$this->Execute($this->mSqlQueries['do_delete_pengalaman_organisasi_by_mhsId'],array($IdMhs));
  //    print($this->GetLastError());
      return $result;  
   }      
   
   function DoDeleteRiwayatPendidikanByMhsId($IdMhs){
      $result=$this->Execute($this->mSqlQueries['do_delete_riwayat_pendidikan_by_mhsId'],array($IdMhs));
  // print($this->GetLastError());
      return $result;  
   }   
   
   function DoAddRiwayatPendidikan($riwId,$jenjang,$pendNama,$tahunLulus,$IdMhs){
      $result=$this->Execute($this->mSqlQueries['do_add_riwayat_pendidikan'],array($riwId,$jenjang,$pendNama,$tahunLulus,$IdMhs));
      //print($this->GetLastError());
      return $result;  
   }

   function DoAddStatusKeluarga($mhsId,$stsKlrgaId){      
      $result=$this->Execute($this->mSqlQueries['do_add_status_keluarga'],array($mhsId,$stsKlrgaId));
      //print($this->GetLastError());
      return $result;  
   }
   
   function DoDeleteStatusKeluarga($mhsId){
      $result=$this->Execute($this->mSqlQueries['do_delete_status_keluarga'],array($mhsId));
      return $result;
   }

//===cek==
   function CheckMhsIsExist($noTes,$prodiKode){
      $result=$this->Open($this->mSqlQueries['check_mhs_is_exist'],array($noTes,$prodiKode));
      if($result[0]['total']>0){
         return true;
      }else{
         return false;
      }  
   }
   
   function CekStatusMhs($idMhs){
      $result=$this->Open($this->mSqlQueries['get_status_mhs_by_id'],array($idMhs));
      return $result;
   }
   
   function CekStatusMhsByArray($arrIdMhs){
      $idMhs = implode("', '", $arrIdMhs);
      $result=$this->Open($this->mSqlQueries['get_status_mhs_by_array_id'],array($idMhs));
      return $result;
   }
   /*
   function GetTableObject(){
      $result=$this->Open($this->mSqlQueries['get_table_object'],array());
      //print($this->GetLastError());
      return $result;
   }*/
   
   function GetFieldLengthTableMhs(){
      $length[0]=20; 
      $length[1]=100;
      $length[2]=255; 
      $length[3]=6; 
      $length[4]=11;
      $length[5]=4;  
      $length[6]=11; 
      $length[7]=20;
      $length[8]=255; 
      $length[9]=20; 
      $length[10]=50;
      $length[11]=10;
      $length[12]=6; 
      $length[13]=1; 
      $length[14]=6;
      $length[15]=20;
      $length[16]=255;
      $length[17]=5;
      $length[18]=6;
      $length[19]=20; 
      $length[20]=50; 
      $length[21]=255; 
      $length[22]=20; 
      $length[23]=255;
      $length[24]=255; 
      $length[25]=5; 
      $length[26]=6; 
      $length[27]=5; 
      $length[28]=11; 
      $length[29]=11;
      $length[30]=10;
      $length[31]=50; 
      $length[32]=6; 
      $length[33]=1; 
      $length[34]=255; 
      $length[35]=20; 
      $length[36]=10; 
      $length[37]=7; 
      $length[38]=5;
      $length[39]=3; 
      $length[40]=4;
      $length[41]=6;         
      $length[42]=255;
      
      return $length;
   }
   
   function GetFieldLengthTableOrtuMhs(){
      $length[0]=255; 
      $length[1]=255;
      $length[2]=6; 
      $length[3]=6; 
      $length[4]=6;
      $length[5]=6;  
      $length[6]=6; 
      $length[7]=6;
      $length[8]=20; 
      $length[9]=5; 
      $length[10]=100;
      $length[11]=100;
      $length[12]=255; 
      $length[13]=10; 
      $length[14]=10;
      $length[15]=1;
      $length[16]=10;
      $length[17]=1;
      $length[18]=10;
      $length[19]=255; 
      $length[20]=6; 
      $length[21]=6; 
      $length[22]=6; 
      $length[23]=20;
      $length[24]=100; 
      $length[25]=5; 
      $length[26]=100; 
      $length[27]=255; 
      $length[28]=10; 
      $length[29]=1;
      $length[30]=10;
      $length[31]=6; 
      $length[32]=1; 
      $length[33]=3; 
      $length[34]=10; 
    }
       
   #tambahan Untuk integrasi Dengan Um
   function DoImportMahasiswaFromUm($arrData){
     $result=$this->Execute($this->mSqlQueries['do_import_mhs_from_um'],$arrData);
     #
      return $result;
   }
   
   function DoImportMahasiswaOrtuFromUm($arrData){
      $result=$this->Execute($this->mSqlQueries['do_import_mhs_ortu_form_um'],$arrData);
      #
      return $result;
   }
   
    
	

 	/*Tambahan Input Nilai SMTA Mahasiswa
    * Proyek : PRODUK
    * Oleh : Edward Saputra
    */
    function GetPeriodeSmta(){
      $result=$this->Open($this->mSqlQueries['get_periode_smta'],array());
      return $result;
    }
    
    function GetCountMataPelajaran(){
      $result=$this->Open($this->mSqlQueries['get_count_mata_pelajaran'],array());
      if(!$result){
         return 0;
      }else{
         return $result[0]['total'];
      } 
    }
    
    function GetMataPelajaranSmta(){
      $result=$this->Open($this->mSqlQueries['get_mata_pelajaran'],array());
      return $result; 
    }
    function GetNilaiMataPelajaranSmta($MatPelId,$MhsId){//print($this->GetLastError());
      $result=$this->Open($this->mSqlQueries['get_nilai_mata_pelajaran'],array($MhsId,$MatPelId));
      return $result;
    }
    
    function GetInfoMahasiswa($mhsId){
      $result=$this->Open($this->mSqlQueries['get_info_mahasiswa'],array($mhsId));
      return $result;
    }
    
    function GetDataForComboNilai(){
      $nilai=50;
      for($i=0;$i<=50;$i++){
         $data[$i]['ID']=$nilai;
         $data[$i]['NAME']=$nilai;
         $nilai++;
      }
      return $data;
    }
    
    function GetGolDarah(){
       $result = $this->Open($this->mSqlQueries['get_gol_darah'],array());
       return $result;
    }
    
   function GetSumberInfo(){
      $result = $this->Open($this->mSqlQueries['get_sumber_info'],array());
      return $result;
   } 
    
    function DoAddNilaiSmta($matPelId,$periodeSmtaId,$nilai,$mhsId){
      $result=$this->Execute($this->mSqlQueries['do_add_nilai_smta'],
         array($matPelId,$periodeSmtaId,$nilai,$mhsId,$matPelId,$periodeSmtaId,$nilai,$mhsId));
		 #print($this->GetLastError());exit;
      return $result;
    }

}
?>
