<?php
	
	if($_SESSION["ses_admin_level"]=="TPK"){

		$qry=mysqli_query($mysqli,"SELECT * FROM qa WHERE status='Y' ORDER BY id ASC");
		echo "<h3 align=\"right\" style=\"padding-right:10px\"><a href='?action=add_qa' style=\"color:#FF0066\">Kirim Pertanyaan</a></h3>";
	
		if(mysqli_num_rows($qry)>0){
			
			$no=1;
			
			echo "<table width='100%' align='center' cellpadding='0' cellspacing='0' border='1' bgcolor='#C4D9FF'>";
			echo "<tr bgcolor='#fffccc'>
					<tr bgcolor='#fffccc'>
					    <td width=\"5%\" rowspan=\"2\"><strong>No</strong></td>
					    <td colspan=\"3\"><strong>Pengirim</strong></td>
					    <td colspan=\"3\"><strong>Penjelasan</strong></td>
					  </tr>
					  <tr bgcolor='#fffccc'>
					    <td width=\"10%\"><strong>Asal</strong></td>
					    <td width=\"10%\"><strong>Tanggal</strong></td>
					    <td width=\"20%\"><strong>Pertanyaan</strong></td>
					    <td width=\"10%\"><strong>Sumber</strong></td>
					    <td width=\"10%\"><strong>Tanggal</strong></td>
					    <td width=\"20%\"><strong>Uraian</strong></td>
					  </tr>

				  </tr>";	

			while($data=mysqli_fetch_array($qry)){
				if($data[tanggal_jawab]=="0000-00-00"){
					$tgljawab="";
				}else{
					$tgljawab=$data["tanggal_jawab"];
				}
				echo "<tr bgcolor=\"#fffcfc\">
						<td align=\"center\" valign=\"top\">$no</td>
						<td valign=\"top\">$data[asal]</td>
						<td valign=\"top\">$data[tanggal_tanya]</td>
						<td valign=\"top\">$data[pertanyaan]</td>
						<td valign=\"top\">$data[sumber]</td>
						<td valign=\"top\">$tgljawab</td>
						<td valign=\"top\">$data[uraian]</td>
				     </tr>";
				$no++;  
			}
			
			echo "</table>";
		}else{
		
			echo "<table width='100%' align='center' cellpadding='0' cellspacing='0' border='1' bgcolor='#C4D9FF'>";
			echo "<tr bgcolor='#fffccc'>
					<tr bgcolor='#fffccc'>
					    <td width=\"5%\" rowspan=\"2\"><strong>No</strong></td>
					    <td colspan=\"3\"><strong>Pengirim</strong></td>
					    <td colspan=\"3\"><strong>Penjelasan</strong></td>
					  </tr>
					  <tr bgcolor='#fffccc'>
					    <td width=\"10%\"><strong>Asal</strong></td>
					    <td width=\"10%\"><strong>Tanggal</strong></td>
					    <td width=\"20%\"><strong>Pertanyaan</strong></td>
					    <td width=\"10%\"><strong>Sumber</strong></td>
					    <td width=\"10%\"><strong>Tanggal</strong></td>
					    <td width=\"20%\"><strong>Uraian</strong></td>
					  </tr>

				  </tr>";	
			
			echo "<tr>
						<td colspan='7' align='center'>Tidak ditemukan data tanya jawab</td>
				     </tr>";		
			echo "</table>";
		}

	}elseif($_SESSION["ses_admin_level"]=="ULP"){
		if($_GET["mode"]=="moderasi"){
			$qry=mysqli_query($mysqli,"SELECT * FROM qa WHERE status='N' ORDER BY id ASC");
			if(mysqli_num_rows($qry)>0){
			
				$no=1;
				
				echo "<form action='_del_qa.php' method='post'><table width='100%' align='center' cellpadding='0' cellspacing='0' border='1' bgcolor='#C4D9FF'>";
				echo "<tr bgcolor='#fffccc'>
						  <tr bgcolor='#fffccc'>
						    <td width=\"5%\" rowspan=\"2\"><strong>No</strong></td>
						    <td colspan=\"3\"><strong>Pengirim</strong></td>
						    <td colspan=\"3\"><strong>Penjelasan</strong></td>
						  </tr>
						  <tr bgcolor='#fffccc'>
						    <td width=\"10%\"><strong>Asal</strong></td>
						    <td width=\"10%\"><strong>Tanggal</strong></td>
						    <td width=\"20%\"><strong>Pertanyaan</strong></td>
						    <td width=\"10%\"><strong>Sumber</strong></td>
						    <td width=\"10%\"><strong>Tanggal</strong></td>
						    <td width=\"20%\"><strong>Uraian</strong></td>
							
						  </tr>

					  </tr>";	

				while($data=mysqli_fetch_array($qry)){
					if($data[tanggal_jawab]=="0000-00-00"){
						$tgljawab="";
					}else{
						$tgljawab=$data["tanggal_jawab"];
					}
					echo "<tr bgcolor=\"#fffcfc\">
							<td align=\"center\" valign=\"top\"><input type='checkbox' name='chkhapus[]' value='$data[id]'/>$no</td>
							<td valign=\"top\">$data[asal]</td>
							<td valign=\"top\">$data[tanggal_tanya]</td>
							<td valign=\"top\">$data[pertanyaan]</td>
							<td valign=\"top\">$data[sumber]</td>
							<td valign=\"top\">$tgljawab</td>
							<td valign=\"top\"><a href='?page=moderasi_qa&id_qa=$data[id]'>Jawab</a></td>
					     </tr>";
					$no++;  
				}
				
				echo "</table><br/>
				<input type='submit' value='&nbsp;Hapus yang dipilih&nbsp;'/>
				</form>";
			}else{
			
				echo "<table width='100%' align='center' cellpadding='0' cellspacing='0' border='1' bgcolor='#C4D9FF'>";
				echo "<tr bgcolor='#fffccc'>
						<tr bgcolor='#fffccc'>
						    <td width=\"5%\" rowspan=\"2\"><strong>No</strong></td>
						    <td colspan=\"3\"><strong>Pengirim</strong></td>
						    <td colspan=\"3\"><strong>Penjelasan</strong></td>
						  </tr>
						  <tr bgcolor='#fffccc'>
						    <td width=\"10%\"><strong>Asal</strong></td>
						    <td width=\"10%\"><strong>Tanggal</strong></td>
						    <td width=\"20%\"><strong>Pertanyaan</strong></td>
						    <td width=\"10%\"><strong>Sumber</strong></td>
						    <td width=\"10%\"><strong>Tanggal</strong></td>
						    <td width=\"20%\"><strong>Uraian</strong></td>
						  </tr>

					  </tr>";	
				
				echo "<tr>
							<td colspan='7' align='center'>Tidak ditemukan data tanya jawab</td>
					     </tr>";		
				echo "</table>";
			}

		}else{
			$qry=mysqli_query($mysqli,"SELECT * FROM qa WHERE status='Y' ORDER BY id ASC");
			if(mysqli_num_rows($qry)>0){
			
				$no=1;
				
				echo "<table width='100%' align='center' cellpadding='0' cellspacing='0' border='1' bgcolor='#C4D9FF'>";
				echo "<tr bgcolor='#fffccc'>
						<tr bgcolor='#fffccc'>
						    <td width=\"5%\" rowspan=\"2\"><strong>No</strong></td>
						    <td colspan=\"3\"><strong>Pengirim</strong></td>
						    <td colspan=\"3\"><strong>Penjelasan</strong></td>
						  </tr>
						  <tr bgcolor='#fffccc'>
						    <td width=\"10%\"><strong>Asal</strong></td>
						    <td width=\"10%\"><strong>Tanggal</strong></td>
						    <td width=\"20%\"><strong>Pertanyaan</strong></td>
						    <td width=\"10%\"><strong>Sumber</strong></td>
						    <td width=\"10%\"><strong>Tanggal</strong></td>
						    <td width=\"20%\"><strong>Uraian</strong></td>
						  </tr>

					  </tr>";	

				while($data=mysqli_fetch_array($qry)){
					if($data[tanggal_jawab]=="0000-00-00"){
						$tgljawab="";
					}else{
						$tgljawab=$data["tanggal_jawab"];
					}
					echo "<tr bgcolor=\"#fffcfc\">
							<td align=\"center\" valign=\"top\">$no</td>
							<td valign=\"top\">$data[asal]</td>
							<td valign=\"top\">$data[tanggal_tanya]</td>
							<td valign=\"top\">$data[pertanyaan]</td>
							<td valign=\"top\">$data[sumber]</td>
							<td valign=\"top\">$tgljawab</td>
							<td valign=\"top\">$data[uraian]</td>
					     </tr>";
					$no++;  
				}
				
				echo "</table>";
			}else{
			
				echo "<table width='100%' align='center' cellpadding='0' cellspacing='0' border='1' bgcolor='#C4D9FF'>";
				echo "<tr bgcolor='#fffccc'>
						<tr bgcolor='#fffccc'>
						    <td width=\"5%\" rowspan=\"2\"><strong>No</strong></td>
						    <td colspan=\"3\"><strong>Pengirim</strong></td>
						    <td colspan=\"3\"><strong>Penjelasan</strong></td>
						  </tr>
						  <tr bgcolor='#fffccc'>
						    <td width=\"10%\"><strong>Asal</strong></td>
						    <td width=\"10%\"><strong>Tanggal</strong></td>
						    <td width=\"20%\"><strong>Pertanyaan</strong></td>
						    <td width=\"10%\"><strong>Sumber</strong></td>
						    <td width=\"10%\"><strong>Tanggal</strong></td>
						    <td width=\"20%\"><strong>Uraian</strong></td>
						  </tr>

					  </tr>";	
				
				echo "<tr>
							<td colspan='7' align='center'>Tidak ditemukan data tanya jawab</td>
					     </tr>";		
				echo "</table>";
			}
		}
	
		
	}

	
?>