ceklog();
$this->load->library('pdf_transkrip');
$this->load->library('rhrpt');
$this->load->library('rhlib');
}
function ceklog() {
$user = $this->session->userdata("user_id1unla");
if($user==""){
redirect('user/login');
}
}
function get_bilangan($num){
return $this->rhlib->get_bilangan($num);
}
function get_par_val($table,$fieldName,$condition){
return $this->rhlib->get_par_val($table,$fieldName,$condition);
}
function get_row_pars($table,$fields,$condition){
return $this->rhlib->get_row_pars($table,$fields,$condition);
}
function squery($query){
$KEDUA= $this->load->database('second', TRUE);
$query = $KEDUA->query($query);
$row= '';
if ($query->num_rows() != 0)
{
$row = $query->row();
}
return $row;
}
function nm_field2($column,$tbl,$whereb, $wherea){
$KEDUA= $this->load->database('second', TRUE);
$q = "SELECT ".$column." as nm FROM ".$tbl." where ".$whereb." = '".$wherea."' " ;
$query = $KEDUA->query($q);
$nm= '';
if ($query->num_rows() != 0)
{
$row = $query->row();
$nm=$row->nm;
}
return $nm;
}
function TanggalIndo($date){
$BulanIndo = array("Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember");
$tahun = substr($date, 0, 4);
$bulan = substr($date, 4, 2);
$tgl = substr($date, 6, 2);
$result =$tgl . " " . $BulanIndo[(int)$bulan-1] . " ". $tahun;
return($result);
}
function set_hari($tanggal){
$namahari = date('l', strtotime($tanggal));
if ($namahari == "Sunday") $namahari = "Minggu";
else if ($namahari == "Monday") $namahari = "Senin";
else if ($namahari == "Tuesday") $namahari = "Selasa";
else if ($namahari == "Wednesday") $namahari = "Rabu";
else if ($namahari == "Thursday") $namahari = "Kamis";
else if ($namahari == "Friday") $namahari = "Jumat";
else if ($namahari == "Saturday") $namahari = "Sabtu";
else $namahari = '';
return $namahari;
}
function getmahasiswa($wherex=''){
$KEDUA= $this->load->database('second', TRUE);
$KEDUA->select("*");
$KEDUA->from("vv_mahasiswa_profile2");
if($wherex !=''){
$KEDUA->where('nim',$wherex);
}
$q = $KEDUA->get();
$result = array();
if ($q->num_rows() > 0) {
$result = $q->result();
}
return $result;
}
function gridsyaratmk($nim,$idkurikulum,$thnmasuk){ ////untuk mengambil syarat matakuliah
$KEDUA= $this->load->database('second', TRUE);
$q = $KEDUA->query("SELECT v_syaratmk.kdmk
, v_syaratmk.nmmkind
, v_syaratmk.idsemester
, v_syaratmk.jmlsks
, v_syaratmk.nmlvlsyaratmk
, v_syaratmk.nilaihurufmin
, v_syaratmk.bobotnilaimin
, (SELECT accnilaihuruf
FROM
nilai
WHERE
kdmk = v_syaratmk.kdmk
AND nim = '$nim') AS nilaihurufmhs
, (SELECT accbobotnilai
FROM
nilai
WHERE
kdmk = v_syaratmk.kdmk
AND nim = '$nim') AS bobotnilaimhs
, (if((SELECT accbobotnilai
FROM
nilai
WHERE
kdmk = v_syaratmk.kdmk
AND nim = '$nim') > v_syaratmk.bobotnilaimin, 'Lulus Syarat', 'Tidak Lulus Syarat')) AS keterangan
FROM
v_syaratmk
WHERE
idkurikulum = '$idkurikulum' AND thnmasuk= '$thnmasuk'");
$makul='';
$a=1;
$data = array();
if ($q->num_rows() > 0) {
$data = $q->result();
}
foreach($data as $row) {
$makul .=$a.". ".($row->nmmkind)
." - Nilai (".(($row->nilaihurufmhs) ? $row->nilaihurufmhs:'-')." > ".(($row->nilaihurufmin) ? $row->nilaihurufmin:'-').") ".
($row->keterangan)."
";
$a= $a + 1;
}
return $makul;
}
function get_data_krs($nim,$kdprodi,$tahunmsk,$kdstsemester,$idkelas,$idsemester){
$KEDUA= $this->load->database('second', TRUE);
$querycek = $KEDUA->query("SELECT idsiskrs,kdsiskrs,nmsiskrs,idsemester FROM v_setkrs
WHERE kdprodi='".$kdprodi."'
AND idsemester IN (SELECT stmhssemester.idsemester FROM stmhssemester WHERE stmhssemester.nim='".$nim."' AND stmhssemester.kdstsemester='".$kdstsemester."')");
$idsiskrs = '';
$idsemesterx = '';
if ($querycek->num_rows() > 0) {
$rowcek = $querycek->row();
$idsiskrs = $rowcek->idsiskrs;
$idsemesterx = $rowcek->idsemester;
}
$query = $KEDUA->query("CALL sp_getKrsMatkul_cetak (?,?,?,?,?,?,?)",array($nim,$kdprodi,$kdstsemester,$tahunmsk,$idkelas,$idsemesterx,$idsiskrs));
$result = array();
if ($query->num_rows() > 0) {
$result = $query->result();
}
return $result;
}
function get_rows_krs($nim,$kdprodi,$tahunmsk,$kdstsemester,$idkelas,$idsemester,$isblanko){
// data table
$data = $this->get_data_krs($nim,$kdprodi,$tahunmsk,$kdstsemester,$idkelas,$idsemester);
$rows = "";
$no = 0;
$jmlsksambil = 0;
$jmlskssetuju = 0;
$no = 0;
$validkrs = (substr($kdstsemester,-1)==1) ? $this->nm_field2('nilai','setting','idset', 42):$this->nm_field2('nilai','setting','idset', 43);
foreach($data as $row)
{
// cek konversi
if($row->is_konversi == null){
if ($validkrs == 1) {
$syaratmk = ($this->gridsyaratmk($nim,$row->idkurikulum,$row->thnmasuk)) ? $this->gridsyaratmk($nim,$row->idkurikulum,$row->thnmasuk):'-';
} else {
$syaratmk = '-';
}
$ambil = ($row->ambilval) ? 'Ya':'Tidak';
$ambil = ($isblanko=='1') ? "":$ambil;
$namakelas = ($isblanko=='1') ? "":$row->namakelas;
$namaambil = ($isblanko=='1') ? "":$row->namaambil;
$namasetuju = ($isblanko=='1') ? "":$row->namasetuju;
if ($row->ambilval) { $jmlsksambil += $row->jmlsks; }
if ($row->idstkrs=='1') { $jmlskssetuju += $row->jmlsks; }
if ($isblanko=='1') {
$no++;
$rows .= "
".$no." |
".$row->kdmk." |
".$row->nmmkind." |
".$row->idsemester." |
".$row->jmlsks." |
".$syaratmk." |
".$ambil." |
".$namakelas." |
".$namaambil." |
".$namasetuju." |
";
} else {
if ($namaambil) {
$no++;
$rows .= "
".$no." |
".$row->kdmk." |
".$row->nmmkind." |
".$row->idsemester." |
".$row->jmlsks." |
".$syaratmk." |
".$ambil." |
".$namakelas." |
".$namaambil." |
".$namasetuju." |
";
}
}
}
}
$items['rows'] = $rows;
$items['jmlsksambil'] = $jmlsksambil;
$items['jmlskssetuju'] = $jmlskssetuju;
return $items;
}
function get_ip_before($nim,$idsemester){
$KEDUA= $this->load->database('second', TRUE);
$where = ($idsemester == '1') ? " AND idsemester = 1 ":" AND idsemester = $idsemester - 1 ";
$query = $KEDUA->query("SELECT sum(if((mutu IS NULL), 0, mutu)) / sum(jmlsks) AS ipk
FROM
v_nilai
WHERE
nim = $nim
AND nilaihuruf <> ''
$where
GROUP BY
nim");
$ipk = 0;
if ($query->row() > 0) {
$row = $query->row();
$ipk=$row->ipk;
}
return round($ipk,2);
}
function get_max_sks($ipbefore){
$KEDUA= $this->load->database('second', TRUE);
$query = $KEDUA->query("SELECT sksmax AS maxsks
FROM
bebanstudi
WHERE
$ipbefore
BETWEEN ipmin AND ipmax");
$maxsks = 0;
if ($query->row() > 0) {
$row = $query->row();
$maxsks=$row->maxsks;
}
return $maxsks;
}
function get_waktu_krs($nim,$kdstsemester){
$KEDUA= $this->load->database('second', TRUE);
$query = $KEDUA->query("SELECT tglkrs, jamkrs
FROM
krs
WHERE
nim = $nim
AND
kdstsemester = $kdstsemester
");
if ($query->row() > 0) {
$row = $query->row();
$tgl_krs = $this->TanggalIndo(date("Ymd", strtotime($row->tglkrs)));
$waktukrs = $tgl_krs." ".$row->jamkrs;
}
return $waktukrs;
}
function get_cetak_krs($nim,$kdprodi,$tahunmsk,$kdstsemester,$idkelas,$idsemester,$niduwali,$isblanko,$before=1,$between=5) {
$this->pdf_transkrip->SetCreator(PDF_CREATOR);
$this->pdf_transkrip->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH,PDF_HEADER_TITLE,PDF_HEADER_STRING);
$this->pdf_transkrip->setPrintHeader(true);
$this->pdf_transkrip->setPrintFooter(false);
// set header and footer fonts
$this->pdf_transkrip->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', 10));
$this->pdf_transkrip->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$this->pdf_transkrip->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$this->pdf_transkrip->SetMargins('7', '40', '20');
$this->pdf_transkrip->SetHeaderMargin('20');
$this->pdf_transkrip->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$this->pdf_transkrip->SetAutoPageBreak(TRUE, '25');
// set image scale factor
$this->pdf_transkrip->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
// ---------------------------------------------------------
// set font
$this->pdf_transkrip->SetFont('helvetica', 'B', 10);
$this->pdf_transkrip->SetCellPadding(0);
// add a page
$this->pdf_transkrip->AddPage();
$this->pdf_transkrip->Write(0, '', '', 0, 'C', true, 0, false, false, 0);
$this->pdf_transkrip->Write(0, 'KARTU RENCANA STUDI', '', 0, 'C', true, 0, false, false, 0);
$this->pdf_transkrip->Write(0, '', '', 0, 'C', true, 0, false, false, 0);
$this->pdf_transkrip->SetFont('helvetica', '', 8);
$smstrakademik = $this->nm_field2('nmthnakademik','v_tahunakademik','kdstsemester', $kdstsemester);
$dosenwali = $this->nm_field2('nmdosdgngelar','dosen','nidu', $niduwali);
$tingkat = $this->nm_field2('tingkat','semester','idsemester', $idsemester);
$mhs = $this->getmahasiswa($nim);
$waktukrs = $this->get_waktu_krs($nim, $kdstsemester);
foreach($mhs as $item) {
$head = <<
Nomor Pokok Mahasiswa |
: $item->nim |
NIDU Dosen Wali |
: $niduwali |
Nama Mahasiswa |
: $item->nmmhs |
Nama Dosen Wali |
: $dosenwali |
Fakultas |
: $item->nmfakultas |
Tahun Akademik - Semester |
: $smstrakademik |
Program Studi |
: $item->nmprodi |
Semester / Tingkat |
: $idsemester / $tingkat |
Waktu Input KRS |
: $waktukrs |
|
|
EOD;
}
$this->pdf_transkrip->writeHTML($head,true,false,false,false);
$this->pdf_transkrip->SetFont('helvetica', '', 7);
$itemkrs = $this->get_rows_krs($nim,$kdprodi,$tahunmsk,$kdstsemester,$idkelas,$idsemester,$isblanko);
$datakrs = $itemkrs['rows'];
$jmlsksambil = ($isblanko=='1') ? "":$itemkrs['jmlsksambil'];
$jmlskssetuju = ($isblanko=='1') ? "":$itemkrs['jmlskssetuju'];
$ipbefore = $this->get_ip_before($nim,$idsemester);
$maxsks = $this->get_max_sks($ipbefore);
$maindata = <<
No. |
Kode MK |
Nama MK ( Matakuliah ) |
Semester |
SKS |
Syarat Matakuliah |
Ambil |
Kelas |
Keterangan |
Status |
$datakrs
Jumlah SKS yang diambil |
: $jmlsksambil |
|
|
Jumlah SKS yang disetujui |
: $jmlskssetuju |
|
|
IP Semester Sebelumnya |
: $ipbefore |
|
|
Jumlah Maksimal SKS yang diambil |
: $maxsks |
|
|
EOD;
$this->pdf_transkrip->writeHTML($maindata,true,false,false,false);
for($a=1;$a<$before;$a++){
$this->pdf_transkrip->Cell(60,4,'',0,1,'C');//space
}
$this->pdf_transkrip->Cell(70,4,'KSBA,',0,0,'C');
$this->pdf_transkrip->Cell(60,4,'',0,0,'C');
$this->pdf_transkrip->Cell(70,4,'DOSEN WALI,',0,1,'C');
for($a=0;$a<$between;$a++){
$this->pdf_transkrip->Cell(60,4,'',0,1,'C');//space
}
$this->pdf_transkrip->SetFont('helvetica', 'B', 8);
$this->pdf_transkrip->Cell(70,4,'______________________',0,0,'C');
$this->pdf_transkrip->Cell(60,4,'',0,0,'C');
$this->pdf_transkrip->SetFont('helvetica', 'B'.'U', 8);
$this->pdf_transkrip->Cell(70,4,$dosenwali,0,1,'C');
$this->pdf_transkrip->Output('krs-'.$nim.'-'.$kdstsemester.'.pdf', 'I');
}
}