<?php
include('../../sys/phpcore.inc');

$gl = $_POST['gl'];
?>
<table style="width:100%" class="table">
<?php
if($gl==1){?>

        	<tr>
            	<td style="width:200px;">Kelompok</td>
                <td>
                	<select class="input" id="koleksi">
                    <?php 
					$sql_gol = "select * from dl_koleksi where gl_autoid = 1";
					$gol_conn = $conn->query($sql_gol) or die($sql_gol);
					while($gol = $gol_conn->fetch_array()){
					?>
                    	<option value="<?php echo $gol['kl_autoid']?>"><?php echo $gol['kl_name']?></option>
                        <?php } ?>
                    </select>
                </td>
            </tr>
        	<tr>
            	<td style="width:200px;">Fiksi / Non Fiksi</td>
                <td>
                	<select class="input" id="ff">
                    	<option value="1">Fiksi</option>
                        <option value="2">Non-Fiksi</option>
                    </select>
                </td>
            </tr>
			<script>
            function get_sub_jenis(x){
				if(x==1){
					$('#sub_jb').show()
					}
				else{
					$('#sub_jb').hide()
					}
				}
            </script>
        	<tr>
            	<td style="width:200px;">Jenis Buku</td>
                <td>
                	<select class="input" id="jb" onchange="get_sub_jenis(this.value)">
                    <option value="">Pilih Jenis Buku</option>
                    <?php 
					$sql_gol = "select * from dl_jenisbuku WHERE gl_autoid = 1 AND jb_parent_id = 0";
					$gol_conn = $conn->query($sql_gol) or die($sql_gol);
					while($gol = $gol_conn->fetch_array()){
					?>
                    	<option value="<?php echo $gol['jb_autoid']?>"><?php echo $gol['jb_name']?></option>
                        <?php } ?>
                    </select>
                </td>
            </tr>
            <tr id="sub_jb" style="display:none;">
            	<td>Sub Jenis</td>
                <td>
                	<input type="checkbox" value="4" name="sub_jb1" id="sub_jb1"/> Pengayaan Pengetahuan
                    <input type="checkbox" value="5" name="sub_jb2" id="sub_jb2" /> Pengayaan Keterampilan
                    <input type="checkbox" value="6" name="sub_jb3" id="sub_jb3" /> Pengayaan Kepribadian
                </td>
            </tr>
        	<tr>
            	<td>Jenjang</td>
                <td>
                	<select class="input" id="jj">
                    <option value="">Pilih Jenjang</option>
                    <?php 
					$sql_gol = "select * from dl_jenjang where gl_autoid = 1";
					$gol_conn = $conn->query($sql_gol) or die($sql_gol);
					while($gol = $gol_conn->fetch_array()){
					?>
                    	<option value="<?php echo $gol['jj_autoid']?>"><?php echo $gol['jj_name']?></option>
                        <?php } ?>
                    </select>
                </td>
            </tr>
        	<tr>
            	<td>Mapel</td>
                <td>
                	<select class="input" id="mp">
                    <?php 
					$sql_gol = "select * from dl_mapel";
					$gol_conn = $conn->query($sql_gol) or die($sql_gol);
					while($gol = $gol_conn->fetch_array()){
					?>
                    	<option value="<?php echo $gol['mp_autoid']?>"><?php echo $gol['mp_name']?></option>
                        <?php } ?>
                    </select>
                </td>
            </tr>
<?php } if($gl==2){ ?>
        	<tr>
            	<td style="width:200px;">Jenis Buku</td>
                <td>
                	<select class="input" id="jb">
                    <?php 
					$sql_gol = "select * from dl_jenisbuku WHERE gl_autoid = 2";
					$gol_conn = $conn->query($sql_gol) or die($sql_gol);
					while($gol = $gol_conn->fetch_array()){
					?>
                    	<option value="<?php echo $gol['jb_autoid']?>"><?php echo $gol['jb_name']?></option>
                        <?php } ?>
                    </select>
                </td>
            </tr>
        	<tr>
            	<td>Jenjang</td>
                <td>
                	<select class="input" id="jj">
                    <?php 
					$sql_gol = "select * from dl_jenjang WHERE gl_autoid = 2";
					$gol_conn = $conn->query($sql_gol) or die($sql_gol);
					while($gol = $gol_conn->fetch_array()){
					?>
                    	<option value="<?php echo $gol['jj_autoid']?>"><?php echo $gol['jj_name']?></option>
                        <?php } ?>
                    </select>
                </td>
            </tr>
        	<tr>
            	<td>Kelas</td>
                <td>
                	<select class="input" id="kelas">
                    <?php for($i=1;$i<13;$i++){?>
						<option value="<?php echo $i?>"><?php echo $i?></option>
                        <?php } ?>
                    </select>
                </td>
            </tr>            
        	<tr>
            	<td>Tipe Buku</td>
                <td>
                	<select class="input" id="tipe">
						<option value="1">Buku Siswa</option>
                        <option value="2">Buku Guru</option>
                    </select>
                </td>
            </tr>

<?php } if($gl==3) {?>

        	<tr>
            	<td style="width:200px;">Subjek</td>
                <td>
                	<select class="input" id="mp">
                    <?php 
					$sql_gol = "select * from dl_mapel WHERE gl_autoid = 3 ORDER BY mp_name";
					$gol_conn = $conn->query($sql_gol) or die($sql_gol);
					while($gol = $gol_conn->fetch_array()){
					?>
                    	<option value="<?php echo $gol['mp_autoid']?>"><?php echo $gol['mp_name']?></option>
                        <?php } ?>
                    </select>
                </td>
            </tr>

<?php }?>
<tr>
	<td colspan="2">
    </td>
</tr>
</table>