function datakosong()
    {
        #cek status message
        #=========================================
        $status = mysql_query("SELECT a.*, b.username FROM mdl_message a INNER JOIN mdl_user b ON a.useridfrom=b.id WHERE a.useridfrom='" . $_SESSION['user_id'] . "' AND a.message='pindahrequest'");
        if (mysql_num_rows($status) !== 0) {
            echo "<center>jika ingin membatalkan perpindahan silahkan klik ";
            ?>
<a
	href="javascript:if(confirm('Anda yakin membatalkan pertukaran jadwal anda?')){document.location='index.php?page=prosesPindah&action=batal';}">
	batal</a>
</center>
<br>
			<?php 
        } else {
            $sql2 = mysql_query("SELECT a.id as idjadwal,b.id as idcourse,a . * , b . * ,\n\t\t(SELECT COUNT( c.id ) FROM mdl_jadwal c\nINNER JOIN mdl_course d ON c.courseid = d.id\nWHERE c.courseid = a.courseid\nAND c.date = a.date \n) AS jumlahpraktikan\nFROM mdl_jadwal a\nINNER JOIN mdl_course b ON a.courseid = b.id\nWHERE a.courseid = '" . $_SESSION['idcourse'] . "'\nAND DATE( a.date ) > DATE( NOW( ) ) AND a.userid != '" . $_SESSION['user_id'] . "'\nGROUP BY b.waktu ORDER BY a.date ASC ");
            echo "<table id=hor-minimalist-b align=center>\n\t\t<th scope=col>Praktikum</th>\n\t\t<th scope=col>Tanggal</th>\n\t\t<th scope=col>Waktu</th>\n\t\t<th scope=col>Praktikan</th>\n\t\t<th scope=col>Pindah</th>";
            while ($row = mysql_fetch_array($sql2)) {
                if (cekmaksimal($row["jumlahpraktikan"], $row["praktikan_max"])) {
                    /*$sql2= mysql_query("SELECT a.*,b.*,(SELECT COUNT(c.id) FROM mdl_jadwal c
                    	 INNER JOIN mdl_course d ON c.courseid = d.id
                    	 WHERE c.courseid = '".$_SESSION['idcourse']."'
                    	 AND c.date=a.date)as jumlahpraktikan FROM mdl_jadwal a INNER JOIN mdl_course b ON a.courseid = b.id WHERE a.courseid='".$_SESSION['idcourse']."' AND DATE(a.date)>=DATE(NOW()) HAVING count(jumlahpraktikan)<b.praktikan_max ORDER BY a.date asc");
                    	 */
                    echo "<tr>\n\t\t\t<td>" . $row["fullname"] . "</td>\n\t\t\t<td>" . tglSQL($row["date"]) . "</td>\n\t\t\t<td>" . $row["waktu"] . "</td>\n\t\t\t<td>" . $row["jumlahpraktikan"] . "</td>\n\t\t\t<td align=center>";
                    ?>
<a
	href="javascript:if(confirm('Anda yakin akan pindah jadwal pada <?php 
                    echo tglSQL($row["date"]);
                    ?>
 ?')){document.location='index.php?page=Pindah&id=<?php 
                    echo $row["idjadwal"];
                    ?>
';}">
	<img src='mahasiswa/pindahjadwal/images/submit.gif' alt='submit'> </a>
					<?php 
                    echo "</td></tr>";
                }
            }
            echo "</table><br>";
        }
    }
		href="javascript:if(confirm('Anda yakin membatalkan pertukaran jadwal anda?')){document.location='index.php?page=prosesTukar&action=batal';}">
		batal</a>
	</center>
	<?php 
                } else {
                    #sql data pencarian
                    #===========================================
                    $sql = mysql_query("SELECT a.id as iduser2, b.id as idcourse, c.id as idjadwal, a.nim, a.username, b.id, b.fullname, b.shortname,c.date\n\t\t\t\tFROM mdl_user a INNER JOIN mdl_jadwal c ON a.id = c.userid INNER JOIN mdl_course b ON b.id = c.courseid\nWHERE a.role=6 AND a.id!='" . $_SESSION['user_id'] . "' AND b.id='" . $_SESSION['idcourse'] . "' AND c.date='{$tanggaltujuanpost}' ORDER BY c.date");
                    #Jika Data 0
                    #=============================================
                    if (mysql_num_rows($sql) == 0) {
                        echo "<center><font color=red>Jadwal Tidak Ditemukan, Silahkan Cari Lagi</font></center><br>";
                    } else {
                        echo "<table id=hor-minimalist-b align=center>\n\t\t<th scope=col>Nim</th>\n\t\t<th scope=col>Nama</th>\n\t\t<th scope=col>Mata Kuliah</th>\n\t\t<th scope=col>Tanggal</th>\n\t\t<th scope=col>Tukar</th>";
                        while ($row = mysql_fetch_array($sql)) {
                            echo "<tr>\n\t\t\t<td>" . $row["nim"] . "</td>\n\t\t\t<td>" . $row["username"] . "</td>\n\t\t\t<td>" . $row["fullname"] . "</td>\n\t\t\t<td>" . tglSQL($row["date"]) . "</td>\n\t\t\t<td align=center>";
                            ?>
	<a
		href="javascript:if(confirm('Anda yakin akan menukar data dengan <?php 
                            echo $row["username"];
                            ?>
 ?')){document.location='index.php?page=Tukar&id=<?php 
                            echo $row["idjadwal"];
                            ?>
';}">
		<img src='mahasiswa/pindahjadwal/images/submit.gif' alt='submit'> </a>
		<?php 
                            echo "</td></tr>";
                        }
                        echo "</table>";
                    }
<?php

#isi dalam header pesan
#======================================================
include '../../login/functions.php';
sec_session_start();
// Our custom secure way of starting a php session.
include '../../config.php';
$iduser = $_SESSION['user_id'];
//$pesan = mysql_query("SELECT a.*, b.username FROM mdl_message a INNER JOIN mdl_user b ON a.useridto=b.id  WHERE useridto='$iduser' AND status='N'");
$pesan = mysql_query("SELECT a.*, b.username FROM mdl_message a INNER JOIN mdl_user b ON (a.useridfrom=b.id AND a.message='request') OR (a.useridto=b.id AND a.message='decline')  OR (useridto=b.id AND message='accept') OR (a.useridto=b.id AND a.message='pindahdecline')  OR (useridto=b.id AND message='pindahaccept') WHERE a.status='N' AND ((useridto='{$iduser}' AND message='request') OR (useridfrom='{$iduser}' AND message='decline')  OR (useridfrom='{$iduser}' AND message='accept') OR (useridfrom='{$iduser}' AND message='pindahdecline')  OR (useridfrom='{$iduser}' AND message='pindahaccept')) ORDER BY a.date desc, a.time desc");
$j = mysql_num_rows($pesan);
if ($j > 0) {
    echo "<table border=0 width=100% style=\"font-size:10pt\">";
} else {
    die("<font color=red size=1>Tidak ada pesan baru yang belum dibaca</font>");
}
while ($p = mysql_fetch_array($pesan)) {
    echo "<tr><td onmouseover=\"this.style.backgroundColor='#F0F0F0'\"\n     onmouseout=\"this.style.backgroundColor='#F8F8F8'\">\n     <a href=index.php?page=pesan&no=" . $p['id'] . ">Pesan dari : " . $p['username'] . "</a><br>\n     Waktu : " . tglSQL($p['date']) . " " . $p['time'] . "</td></tr>";
}
echo "</table>";
 $dataPerhal = 10;
 // apabila $_GET['hal'] sudah didefinisikan, gunakan nomor halaman tersebut,
 // sedangkan apabila belum, nomor halamannya 1.
 if (isset($_GET['hal'])) {
     $nohal = $_GET['hal'];
 } else {
     $nohal = 1;
 }
 // perhitungan offset
 $offset = ($nohal - 1) * $dataPerhal;
 // query SQL untuk menampilkan data perhalaman sesuai offset
 $query = mysql_query("SELECT *,DATE(uploaddate)as tanggal,TIME(uploaddate) as jam from mdl_user WHERE DATE(uploaddate)='{$tanggal}' AND role=6 AND uploadnumber='{$urutan}' order by uploaddate desc, uploadnumber asc LIMIT {$offset}, {$dataPerhal} ");
 if (mysql_num_rows($query) !== 0) {
     echo "<table border=1 align='center'>\n\t\t<tr>\n\t\t<th>Nim</th>\n\t\t<th>Nama</th>\n\t\t<th>Tanggal upload</th>\n\t\t<th>Jam</th>\n\t\t<th>Urutan</th>\n\t\t<th></th>\n\t\t</tr>";
     while ($row = mysql_fetch_array($query)) {
         echo "<tr>\n\t<td>" . $row["nim"] . "</td>\n\t<td>" . $row["username"] . "</td>\n\t<td>" . tglSQL($row["tanggal"]) . "</td>\n\t<td>" . $row["jam"] . "</td>\n\t<td>ke- " . $row["uploadnumber"] . "</td>\n\t<td><a href='data.php?id=" . $row['nim'] . "'>Hapus</a></td>\n\t\t</tr>";
     }
     echo "</table><br>";
 } else {
     echo "<center>no result database</center>";
 }
 $query = "SELECT COUNT(*) AS jumData FROM tb_mdl_user";
 $hasil = mysql_query($query);
 $data = mysql_fetch_array($hasil);
 $jumData = $data['jumData'];
 // menentukan jumlah halaman yang muncul berdasarkan jumlah semua data
 $jumhal = ceil($jumData / $dataPerhal);
 // menampilkan link previous
 echo '<div align="center">';
 if ($nohal > 1) {
     echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=datauser&hal=" . ($nohal - 1) . "'>&lt;&lt; Prev</a>";
    ?>
			
			
		<table id="hor-minimalist-b" align="center">
			<tr>
				<th scope="col">Nim</th>
				<th scope="col">Nama Peminta</th>
				<th scope="col">Mata Kuliah</th>
				<th scope="col">Tanggal</th>
				<th scope="col">Tanggal Anda</th>
				<th scope="col" colspan="2">Action</th>
			</tr>
			<tr>
			<?php 
    while ($row = mysql_fetch_array($tampil)) {
        echo "\n\t\t<td>" . $row["nim"] . "</td>\n\t\t<td>" . $row["username"] . "</td>\n\t\t<td>" . $row["fullname"] . "</td>\n\t\t<td>" . tglSQL($row["date"]) . "</td>\n\t\t<td>" . tglSQL($row["datemhs2"]) . "</td>\n\t\t";
        ?>
				<td><a
					href="javascript:if(confirm('Anda yakin akan menukar jadwal dengan	 <?php 
        echo $row["username"];
        ?>
 ?')){document.location='index.php?page=prosesTukar&action=accept';}"><img
						src='mahasiswa/pindahjadwal/images/accept.png' alt='accept'> </a>
				</td>
				<td><a
					href="javascript:if(confirm('Anda yakin mengabaikan pertukaran jadwal dari	 <?php 
        echo $row["username"];
        ?>
 ?')){document.location='index.php?page=prosesTukar&action=decline';}"><img
						src='mahasiswa/pindahjadwal/images/decline.png' alt='decline'> </a>
				</td>