public function get_elem_skripsi($univ = null, $jurusan = null, $tahun = null, $user = null)
 {
     $sql = "SELECT \r\n            a.KD_D_ELEM_BEASISWA AS KD_D_ELEM_BEASISWA,\r\n            a.KD_R_ELEM_BEASISWA AS KD_R_ELEM_BEASISWA,\r\n            a.TAHUN_MASUK AS TAHUN_MASUK,\r\n            b.NM_JUR as NM_JUR,\r\n            c.KD_FAKUL AS KD_FAKUL,\r\n            d.NM_UNIV as NM_UNIV,\r\n            a.NO_SP2D_D_ELEM_BEASISWA as NO_SP2D_D_ELEM_BEASISWA,\r\n            a.TGL_SP2D_D_ELEM_BEASISWA as TGL_SP2D_D_ELEM_BEASISWA,\r\n            a.JML_PEG_D_ELEM_BEASISWA as JML_PEG_D_ELEM_BEASISWA,\r\n            a.BLN_D_ELEM_BEASISWA as BLN_D_ELEM_BEASISWA,\r\n            a.THN_D_ELEM_BEASISWA as THN_D_ELEM_BEASISWA,\r\n            a.TOTAL_BAYAR_D_ELEM_BEASISWA as TOTAL_BAYAR_D_ELEM_BEASISWA\r\n            FROM " . $this->_table . " a\r\n                LEFT JOIN r_jur b ON a.KD_JUR = b.KD_JUR\r\n                LEFT JOIN r_fakul c ON b.KD_FAKUL = c.KD_FAKUL\r\n                LEFT JOIN r_univ d ON c.KD_UNIV = d.KD_UNIV\r\n                WHERE KD_R_ELEM_BEASISWA='" . $this->_skripsi . "'";
     if ($user != "") {
         $sql .= " AND d.KD_USER ='******'";
     }
     if ($univ != "") {
         $sql .= " AND d.KD_UNIV ='" . $univ . "'";
     }
     if ($jurusan != "") {
         $sql .= " AND b.KD_JUR ='" . $jurusan . "'";
     }
     if ($tahun != "") {
         $sql .= " AND a.TAHUN_MASUK ='" . $tahun . "'";
     }
     $sql .= " order by a.KD_D_ELEM_BEASISWA desc";
     $result = $this->db->select($sql);
     $data = array();
     foreach ($result as $key => $value) {
         $elem = new ElemenBeasiswa();
         $elem->set_kd_d($value['KD_D_ELEM_BEASISWA']);
         $elem->set_no_sp2d($value['NO_SP2D_D_ELEM_BEASISWA']);
         $elem->set_tgl_sp2d(date('d-m-Y', strtotime($value['TGL_SP2D_D_ELEM_BEASISWA'])));
         $elem->set_univ($value['NM_UNIV']);
         $elem->set_thn_masuk($value['TAHUN_MASUK']);
         $elem->set_kd_jur($value['NM_JUR']);
         $elem->set_jml_peg($value['JML_PEG_D_ELEM_BEASISWA']);
         $elem->set_bln($value['BLN_D_ELEM_BEASISWA']);
         $elem->set_biaya_per_peg($v['BIAYA_PER_PEG_D_ELEM_BEASISWA']);
         $elem->set_thn($value['THN_D_ELEM_BEASISWA']);
         $elem->set_total_bayar($value['TOTAL_BAYAR_D_ELEM_BEASISWA']);
         $data[] = $elem;
     }
     //var_dump($data);
     return $data;
 }
 public function updateUangSkripsi()
 {
     if (isset($_POST['ubah_uskripsi'])) {
         if (isset($_POST['js']) && $_POST['js'] == 1) {
             header('location:' . URL . 'elemenBeasiswa/viewSkripsi');
         }
         if ($_POST['kd_el'] && $_POST['setuju'] != "" && $_POST['r_elem'] != "" && $_POST['kode_jur'] != "" && $_POST['tahun_masuk'] != "" && $_POST['biaya_skripsi'] != "" && $_POST['total_bayar'] != "") {
             $elem = new ElemenBeasiswa();
             $pb = $_POST['setuju'];
             $jml_peg = count($pb);
             $elem->set_kd_d($_POST['kd_el']);
             $elem->set_jml_peg($jml_peg);
             $elem->set_kd_r($_POST['r_elem']);
             $elem->set_kd_jur($_POST['kode_jur']);
             $elem->set_thn_masuk($_POST['tahun_masuk']);
             $elem->set_biaya_per_peg(str_replace(',', '', $_POST['biaya_skripsi']));
             $elem->set_total_bayar(str_replace(',', '', $_POST['total_bayar']));
             $elem->set_no_sp2d($_POST['no_sp2d']);
             $elem->set_tgl_sp2d(date('Y-m-d', strtotime($_POST['tgl_sp2d'])));
             //var_dump($elem);
             //echo $kd_elemen_beasiswa;
             //exit();
             //var_dump($elem);
             $upload = new Upload();
             $upload->init('fupload');
             if ($upload->getFileName() != "") {
                 $upload->setDirTo("files/sp2d/");
                 $nama = array($elem->get_no_sp2d(), $elem->get_tgl_sp2d());
                 //$upload->uploadFile2("", $nama);
                 if ($upload->uploadFile2("", $nama) == false) {
                     $url = URL . 'elemenBeasiswa/editJadup/' . $elem->get_kd_d();
                     echo '<script> alert("File gagal diupload.") </script>';
                     echo '<script language="JavaScript"> window.location.href ="' . $url . '" </script>';
                     exit;
                 }
                 $elem->set_file_sp2d($upload->getFileTo());
                 //echo $upload->getFileName();
                 if ($_POST['fupload_lama'] != "") {
                     $file = "files/sp2d/" . $_POST['fupload_lama'];
                     //echo $file;
                     if (file_exists($file)) {
                         unlink($file);
                     }
                 }
                 //echo $upload->getFileName();
             } else {
                 if ($_POST['fupload_lama'] != "") {
                     $elem->set_file_sp2d($_POST['fupload_lama']);
                     //echo $_POST['fupload_lama'];
                 } else {
                     $elem->set_file_sp2d("");
                 }
             }
             $elem->update_elem($elem);
             $penerima = new PenerimaElemenBeasiswa();
             $penerima->delete($elem->get_kd_d());
             foreach ($pb as $val) {
                 $penerima_elemen = new PenerimaElemenBeasiswa();
                 $penerima_elemen->kd_elemen_beasiswa = $elem->get_kd_d();
                 $penerima_elemen->kd_pb = $val;
                 $penerima_elemen->add($penerima_elemen);
             }
             ClassLog::write_log("elemen beasiswa", "ubah uang penelitian", "kd_el." . $elem->get_kd_d());
             //$url = URL . 'elemenBeasiswa/editSkripsi/' . $elem->get_kd_d();
             $url = URL . 'elemenBeasiswa/viewSkripsi';
             echo '<script> alert("Data berhasil disimpan") </script>';
             echo '<script language="JavaScript"> window.location.href ="' . $url . '" </script>';
         } else {
             header('location:' . URL . 'elemenBeasiswa/editSkripsi/' . $elem->get_kd_d());
         }
     } else {
         header('location:' . URL . 'elemenBeasiswa/viewSkripsi');
     }
 }
 public function cetak_profil($id)
 {
     $pb = new Penerima($this->registry);
     //mendapatkan informasi pb
     $st = new SuratTugas($this->registry);
     //mendapatkan informasi surat tugas
     $el = new ElemenBeasiswa($this->registry);
     //mendapatkan pembayaran
     $bank = new Bank($this->registry);
     //mendapatkan nama bank
     $jst = new JenisSuratTugas($this->registry);
     //mendapatkan jenis surat tugas
     $jur = new Jurusan($this->registry);
     $univ = new Universitas($this->registry);
     $nilai = new Nilai($this->registry);
     $cuti = new Cuti($this->registry);
     $mas = new MasalahPenerima($this->registry);
     $pemb = new PemberiBeasiswa();
     $beaya = new Biaya();
     $role = Session::get('role');
     $pb->set_kd_pb($id);
     $this->view->d_pb = $pb->get_penerima_by_id($pb, $this->kd_user);
     if ($role == 3) {
         $this->view->d_pb = $pb->get_penerima_by_id($pb);
     }
     $st->set_kd_st($this->view->d_pb->get_st());
     $this->view->d_st = $st->get_surat_tugas_by_id($st, $this->kd_user);
     if ($role == 3) {
         $this->view->d_st = $st->get_surat_tugas_by_id($st);
     }
     $pemb = $pemb->get_by_id($this->view->d_st->get_pemberi());
     $this->view->d_pemb = $pemb->nama_pemberi;
     $this->view->d_bank = $bank->get_bank_id($this->view->d_pb->get_bank());
     $jur->set_kode_jur($this->view->d_pb->get_jur());
     $this->view->d_jur = $jur->get_jur_by_id($jur);
     $jst->set_kode($this->view->d_st->get_jenis_st());
     $this->view->d_jst = $jst->get_jst_by_id($jst);
     $this->view->d_univ = $univ->get_univ_by_jur($this->view->d_jur->get_kode_jur());
     $this->view->d_nil = $nilai->get_nilai($pb);
     $this->view->d_cur_ipk = $nilai->get_current_ipk($pb);
     $this->view->d_cuti = $cuti->get_cuti($this->kd_user, $pb);
     if ($role == 3) {
         $this->view->d_cuti = $cuti->get_cuti(0, $pb);
     }
     $this->view->d_rwt_beas = $pb->get_penerima_by_column($pb, $this->kd_user, 'nip', true);
     if ($role == 3) {
         $this->view->d_rwt_beas = $pb->get_penerima_by_column($pb, 0, 'nip', true);
     }
     $elem = $el->get_elem_per_pb($pb, false);
     $bea = $beaya->get_cost_per_pb($pb, false);
     $this->view->d_mas = $mas->get_masalah($pb);
     $d_bea = array();
     /*
      * sementara versi dummy dulu ye :p
      */
     foreach ($elem as $v) {
         $d = new BiayaPenerimaBeasiswa();
         $is_jadup = $v->get_kd_r() == 'tunjangan hidup';
         $is_buku = $v->get_kd_r() == 'buku';
         $nama = $v->get_kd_r();
         if ($is_jadup) {
             $nama .= " " . $v->get_bln() . " " . $v->get_thn();
         }
         if ($is_buku) {
             $bulan = Tanggal::bulan_num($v->get_bln());
             $bulan = $bulan == 1 ? 'ganjil' : 'genap';
             $nama .= " semester " . $bulan . " " . $v->get_thn();
         }
         $d->set_nama_biaya($nama);
         $d->set_jumlah_biaya($v->get_total_bayar());
         $d_bea[] = $d;
     }
     foreach ($bea as $v) {
         $d = new BiayaPenerimaBeasiswa();
         $d->set_nama_biaya($v->nama_tagihan);
         $d->set_jumlah_biaya($v->biaya_per_pegawai);
         $d_bea[] = $d;
     }
     $this->view->d_bea = $d_bea;
     $this->view->load('profil/cetak_profil');
 }