<title>Bus</title>
<div id="pagetitle">BUS</div>
<div id="batascontent">
	<div id="tomboltambah">
		<a href="?m=bus_input" class="submitbutton">+ BUS</a>
	</div>
	<div id="tableres">
		<table width="100%" border="0" class="display" id="example">
			<thead>
				<tr>
					<th>NO</th>
					<th></th>
					<th></th>
					<th>BUS</th>
					<th>HEAD</th>
					<th>IMG</th>
					<th>TAGS</th>
					<th>VIEWS</th>
					<th>HITS</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
				<?php
					$nomor = 1;
					$db = mysqli_query($koneksi, "SELECT * FROM cmas_bus ORDER BY bus_status ASC, bus_id DESC");
					while($dt = mysqli_fetch_array($db)){
						
					if ($dt['bus_status'] == "Non-Aktif") {
						$bus_status = "<img src='assets/images/icons/icon_no.png' width='15' alt='$dt[bus_status]' title='$dt[bus_status]'>";
					} else {
						$bus_status = "<img src='assets/images/icons/icon_yes.png' width='15' alt='$dt[bus_status]' title='$dt[bus_status]'>";
					}
					
					if ($dt['bus_imageid'] == 0) {
						$bus_image = "<img src='assets/images/noimage.jpg' width='100' alt='$dt[bus_nama]' title='$dt[bus_nama]'>";
					} else {
						$bus_image = "<img src='assets/images/bus/$dt[bus_image]' width='100' alt='$dt[bus_nama]' title='$dt[bus_nama]'>";
					}
				?>
					<tr>
						<td align="center" width="1%">
							<?php echo $nomor; ?>
						</td>
						<td align="center" width="1%">
							<?php echo $bus_status; ?>
						</td>
						<td align="center" width="1%">
							<a href="?m=bus_edit&id=<?php echo $dt['bus_id']; ?>">
								<?php echo $bus_image; ?>
							</a>
						</td>
						<td>
							<a href="?m=bus_edit&id=<?php echo $dt['bus_id']; ?>">
								<?php echo $dt['bus_nama']; ?>
							</a>
						</td>
						<td width="1%">
							<?php if ($dt['bus_headerid'] == 0) { ?>
								<a href="?m=bushead_edit&id=<?php echo $dt['bus_id']; ?>">
									<img src="assets/images/icons/icon_adds.png" width="20" title="Tambah Header">
								</a>
							<?php } else { ?>
								<a href="?m=bushead_edit&id=<?php echo $dt['bus_id']; ?>">
									<img src="assets/images/icons/icon_edits.png" width="20" title="Edit Header">
								</a>
							<?php } ?>
						</td>
						<td align="center" width="1%">
							<?php
								$tdb = mysqli_query($koneksi, "SELECT * FROM cmas_busimg WHERE bus_id='$dt[bus_id]'");
								if (mysqli_num_rows($tdb) < 1) {
							?>
								<a href="?m=busimg_input&id=<?php echo $dt['bus_id']; ?>">
									<img src="assets/images/icons/icon_adds.png" width="20" title="Tambah Images">
								</a>
							<?php } else { ?>
								<a href="?m=busimg_input&id=<?php echo $dt['bus_id']; ?>">
									<img src="assets/images/icons/icon_edits.png" width="20" title="Edit Images">
								</a>
							<?php } ?>
						</td>
						<td align="center" width="1%">
							<?php
								$tdb = mysqli_query($koneksi, "SELECT * FROM cmas_bustag WHERE bus_id='$dt[bus_id]'");
								if (mysqli_num_rows($tdb) < 1) {
							?>
								<a href="?m=bustag_input&id=<?php echo $dt['bus_id']; ?>">
									<img src="assets/images/icons/icon_adds.png" width="20" title="Tambah Tags">
								</a>
							<?php } else { ?>
								<a href="?m=bustag_input&id=<?php echo $dt['bus_id']; ?>">
									<img src="assets/images/icons/icon_edits.png" width="20" title="Edit Tags">
								</a>
							<?php } ?>
						</td>
						<td align="center" width="1%">
							<?php
								$vdb = mysqli_query($koneksi, "SELECT COUNT(loghits_ip) AS JumlahIP FROM cmas_loghits WHERE contentid='$dt[bus_id]'");
								$vdt = mysqli_fetch_array($vdb);
								echo $vdt['JumlahIP'];
							?>
						</td>
						<td align="center" width="1%">
							<?php
								$hdb = mysqli_query($koneksi, "SELECT SUM(loghits_hits) AS JumlahHits FROM cmas_loghits WHERE contentid='$dt[bus_id]'");
								$hdt = mysqli_fetch_array($hdb);
								echo $hdt['JumlahHits'];
							?>
						</td>
						<td align="center" width="5%">
							<a href="?m=bus_edit&id=<?php echo $dt['bus_id']; ?>" title="Edit">
								<img src="assets/images/icons/icon_edit.png" width="20">
							</a>
							<a href="?m=bus_hapus&id=<?php echo $dt['bus_id']; ?>" onclick="return confirm('DATA AKAN DIHAPUS, ANDA YAKIN?');">
								<img src="assets/images/icons/icon_delete.png" width="20">
							</a>
						</td>
					</tr>
				<?php $nomor++; } ?>
			</tbody>
		</table>
	</div>
</div>