SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | if($domain!=='admin' && $domain!=='superadmin'){
| |
| 3 | ?><script language="javascript">document.location.href="logout.php"</script><?php | |
| 4 | } | |
| 5 | ?> | |
| 6 | <?php | |
| 7 | if($_GET['mode']=='input'){
| |
| 8 | ||
| 9 | $id_siswa=htmlentities($_POST['id_siswa']); | |
| 10 | $id_kelas=htmlentities($_POST['id_kelas']); | |
| 11 | ||
| 12 | $cek_query=mysql_query("select * from tbl_ruangan where id_siswa='$id_siswa' and id_kelas='$id_kelas'");
| |
| 13 | $cek_query2=mysql_query("select * from tbl_ruangan where id_siswa='$id_siswa'");
| |
| 14 | $cek_num=mysql_num_rows($cek_query); | |
| 15 | $cek_num2=mysql_num_rows($cek_query2); | |
| 16 | ||
| 17 | if($cek_num!==0 || $cek_num2!==0){
| |
| 18 | ?><script language="javascript">document.location.href="?page=jadwal_ruangkelas&status=4";</script><?php | |
| 19 | }else{
| |
| 20 | $query=mysql_query("insert into tbl_ruangan values('','$id_siswa','$id_kelas')");
| |
| 21 | ||
| 22 | if($query){
| |
| 23 | ?><script language="javascript">document.location.href="?page=jadwal_ruangkelas&status=1";</script><?php | |
| 24 | } | |
| 25 | } | |
| 26 | } | |
| 27 | ||
| 28 | if($_GET['mode']=='delete'){
| |
| 29 | ||
| 30 | $id_ruangan=$_GET['id_ruangan']; | |
| 31 | $query=mysql_query("delete from tbl_ruangan where id_ruangan='$id_ruangan'");
| |
| 32 | if($query){
| |
| 33 | ?><script language="javascript">document.location.href="?page=jadwal_ruangkelas&status=2";</script><?php | |
| 34 | } | |
| 35 | } | |
| 36 | ||
| 37 | if($_GET['mode']=='update'){
| |
| 38 | $id_ruangan=$_POST['id_ruangan']; | |
| 39 | ||
| 40 | $id_siswa=$_POST['id_siswa']; | |
| 41 | $id_kelas=$_POST['id_kelas']; | |
| 42 | ||
| 43 | $cek_query=mysql_query("select * from tbl_ruangan where id_siswa='$id_siswa' and id_kelas='$id_kelas'");
| |
| 44 | $cek_num=mysql_num_rows($cek_query); | |
| 45 | ||
| 46 | if($cek_num!==0){
| |
| 47 | ?><script language="javascript">document.location.href="?page=jadwal_ruangkelas&status=0";</script><?php | |
| 48 | }else{
| |
| 49 | ||
| 50 | $query=mysql_query("update tbl_ruangan set id_siswa='$id_siswa', id_kelas='$id_kelas' where id_ruangan='$id_ruangan'");
| |
| 51 | ||
| 52 | if($query){
| |
| 53 | ?><script language="javascript">document.location.href="?page=jadwal_ruangkelas&status=3";</script><?php | |
| 54 | }else{
| |
| 55 | echo mysql_error(); | |
| 56 | } | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 60 | if($_GET['mode']=='edit'){
| |
| 61 | $id_ruangan=$_GET['id_ruangan']; | |
| 62 | $edit=mysql_query("select * from tbl_ruangan where id_ruangan='$id_ruangan'");
| |
| 63 | ||
| 64 | $data=mysql_fetch_array($edit); | |
| 65 | $id_siswa=$data['id_siswa']; | |
| 66 | $id_kelas=$data['id_kelas']; | |
| 67 | } | |
| 68 | ?> | |
| 69 | ||
| 70 | <!-- start page-heading --> | |
| 71 | <div id="page-heading"> | |
| 72 | <h1>Ruang Kelas</h1> | |
| 73 | </div> | |
| 74 | <!-- end page-heading --> | |
| 75 | ||
| 76 | <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table"> | |
| 77 | <tr> | |
| 78 | <th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th> | |
| 79 | <th class="topleft"></th> | |
| 80 | <td id="tbl-border-top"> </td> | |
| 81 | <th class="topright"></th> | |
| 82 | <th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th> | |
| 83 | </tr> | |
| 84 | <tr> | |
| 85 | <td id="tbl-border-left"></td> | |
| 86 | <td> | |
| 87 | <!-- start content-table-inner ...................................................................... START --> | |
| 88 | <div id="content-table-inner"> | |
| 89 | ||
| 90 | <?php | |
| 91 | include "warning.php"; | |
| 92 | ?> | |
| 93 | ||
| 94 | <?php | |
| 95 | if($_GET['mode']=='edit'){
| |
| 96 | ?><form action="?page=jadwal_ruangkelas&mode=update" method="post"><?php | |
| 97 | }else{
| |
| 98 | ?><form action="?page=jadwal_ruangkelas&mode=input" method="post"><?php | |
| 99 | } | |
| 100 | ?> | |
| 101 | ||
| 102 | <table border="0" width="100%" cellpadding="0" cellspacing="0"> | |
| 103 | <tr valign="top"> | |
| 104 | <td><!-- start step-holder --> | |
| 105 | <!-- end step-holder --> | |
| 106 | <!-- start id-form --> | |
| 107 | <table border="0" cellpadding="0" cellspacing="0" id="id-form"> | |
| 108 | <tr> | |
| 109 | <th valign="top">Siswa</th> | |
| 110 | <td><select name="id_siswa" > | |
| 111 | <?php | |
| 112 | $siswa=mysql_query("select * from data_siswa order by nama_siswa asc");
| |
| 113 | while($row1=mysql_fetch_array($siswa)){
| |
| 114 | ?> | |
| 115 | <option value="<?php echo $row1['id_siswa'];?>" <?php if($row1['id_siswa']==$id_siswa){ echo 'selected';}?>><?php echo $row1['nama_siswa'];?> (<?php echo $row1['nis'];?>) </option>
| |
| 116 | <?php | |
| 117 | } | |
| 118 | ?> | |
| 119 | ||
| 120 | </select> | |
| 121 | </td> | |
| 122 | <td></td> | |
| 123 | </tr> | |
| 124 | ||
| 125 | <tr> | |
| 126 | <th valign="top">Kelas</th> | |
| 127 | <td><select name="id_kelas" > | |
| 128 | <?php | |
| 129 | $kelas=mysql_query("select * from setup_kelas order by nama_kelas asc");
| |
| 130 | while($row2=mysql_fetch_array($kelas)){
| |
| 131 | ?> | |
| 132 | <option value="<?php echo $row2['id_kelas'];?>" <?php if($row2['id_kelas']==$id_kelas){ echo 'selected';}?>><?php echo $row2['nama_kelas'];?></option>
| |
| 133 | <?php | |
| 134 | } | |
| 135 | ?> | |
| 136 | ||
| 137 | </select> | |
| 138 | </td> | |
| 139 | <td></td> | |
| 140 | </tr> | |
| 141 | ||
| 142 | <tr> | |
| 143 | <th> </th> | |
| 144 | <td valign="top"> | |
| 145 | <input type="hidden" name="id_ruangan" value="<?php echo $_GET['id_ruangan'];?>"> | |
| 146 | <input type="submit" name="submit" onClick="return confirm('Apakah Anda yakin?')" value="" class="form-submit" />
| |
| 147 | <input type="reset" value="" class="form-reset" /> | |
| 148 | </td> | |
| 149 | <td></td> | |
| 150 | </tr> | |
| 151 | </table> | |
| 152 | <!-- end id-form --> | |
| 153 | </td> | |
| 154 | <td><!-- start related-activities --> | |
| 155 | </td> | |
| 156 | </tr> | |
| 157 | <tr> | |
| 158 | <td><img src="images/shared/blank.gif" width="695" height="1" alt="blank" /></td> | |
| 159 | <td></td> | |
| 160 | </tr> | |
| 161 | </table> | |
| 162 | </form> | |
| 163 | ||
| 164 | <p><em>* Satu siswa hanya untuk Satu Ruang Kelas</em> | |
| 165 | <!-- start product-table ..................................................................................... --> | |
| 166 | </p> | |
| 167 | <p> </p> | |
| 168 | ||
| 169 | ||
| 170 | <?php | |
| 171 | //************awal paging************// | |
| 172 | $query=mysql_query("select * from tbl_ruangan ruangan, setup_kelas kelas, data_siswa siswa where ruangan.id_kelas=kelas.id_kelas and ruangan.id_siswa=siswa.id_siswa order by id_ruangan asc");
| |
| 173 | $get_pages=mysql_num_rows($query); //dapatkan jumlah semua data | |
| 174 | ||
| 175 | echo "<hr>entries = $entries<hr>"; | |
| 176 | if ($get_pages>$entries) //jika jumlah semua data lebih banyak dari nilai awal yang diberikan | |
| 177 | {
| |
| 178 | ?>Halaman : <?php | |
| 179 | $pages=1; | |
| 180 | while($pages<=ceil($get_pages/$entries)) | |
| 181 | {
| |
| 182 | if ($pages!=1) | |
| 183 | {
| |
| 184 | echo " | "; | |
| 185 | } | |
| 186 | ?> | |
| 187 | <!--Membuat link sesuai nama halaman--> | |
| 188 | <a href="?page=jadwal_ruangkelas&halaman=<?php echo ($pages-1); ?> " style="text-decoration:none"><font size="2" face="verdana" color="#009900"><?php echo $pages; ?></font></a> | |
| 189 | <?php | |
| 190 | $pages++; | |
| 191 | } | |
| 192 | ||
| 193 | }else{
| |
| 194 | $pages=1; | |
| 195 | } | |
| 196 | ||
| 197 | //**************akhir paging*****************// | |
| 198 | ?> | |
| 199 | </font> | |
| 200 | <?php | |
| 201 | $page=(int)$_GET['halaman']; | |
| 202 | $offset=$page*$entries; | |
| 203 | ||
| 204 | //menampilkan data dengan menggunakan limit sesuai parameter paging yang diberikan | |
| 205 | $result=mysql_query("select * from tbl_ruangan ruangan, setup_kelas kelas, data_siswa siswa where ruangan.id_kelas=kelas.id_kelas and ruangan.id_siswa=siswa.id_siswa order by id_ruangan asc limit $offset,$entries"); //output
| |
| 206 | ?> | |
| 207 | ||
| 208 | <form id="mainform" action=""> | |
| 209 | <table class="table"> | |
| 210 | <tr> | |
| 211 | <td><a href="">Nomor</a><td> | |
| 212 | <td><a href="">Nama Siswa</a><td> | |
| 213 | <td><a href="">NIS</a><td> | |
| 214 | <td><a href="">Kelas</a><td> | |
| 215 | <td><a href="">Aksi</a><td> | |
| 216 | </tr> | |
| 217 | <?php | |
| 218 | $no=0; | |
| 219 | while($row=mysql_fetch_array($result)){
| |
| 220 | ?> | |
| 221 | <tr class="table"> | |
| 222 | <td><?php echo $offset=$offset+1;?></td> | |
| 223 | <td><?php echo $row['nama_siswa'];?></td> | |
| 224 | <td><?php echo $row['nis'];?></td> | |
| 225 | <td><?php echo $row['nama_kelas'];?></td> | |
| 226 | <td class="options-width"> | |
| 227 | <a href="?page=jadwal_ruangkelas&mode=delete&id_ruangan=<?php echo $row['id_ruangan'];?>" onclick="return confirm('Apakah Anda yakin?')" title="Delete" class="icon-2 info-tooltip"></a>
| |
| 228 | <a href="?page=jadwal_ruangkelas&mode=edit&id_ruangan=<?php echo $row['id_ruangan'];?>" title="Edit" class="icon-5 info-tooltip"></a> | |
| 229 | </td> | |
| 230 | </tr> | |
| 231 | <?php | |
| 232 | } | |
| 233 | ?> | |
| 234 | </table> | |
| 235 | TOTAL DATA : <?php echo $get_pages;?> | |
| 236 | <!-- end product-table................................... --> | |
| 237 | </form> | |
| 238 | ||
| 239 | ||
| 240 | ||
| 241 | <div class="clear"></div> | |
| 242 | ||
| 243 | </div> | |
| 244 | <!-- end content-table-inner ............................................END --> | |
| 245 | </td> | |
| 246 | <td id="tbl-border-right"></td> | |
| 247 | </tr> | |
| 248 | <tr> | |
| 249 | <th class="sized bottomleft"></th> | |
| 250 | <td id="tbl-border-bottom"> </td> | |
| 251 | <th class="sized bottomright"></th> | |
| 252 | </tr> | |
| 253 | </table> |