Exemple #1
0
function Edit($md, $id, $Kembali)
{
    if ($Kembali == 1) {
        if ($md == 0) {
            $jdl = "Edit Jadwal Remedial";
        } elseif ($md == 1) {
            $jdl = "Tambah Jadwal Remedial";
        } else {
        }
        $w = array();
        $w['ProgramID'] = $_REQUEST['ProgramID'];
        $w['MKID'] = $_REQUEST['MKID'];
        $w['MKKode'] = $_REQUEST['MKKode'];
        $w['Nama'] = $_REQUEST['MKNama'];
        $w['SKS'] = $_REQUEST['SKS'];
        $w['NamaKelas'] = $_REQUEST['NamaKelas'];
        $w['RencanaKehadiran'] = $_REQUEST['RencanaKehadiran'];
        $w['KehadiranMin'] = $_REQUEST['KehadiranMin'];
        $w['MaxAbsen'] = $_REQUEST['MaxAbsen'];
        $w['TglMulai'] = $_REQUEST['TglMulai'];
        $w['TglSelesai'] = $_REQUEST['TglSelesai'];
        $w['Kapasitas'] = $_REQUEST['Kapasitas'];
        $w['BiayaKhusus'] = $_REQUEST['BiayaKhusus'];
        $w['Biaya'] = $_REQUEST['Biaya'];
        $w['NamaBiaya'] = $_REQUEST['NamaBiaya'];
        $w['DosenID'] = $_REQUEST['DosenID'];
        $w['Dosen'] = GetaField('dosen', "KodeID='" . KodeID . "' and Login", $w['DosenID'], 'Nama');
    } else {
        if ($md == 0) {
            $jdl = "Edit Jadwal Remedial";
            $w = GetFields('jadwalremedial', 'JadwalRemedialID', $id, '*');
            $w['Dosen'] = GetaField('dosen', "KodeID='" . KodeID . "' and Login", $w['DosenID'], 'Nama');
            $w['JamMulai'] = substr($w['JamMulai'], 0, 5);
            $w['JamSelesai'] = substr($w['JamSelesai'], 0, 5);
        } elseif ($md == 1) {
            $jdl = "Tambah Jadwal Remedial";
            $w = array();
            $w['Dosen'] = '';
            $w['ProgramID'] = $_SESSION['_remProg'];
            $w['TglMulai'] = date('Y-m-d');
            $w['TglSelesai'] = date('Y-m-d');
            $w['HariID'] = date('w');
            $w['BiayaKhusus'] = 'N';
        } else {
        }
    }
    // Parameters
    JdwlScript();
    $prodi = GetFields('prodi', "KodeID='" . KodeID . "' and ProdiID", $_SESSION['_remProdi'], '*');
    $optprg = GetOption2('program', "concat(ProgramID, ' - ', Nama)", 'ProgramID', $w['ProgramID'], "KodeID='" . KodeID . "'", 'ProgramID');
    $opthari = GetOption2('hari', "Nama", 'HariID', $w['HariID'], '', 'HariID');
    $opttglmulai = GetDateOption2($w['TglMulai'], 'TglMulai', "AmbilHari('TglMulai', 'frmJadwal')");
    $opttglselesai = GetDateOption2($w['TglSelesai'], 'TglSelesai', "");
    $ck_biayakhusus = $w['BiayaKhusus'] == 'Y' ? 'checked' : '';
    $TanggalPenting = AmbilTanggalPenting($w['JadwalRemedialID']);
    // Tampilkan
    CheckFormScript("ProgramID,HariID,JamMulai,JamSelesai,DosenID,MKID");
    TampilkanJudul($jdl);
    echo <<<END
  <table class=bsc cellspacing=1 width=100%>
  <form name='frmJadwal' action='../{$_SESSION['mnux']}.edit.php' method=POST onSubmit="return CheckForm(this)">
  <input type=hidden name='gos' value='Simpan' />
  <input type=hidden name='md' value='{$md}' />
  <input type=hidden name='_remTahun' value='{$_SESSION['_remTahun']}' />
  <input type=hidden name='_remProdi' value='{$_SESSION['_remProdi']}' />
  <input type=hidden name='id' value='{$id}' />
  
  <tr><td class=inp>Program Studi:</td>
      <td class=ul1><b>{$prodi['Nama']}</b> <sup>({$_SESSION['_remProdi']})</sup></td>
      <td class=inp>Program:</td>
      <td class=ul1><select name='_remProg'>{$optprg}</select></td>
      </tr>
  <tr><td class=inp>Tanggal Mulai Remedial:</td>
      <td class=ul1>{$opttglmulai}</td>
\t  <td class=inp>Tanggal Selesai Remedial:</td>
\t  <td class=ul1>{$opttglselesai}</td>
\t  </tr>

  <tr><td class=inp>Matakuliah:</td>
      <td class=ul1 colspan=3 nowrap>
      <input type=hidden name='MKID' value='{$w['MKID']}' />
      <input type=text name='MKKode' value='{$w['MKKode']}' size=10 maxlength=50 />
      <input type=text name='MKNama' value='{$w['Nama']}' size=30 maxlength=50 onKeyUp="javascript:CariMK('{$_SESSION['_remProdi']}', 'frmJadwal')"/>
      <input type=text name='SKS' value='{$w['SKS']}' size=3 maxlength=3> <sub>SKS</sub>
      <div style='text-align:right'>
      &raquo;
      <a href='#'
        onClick="javascript:CariMK('{$_SESSION['_remProdi']}', 'frmJadwal')" />Cari...</a> |
      <a href='#' onClick="javascript:frmJadwal.MKID.value='';frmJadwal.MKKode.value='';frmJadwal.MKNama.value='';frmJadwal.SKS.value=0">Reset</a>
      </div>
      </td>
      </tr>

  <tr><td class=inp>Dosen Pengampu:</td>
      <td class=ul1 colspan=3 nowrap>
      <input type=text name='DosenID' value='{$w['DosenID']}' size=10 maxlength=50 />
      <input type=text name='Dosen' value='{$w['Dosen']}' size=30 maxlength=50 onKeyUp="javascript:CariDosen('{$_SESSION['_remProdi']}', 'frmJadwal')" />
      <div style='text-align:right'>
      &raquo;
      <a href='#'
        onClick="javascript:CariDosen('{$_SESSION['_remProdi']}', 'frmJadwal')" />Cari...</a> |
      <a href='#' onClick="javascript:frmJadwal.DosenID.value='';frmJadwal.Dosen.value=''">Reset</a>
      </div>
      </td>
      </tr>

  <tr><td class=inp>Kelas:</td>
      <td class=ul1><input type=text name='NamaKelas' value='{$w['NamaKelas']}' size=10 maxlength=10 /></td>
      </tr>
  <tr><td class=inp>Rencana Kehadiran Dosen:</td>
      <td class=ul1><input type=text name='RencanaKehadiran' value='{$w['RencanaKehadiran']}' size=4 maxlength=4 /></td>
      <td class=inp>Maksimum Absen:</td>
      <td class=ul1><input type=text name='MaxAbsen' value='{$w['MaxAbsen']}' size=4 maxlength=4 /></td>
      </tr>
  <tr><td class=inp>Ada Biaya Khusus?</td>
      <td class=ul1>
        <input type=checkbox name='BiayaKhusus' value='Y' {$ck_biayakhusus} /> &raquo;
        Biaya:
        <input type=text name='Biaya' value='{$w['Biaya']}' size=10 maxlength=20 />
      </td>
\t  <td class=inp>Nama Biaya:</td>
\t  <td class=ul1><input type=text name='NamaBiaya' value='{$w['NamaBiaya']}' size=30 maxlength=100></td>
      </tr>
  <tr><td class=inp>Tanggal<sup>2</sup> Penting:</td>
\t  <td colspan=3>
\t\t\t<table id='TanggalPenting' border=0 cellspacing=0 cellpadding=0 width=100%>
\t\t\t\t{$TanggalPenting}
\t\t\t</table>
\t\t    <input type=button name='TambahTanggal' value='Tambah Tanggal Remedial' onClick="fnTambahTanggal()">
\t\t\t<input type=hidden id='StringTanggalPenting' name='StringTanggalPenting' value=''>
\t  </td>
\t  </tr>
  <tr><td class=ul1 colspan=4 align=center>
      <input type=submit name='Simpan' value='Simpan' onClick="return SimpanKeString()"/>
      <input type=button name='Batal' value='Batal' onClick="window.close()" />
      </td></tr>
  </form>
  </table>

  <div class='box0' id='caridosen'></div>
  <div class='box0' id='carimk'></div>
  <div class='box0' id='cariruang'></div>
END;
}
Exemple #2
0
function Edit($md, $id, $resid, $Kembali)
{
    echo '
<link type="text/css" href="../datepicker2/datePicker.css" rel="stylesheet" />	
<script type="text/javascript" src="../datepicker2/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../datepicker2/date-id.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../datepicker2/jquery.bgiframe.js"></script>
<![endif]-->
<script type="text/javascript" src="../datepicker2/jquery.datePicker.js"></script>
';
    $s2 = "select date_format(TglMulai, '%d')+0 as _fromday, date_format(TglMulai, '%m')+0 as _frommonth, date_format(TglMulai, '%Y')+0 as _fromyear,\r\n\tdate_format(TglSelesai, '%d')+0 as _today, date_format(TglSelesai, '%m')+0 as _tomonth, date_format(TglSelesai, '%Y')+0 as _toyear\r\n\tfrom jadwal where NA = 'N' and JadwalID = {$id}";
    $q2 = _query($s2);
    $w2 = _fetch_array($q2);
    $start = $w2[_fromyear] . "," . $w2[_frommonth] . "," . $w2[_fromday];
    $end = $w2[_toyear] . ',' . $w2[_tomonth] . ',' . $w2[_today];
    echo "\r\n<script>\r\nfunction setDatePicker(selector,rangeSelector,stat){\r\n\tvar dt = \$('#alt'+selector).val().replace('-',',');\r\n\tdt = dt.replace('-',',');\r\n\t\r\n\t\$('#'+selector).datePicker({startDate:'01/01/1990'});\r\n\t\$('#'+selector).datePicker().val(new Date(dt).asString()).trigger('change');\r\n\t\$('#'+selector).dpSetPosition(\$.dpConst.POS_TOP, \$.dpConst.POS_RIGHT);\r\n\t\r\n\tif (rangeSelector != ''){\r\n\t\tvar dts = \$('#'+rangeSelector).val().replace('-',',');\r\n\t\tdts = dts.replace('-',',');\r\n\t\t\r\n\t\tif (dts) {\r\n\t\t\tdts = new Date(dts);\r\n\t\t\t\r\n\t\t\tif (stat == 'end'){\r\n\t\t\t\t\$('#'+selector).dpSetEndDate(dts.addDays(-1).asString());\r\n\t\t\t} else if (stat == 'start'){\r\n\t\t\t\t\$('#'+selector).dpSetStartDate(dts.addDays(1).asString());\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\t\t// bind to event\r\n\t\t\$('#'+rangeSelector).bind(\r\n\t\t\t'dpClosed',\r\n\t\t\tfunction(e, selectedDates)\r\n\t\t\t{\r\n\t\t\t\tvar year = selectedDates[0].getFullYear();\r\n\t\t\t\tvar mon = selectedDates[0].getMonth()+1;\r\n\t\t\t\tvar day = selectedDates[0].getDate();\r\n\t\t\t\tvar realvalue = year+'-'+mon+'-'+day;\r\n\t\t\t\t\$('#alt'+rangeSelector).val(realvalue);\r\n\t\t\t\t\r\n\t\t\t\tvar d = selectedDates[0];\r\n\t\t\t\tif (d) {\r\n\t\t\t\t\td = new Date(d);\r\n\t\t\t\t\tif (stat == 'end'){\r\n\t\t\t\t\t\t\$('#'+selector).dpSetEndDate(d.addDays(-1).asString());\r\n\t\t\t\t\t} else if (stat == 'start'){\r\n\t\t\t\t\t\t\$('#'+selector).dpSetStartDate(d.addDays(1).asString());\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t)\r\n\t}\t\r\n}\r\n\r\n\$(function()\r\n{\r\n\tDate.format = 'dd mmmm yyyy';\r\n\tsetDatePicker('KuliahTanggal','KuliahTanggal','');\r\n\t\tvar dts = '" . $start . "';\r\n\t\tif (dts) {\r\n\t\t\tdts = new Date(dts);\r\n\t\t\t\t\$('#KuliahTanggal').dpSetStartDate(dts.addDays(0).asString());\r\n\t\t\t}\r\n\t\tvar dts = '" . $end . "';\r\n\t\tif (dts) {\r\n\t\t\tdts = new Date(dts);\r\n\t\t\t\t\$('#KuliahTanggal').dpSetEndDate(dts.addDays(0).asString());\r\n\t\t\t}\r\n});\r\n</script>";
    function GetDateOption3($value, $name)
    {
        $a = "<input type=hidden name=" . $name . " id=alt" . $name . " value=" . $value . " /><input type=text id=" . $name . " value=" . $value . " readonly=true />";
        return $a;
    }
    if ($Kembali == 1) {
        if ($md == 0) {
            $jdl = "Edit Jadwal Ekstra";
        } else {
            if ($md == 1) {
                $jdl = "Tambah Jadwal Ekstra";
            } else {
                die(ErrorMsg('Fatal Error', "Mode Edit tidak diketahui"));
            }
        }
        $w = GetFields('jadwal j left outer join prodi prd on j.ProdiID=prd.ProdiID
								 left outer join program prg on j.ProgramID=prg.ProgramID', 'j.JadwalID', $id, 'j.DosenID, j.NamaKelas, j.RencanaKehadiran, j.MaxAbsen, prd.Nama as _PRD, prg.Nama as _PRG,
				j.MKID, j.MKKode, j.Nama, j.SKS');
        $w['HariID'] = $_REQUEST['HariID'];
        $w['JamMulai'] = $_REQUEST['JamMulai'];
        $w['JamSelesai'] = $_REQUEST['JamSelesai'];
        $w['DosenID'] = $_REQUEST['DosenID'];
        $w['RuangID'] = $_REQUEST['RuangID'];
        $w['Kapasitas'] = $_REQUEST['Kapasitas'];
        $w['KuliahTanggal'] = $_REQUEST['KuliahTanggal'];
        $w['_RencanaKehadiranRes'] = $_REQUEST['_RencanaKehadiranRes'];
        $w['_MaxAbsenRes'] = $_REQUEST['_MaxAbsenRes'];
        $w['Dosen'] = GetaField('dosen', "KodeID='" . KodeID . "' and Login", $w['DosenID'], 'Nama');
    } else {
        if ($md == 0) {
            $jdl = "Edit Jadwal Ekstra";
            $w = GetFields('jadwal jr left outer join jadwal j on jr.JadwalRefID=j.JadwalID
										  left outer join prodi prd on j.ProdiID=prd.ProdiID 
										  left outer join program prg on j.ProgramID=prg.ProgramID 
										  left outer join kelas k on k.KelasID = j.NamaKelas', 'jr.JadwalID', $resid, 'jr.*, j.ProdiID, j.ProgramID, j.DosenID, j.NamaKelas, j.RencanaKehadiran, j.MaxAbsen, prd.Nama as _PRD, prg.Nama as _PRG,
				j.MKID, j.MKKode, j.Nama, j.SKS, jr.RencanaKehadiran as _RencanaKehadiranRes, jr.MaxAbsen as _MaxAbsenRes,  k.Nama as NamaKelas');
            $w['Dosen'] = GetaField('dosen', "KodeID='" . KodeID . "' and Login", $w['DosenID'], 'Nama');
            $w['JamMulai'] = substr($w['JamMulai'], 0, 5);
            $w['JamSelesai'] = substr($w['JamSelesai'], 0, 5);
        } elseif ($md == 1) {
            $jdl = "Tambah Jadwal Ekstra";
            $w = GetFields('jadwal j left outer join prodi prd on j.ProdiID=prd.ProdiID
								 left outer join program prg on j.ProgramID=prg.ProgramID 
								 left outer join kelas k on k.KelasID = j.NamaKelas', 'j.JadwalID', $id, 'j.DosenID, j.NamaKelas, j.RencanaKehadiran, j.MaxAbsen, prd.Nama as _PRD, prg.Nama as _PRG,
				j.MKID, j.MKKode, j.Nama, j.SKS,  k.Nama as NamaKelas');
            $w['Dosen'] = GetaField('dosen', "KodeID='" . KodeID . "' and Login", $w['DosenID'], 'Nama');
            $w['KuliahTanggal'] = date('Y-m-d');
            $w['HariID'] = date('w');
            $w['_RencanaKehadiranRes'] = $w['RencanaKehadiran'];
            $w['_MaxAbsenRes'] = $w['MaxAbsen'];
        } else {
            die(ErrorMsg('Fatal Error', "Mode Edit tidak diketahui"));
        }
    }
    $opthari = GetOption2('hari', "Nama", 'HariID', $w['HariID'], '', 'HariID');
    $opttglkuliah = GetDateOption3($w['KuliahTanggal'], 'KuliahTanggal');
    $optJamMulai = GetTimeOption($w['JamMulai'], 'JamMulai');
    $optJamSelesai = GetTimeOption($w['JamSelesai'], 'JamSelesai');
    $optjenisjadwal = GetOption2('jenisjadwal', "concat(JenisJadwalID, ' - ', Nama)", 'JenisJadwalID', $w['JenisJadwalID'], "NA='N' and Tambahan='Y'", 'JenisJadwalID', 0, 0);
    // Parameters
    JdwlScript();
    // Tampilkan
    CheckFormScript("HariID,RuangID");
    TampilkanJudul($jdl);
    echo '
  <script>
  	function cekJdwl(){
	
		var fromHour = document.forms[0].JamMulai_h.value;
		var fromMinutes = document.forms[0].JamMulai_n.value;

		var toHour = document.forms[0].JamSelesai_h.value;
		var toMinutes = document.forms[0].JamSelesai_n.value;
		
		var d4 = new Date();
		d4.setHours(fromHour);
		d4.setMinutes(fromMinutes);
		
		var fromJam = d4.getTime();
		
		var d5 = new Date();
		d5.setHours(toHour);
		d5.setMinutes(toMinutes);
		
		var toJam = d5.getTime();
		
		var kapasitas = document.forms[0].Kapasitas.value;
		
		var errmsg = "";
		
		if (fromJam >= toJam){
			errmsg += "Jam kuliah mulai harus lebih awal dari jam kuliah selesai\\n"
		}
		if (kapasitas == 0){
			errmsg += "Kapasitas tidak boleh bernilai 0\\n"
		}
		if (errmsg != ""){
			alert (errmsg);
			return false;
		}
	}
  </script>';
    echo <<<END
  <table class=bsc cellspacing=1 width=100%>
  <form name='frmJadwal' action='../{$_SESSION['mnux']}.editlab.php' method=POST onSubmit="return CheckForm(this)">
  <input type=hidden name='gos' value='Simpan' />
  <input type=hidden name='md' value='{$md}' />
  <input type=hidden name='TahunID' value='{$_SESSION['_jdwlTahun']}' />
  <input type=hidden name='ProdiID' value='{$_SESSION['_jdwlProdi']}' />
  <input type=hidden name='id' value='{$id}' />
  <input type=hidden name='resid' value='{$resid}' />
  
  <tr><td class=inp>Program Studi:</td>
      <td class=ul1><b>{$w['_PRD']}</b> <sup>({$_SESSION['_jdwlProdi']})</sup></td>
      <td class=inp>Program:</td>
      <td class=ul1>{$w['_PRG']} <sup>{$w['ProgramID']}</sup></td>
      </tr>
   <tr><td class=inp>Matakuliah:</td>
      <td class=ul1 colspan=3 nowrap>
\t  {$w['MKKode']} - {$w['Nama']} <sub>{$w['SKS']} SKS</sub></td></tr>
  <tr><td class=inp>Dosen Pengampu:</td>
      <td class=ul1 colspan=3 nowarp>{$w['DosenID']} - {$w['Dosen']}</td>
      </tr>
  <tr><td class=inp>Kelas:</td>
      <td class=ul1>{$w['NamaKelas']}</td>
      </tr>
  <tr><td class=inp>Rencana Kehadiran Dosen:</td>
      <td class=ul1>{$w['RencanaKehadiran']}</td>
      <td class=inp>Maksimum Absen:</td>
      <td class=ul1>{$w['MaxAbsen']}</td>
      </tr>
  <tr><td colspan=4><hr color=silver size=3></td></tr>
  <tr><td class=inp>Jenis Jadwal Tambahan:</td>
\t  <td class=ul1 colspan=3><select name='JenisJadwalID'>{$optjenisjadwal}</select></td>
\t  </tr>
  <tr><td class=inp>Tanggal Mulai Tambahan:</td>
      <td class=ul1 colspan=3>{$opttglkuliah}</td>
\t  </tr>
  <tr><td class=inp>Hari:</td>
      <td class=ul1><select name='HariID'>{$opthari}</select></td>
      <td class=inp>Jam Kuliah:</td>
      <td class=ul1>
        {$optJamMulai} &#8594;
        {$optJamSelesai}
        </td>
      </tr>
  <tr><td class=inp>Ruang:</td>
      <td class=ul1>
        <input type=text name='RuangID' value='{$w['RuangID']}' size=10 maxlength=50 
          onKeyUp="javascript:CariRuang('{$_SESSION['_jdwlProdi']}', 'frmJadwal')" />
        &raquo;
      <a href='#'
        onClick="javascript:CariRuang('{$_SESSION['_jdwlProdi']}', 'frmJadwal')" />Cari...</a> |
      <a href='#' onClick="javascript:frmJadwal.RuangID.value=''">Reset</a>
        </td>
      <td class=inp>Kapasitas:</td>
      <td class=ul1>
        <input type=text name='Kapasitas' value='{$w['Kapasitas']}' size=4 maxlength=5 />
        <sub>orang</sub>
        </td>
      </tr>
  <tr><td class=inp>Rencana Kehadiran Tambahan:</td>
      <td class=ul1><input type=text name='_RencanaKehadiranRes' value='{$w['_RencanaKehadiranRes']}' size=4 maxlength=4></td>
      <td class=inp>Maksimum Absen Tambahan:</td>
      <td class=ul1><input type=text name='_MaxAbsenRes' value='{$w['_MaxAbsenRes']}' size=4 maxlength=4></td>
      </tr>
  <tr><td class=ul1 colspan=4 align=center>
      <input type=submit name='Simpan' value='Simpan' onclick="return cekJdwl()" />
      <input type=button name='Batal' value='Batal' onClick="window.close()" />
      </td></tr>
  </form>
  </table>

  <div class='box0' id='cariruang'></div>
END;
}
function Edit($md, $id, $Kembali)
{
    if ($Kembali == 1) {
        if ($md == 0) {
            $jdl = "Edit Jadwal";
        } elseif ($md == 1) {
            $jdl = "Tambah Jadwal";
        } else {
        }
        $w = array();
        $w['ProgramID'] = $_REQUEST['ProgramID'];
        $w['MKID'] = $_REQUEST['MKID'];
        $w['MKKode'] = $_REQUEST['MKKode'];
        $w['Nama'] = $_REQUEST['MKNama'];
        $w['SKS'] = $_REQUEST['SKS'];
        $w['NamaKelas'] = $_REQUEST['NamaKelas'];
        $w['RencanaKehadiran'] = $_REQUEST['RencanaKehadiran'];
        $w['KehadiranMin'] = $_REQUEST['KehadiranMin'];
        $w['MaxAbsen'] = $_REQUEST['MaxAbsen'];
        $w['TglMulai'] = $_REQUEST['TglMulai'];
        $w['TglSelesai'] = $_REQUEST['TglSelesai'];
        $w['Kapasitas'] = $_REQUEST['Kapasitas'];
        $w['HariID'] = $_REQUEST['HariID'];
        $w['RuangID'] = $_REQUEST['RuangID'];
        $w['BiayaKhusus'] = $_REQUEST['BiayaKhusus'];
        $w['Biaya'] = $_REQUEST['Biaya'];
        $w['NamaBiaya'] = $_REQUEST['NamaBiaya'];
        $w['DosenID'] = $_REQUEST['DosenID'];
        $w['Dosen'] = GetaField('dosen', "KodeID='" . KodeID . "' and Login", $w['DosenID'], 'Nama');
        $w['JamMulai'] = substr($_REQUEST['JamMulai'], 0, 5);
        $w['JamSelesai'] = substr($_REQUEST['JamSelesai'], 0, 5);
        $w['AdaResponsi'] = $_REQUEST['AdaResponsi'];
    } else {
        if ($md == 0) {
            $jdl = "Edit Jadwal";
            $w = GetFields('jadwal', 'JadwalID', $id, '*');
            $w['Dosen'] = GetaField('dosen', "KodeID='" . KodeID . "' and Login", $w['DosenID'], 'Nama');
            $w['JamMulai'] = substr($w['JamMulai'], 0, 5);
            $w['JamSelesai'] = substr($w['JamSelesai'], 0, 5);
        } elseif ($md == 1) {
            $jdl = "Tambah Jadwal";
            $w = array();
            $w['Dosen'] = '';
            $w['ProgramID'] = $_SESSION['_jdwlProg'];
            $w['RencanaKehadiran'] = GetaField('prodi', "KodeID='" . KodeID . "' and ProdiID", $_SESSION['_jdwlProdi'], 'DefKehadiran');
            $w['MaxAbsen'] = floor(0.3 * $w['RencanaKehadiran']);
            $w['KehadiranMin'] = $w['RencanaKehadiran'];
            $w['TglMulai'] = date('Y-m-d');
            $w['TglSelesai'] = date('Y-m-d');
            $w['HariID'] = date('w');
            $w['AdaResponsi'] = 'N';
            $w['BiayaKhusus'] = 'N';
        } else {
        }
    }
    $q = "select * from kelas where ProdiID = '" . $_SESSION[_jdwlProdi] . "' and TahunID = '" . $_SESSION[_jdwlTahun] . "'";
    $m = _query($q);
    if (_num_rows($m) == 0) {
        $optkelas = "";
    } else {
        $optkelas = "<option value='' {$sel}>&nbsp;</option>";
        while ($x = _fetch_array($m)) {
            $sel = $w['NamaKelas'] == $x[KelasID] ? 'selected=selected' : '';
            $optkelas .= "<option value={$x['KelasID']} {$sel}>{$x['Nama']}</option>";
        }
    }
    echo '
<link type="text/css" href="../datepicker2/datePicker.css" rel="stylesheet" />	
<script type="text/javascript" src="../datepicker2/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../datepicker2/date-id.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../datepicker2/jquery.bgiframe.js"></script>
<![endif]-->
<script type="text/javascript" src="../datepicker2/jquery.datePicker.js"></script>
';
    echo "\r\n<script>\r\nfunction setDatePicker(selector,rangeSelector,stat){\r\n\tvar dt = \$('#alt'+selector).val().replace('-',',');\r\n\tdt = dt.replace('-',',');\r\n\t\r\n\t\$('#'+selector).datePicker({startDate:'01/01/1990'});\r\n\t\$('#'+selector).datePicker().val(new Date(dt).asString()).trigger('change');\r\n\t\$('#'+selector).dpSetPosition(\$.dpConst.POS_TOP, \$.dpConst.POS_RIGHT);\r\n\t\r\n\tif (rangeSelector != ''){\r\n\t\tvar dts = \$('#'+rangeSelector).val().replace('-',',');\r\n\t\tdts = dts.replace('-',',');\r\n\t\t\r\n\t\tif (dts) {\r\n\t\t\tdts = new Date(dts);\r\n\t\t\t\r\n\t\t\tif (stat == 'end'){\r\n\t\t\t\t\$('#'+selector).dpSetEndDate(dts.addDays(-1).asString());\r\n\t\t\t} else if (stat == 'start'){\r\n\t\t\t\t\$('#'+selector).dpSetStartDate(dts.addDays(1).asString());\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\t\t// bind to event\r\n\t\t\$('#'+rangeSelector).bind(\r\n\t\t\t'dpClosed',\r\n\t\t\tfunction(e, selectedDates)\r\n\t\t\t{\r\n\t\t\t\tvar year = selectedDates[0].getFullYear();\r\n\t\t\t\tvar mon = selectedDates[0].getMonth()+1;\r\n\t\t\t\tvar day = selectedDates[0].getDate();\r\n\t\t\t\tvar realvalue = year+'-'+mon+'-'+day;\r\n\t\t\t\t\$('#alt'+rangeSelector).val(realvalue);\r\n\t\t\t\t\r\n\t\t\t\tvar d = selectedDates[0];\r\n\t\t\t\tif (d) {\r\n\t\t\t\t\td = new Date(d);\r\n\t\t\t\t\tif (stat == 'end'){\r\n\t\t\t\t\t\t\$('#'+selector).dpSetEndDate(d.addDays(-1).asString());\r\n\t\t\t\t\t} else if (stat == 'start'){\r\n\t\t\t\t\t\t\$('#'+selector).dpSetStartDate(d.addDays(1).asString());\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t)\r\n\t}\t\r\n}\r\n\r\n\$(function()\r\n{\r\n\tDate.format = 'dd mmmm yyyy';\r\n\tsetDatePicker('TglMulai','TglSelesai','end');\r\n\tsetDatePicker('TglSelesai','TglMulai','start');\r\n\t\t\r\n});\r\n</script>";
    function GetDateOption3($value, $name)
    {
        $a = "<input type=hidden name=" . $name . " id=alt" . $name . " value=" . $value . " /><input type=text id=" . $name . " value=" . $value . " readonly=true />";
        return $a;
    }
    // Parameters
    JdwlScript();
    $prodi = GetFields('prodi', "KodeID='" . KodeID . "' and ProdiID", $_SESSION['_jdwlProdi'], '*');
    $optprg = GetOption2('program', "concat(ProgramID, ' - ', Nama)", 'ProgramID', $w['ProgramID'], "KodeID='" . KodeID . "'", 'ProgramID');
    $opthari = GetOption2('hari', "Nama", 'HariID', $w['HariID'], '', 'HariID');
    //$opttglmulai = GetDateOption3($w['TglMulai'], 'TglMulai');
    //$opttglselesai = GetDateOption3($w['TglSelesai'], 'TglSelesai');
    $opttglmulai = GetDateOption2($w['TglMulai'], 'TglMulai', "AmbilHari('TglMulai', 'frmJadwal')");
    $opttglselesai = GetDateOption2($w['TglSelesai'], 'TglSelesai', "");
    $optJamMulai = GetTimeOption($w['JamMulai'], 'JamMulai');
    $optJamSelesai = GetTimeOption($w['JamSelesai'], 'JamSelesai');
    $ck_adaresponsi = $w['AdaResponsi'] == 'Y' ? 'checked' : '';
    $ck_biayakhusus = $w['BiayaKhusus'] == 'Y' ? 'checked' : '';
    // Tampilkan
    CheckFormScript("ProgramID,HariID,DosenID,MKID");
    TampilkanJudul($jdl);
    $s2 = "select date_format(TglKuliahMulai, '%d')+0 as _fromday, date_format(TglKuliahMulai, '%m')+0 as _frommonth, date_format(TglKuliahMulai, '%Y')+0 as _fromyear,\r\n\tdate_format(TglKuliahSelesai, '%d')+0 as _today, date_format(TglKuliahSelesai, '%m')+0 as _tomonth, date_format(TglKuliahSelesai, '%Y')+0 as _toyear\r\n\tfrom tahun where NA = 'N' and TahunID = '{$_SESSION['_jdwlTahun']}' and ProdiID = '{$_SESSION['_jdwlProdi']}' and ProgramID = '{$_SESSION['_jdwlProg']}'";
    $q2 = _query($s2);
    $w2 = _fetch_array($q2);
    $start = $w2[_fromyear] . "/" . $w2[_frommonth] . "/" . $w2[_fromday];
    $end = $w2[_toyear] . '/' . $w2[_tomonth] . '/' . $w2[_today];
    echo '
  <script>
  	function cekJdwl(start,end){
	
		var kuliahMulai = getDateTime("TglMulai");
		var kuliahSelesai = getDateTime("TglSelesai");
				
		var RkuliahMulai = Date.parse(start);
		var RkuliahSelesai = Date.parse(end);
		
		
		
		var fromHour = document.forms[0].JamMulai_h.value;
		var fromMinutes = document.forms[0].JamMulai_n.value;

		var toHour = document.forms[0].JamSelesai_h.value;
		var toMinutes = document.forms[0].JamSelesai_n.value;
		
		var d4 = new Date();
		d4.setHours(fromHour);
		d4.setMinutes(fromMinutes);
		
		var fromJam = d4.getTime();
		
		var d5 = new Date();
		d5.setHours(toHour);
		d5.setMinutes(toMinutes);
		
		var toJam = d5.getTime();
		
		var kapasitas = document.forms[0].Kapasitas.value;
		
		var errmsg = "";
		
		if (kuliahMulai < RkuliahMulai || kuliahMulai > RkuliahSelesai || kuliahSelesai < RkuliahMulai || kuliahSelesai > RkuliahSelesai){
			errmsg += "Tanggal kuliah harus berada pada masa kuliah sesuai Tahun Akademik\\n"
		}
		
		if (fromJam >= toJam){
			errmsg += "Jam kuliah mulai harus lebih awal dari jam kuliah selesai\\n"
		}
		if (kapasitas == 0){
			errmsg += "Kapasitas tidak boleh bernilai 0\\n"
		}
		if (errmsg != ""){
			alert (errmsg);
			return false;
		}
	}
  </script>';
    echo <<<END
  <table class=bsc cellspacing=1 width=100%>
  <form name='frmJadwal' action='../{$_SESSION['mnux']}.edit.php' method=POST onSubmit="return CheckForm(this)">
  <input type=hidden name='gos' value='Simpan' />
  <input type=hidden name='md' value='{$md}' />
  <input type=hidden name='TahunID' value='{$_SESSION['_jdwlTahun']}' />
  <input type=hidden name='ProdiID' value='{$_SESSION['_jdwlProdi']}' />
  <input type=hidden name='id' value='{$id}' />
  
  <tr><td class=inp>Program Studi:</td>
      <td class=ul1><b>{$prodi['Nama']}</b> <sup>({$_SESSION['_jdwlProdi']})</sup></td>
      <td class=inp>Program:</td>
      <td class=ul1><select name='ProgramID'>{$optprg}</select></td>
      </tr>
  <tr><td class=inp>Tanggal Mulai Kuliah:</td>
      <td class=ul1>{$opttglmulai}</td>
\t  <td class=inp>Tanggal Selesai Kuliah:</td>
\t  <td class=ul1>{$opttglselesai}</td>
\t  </tr>
  <tr><td class=inp>Hari:</td>
      <td class=ul1><select name='HariID'>{$opthari}</select></td>
      <td class=inp>Jam Kuliah:</td>
      <td class=ul1>
        {$optJamMulai} &#8594;
        {$optJamSelesai}
        </td>
      </tr>
  <tr><td class=inp>Ruang:</td>
      <td class=ul1>
        <input type=text name='RuangID' value='{$w['RuangID']}' size=10 maxlength=50 
          onKeyUp="javascript:CariRuang('{$_SESSION['_jdwlProdi']}', 'frmJadwal')" />
        &raquo;
      <a href='#'
        onClick="javascript:CariRuang('{$_SESSION['_jdwlProdi']}', 'frmJadwal')" />Cari...</a> |
      <a href='#' onClick="javascript:frmJadwal.RuangID.value=''">Reset</a>
        </td>
      <td class=inp>Kapasitas:</td>
      <td class=ul1>
        <input type=text name='Kapasitas' value='{$w['Kapasitas']}' size=4 maxlength=5 />
        <sub>orang</sub>
        </td>
      </tr>

  <tr><td class=inp>Matakuliah:</td>
      <td class=ul1 colspan=3 nowrap>
      <input type=hidden name='MKID' value='{$w['MKID']}' />
      <input type=text name='MKKode' value='{$w['MKKode']}' size=10 maxlength=50 />
      <input type=text name='MKNama' value='{$w['Nama']}' size=30 maxlength=50 onKeyUp="javascript:CariMK('{$_SESSION['_jdwlProdi']}', 'frmJadwal')"/>
      <input type=text name='SKS' value='{$w['SKS']}' size=3 maxlength=3> <sub>SKS</sub>
\t  <br><b><font color=green size=0.9em>Ada Responsi/Lab? </font></b><input type=checkbox name='AdaResponsi' value='Y' {$ck_adaresponsi}>
      <div style='text-align:right'>
      &raquo;
      <a href='#'
        onClick="javascript:CariMK('{$_SESSION['_jdwlProdi']}', 'frmJadwal')" />Cari...</a> |
      <a href='#' onClick="javascript:frmJadwal.MKID.value='';frmJadwal.MKKode.value='';frmJadwal.MKNama.value='';frmJadwal.SKS.value=0">Reset</a>
      </div>
      </td>
      </tr>

  <tr><td class=inp>Dosen Pengampu:</td>
      <td class=ul1 colspan=3 nowrap>
      <input type=text name='DosenID' value='{$w['DosenID']}' size=10 maxlength=50 />
      <input type=text name='Dosen' value='{$w['Dosen']}' size=30 maxlength=50 onKeyUp="javascript:CariDosen('{$_SESSION['_jdwlProdi']}', 'frmJadwal')" />
      <div style='text-align:right'>
      &raquo;
      <a href='#'
        onClick="javascript:CariDosen('{$_SESSION['_jdwlProdi']}', 'frmJadwal')" />Cari...</a> |
      <a href='#' onClick="javascript:frmJadwal.DosenID.value='';frmJadwal.Dosen.value=''">Reset</a>
      </div>
      </td>
      </tr>

  <tr><td class=inp>Kelas:</td>
      <td class=ul1><select name='NamaKelas'>{$optkelas}</select></td>
      </tr>
  <tr><td class=inp>Rencana Kehadiran Dosen:</td>
      <td class=ul1><input type=text name='RencanaKehadiran' value='{$w['RencanaKehadiran']}' size=4 maxlength=4 /></td>
      <td class=inp>Maksimum Absen:</td>
      <td class=ul1><input type=text name='MaxAbsen' value='{$w['MaxAbsen']}' size=4 maxlength=4 /></td>
      </tr>
  <tr><td class=inp>Ada Biaya Khusus?</td>
      <td class=ul1>
        <input type=checkbox name='BiayaKhusus' value='Y' {$ck_biayakhusus} /> &raquo;
        Biaya:
        <input type=text name='Biaya' value='{$w['Biaya']}' size=10 maxlength=20 />
      </td>
\t  <td class=inp>Nama Biaya:</td>
\t  <td class=ul1><input type=text name='NamaBiaya' value='{$w['NamaBiaya']}' size=30 maxlength=100></td>
      </tr>
  
  <tr><td class=ul1 colspan=4 align=center>
      <input type=submit name='Simpan' value='Simpan' onclick="return cekJdwl('{$start}','{$end}')" />
      <input type=button name='Batal' value='Batal' onClick="window.close()" />
      </td></tr>
  </form>
  </table>

  <div class='box0' id='caridosen'></div>
  <div class='box0' id='carimk'></div>
  <div class='box0' id='cariruang'></div>
END;
}