<?php
if(count(get_included_files())==1) exit("Direct access not permitted.");
$mod = basename(__FILE__, '.php');
$page->tbCss($mod);
?>
<div class="box_daftarlayanan" align="center">
	<h2>DAFTAR LAYANAN</h2>
</div>
<div id="box_daftarlayanan_main" class="box_daftar_layanan_main">
<?php
$query="select t1.`id`,
			t1.`nama`,
			t1.`deskripsi`,
			t1.`keterangan`,
			t1.`idgambar`,
			t1.`idicon`,
			t1.`urutan`,
			t1.`status`,
			t2.nama_baru as namagambar,
			t2.folder as foldergambar,
			t3.nama_baru as namaicon,
			t3.folder as foldericon
		from tb_layanan as t1
		inner join tb_dokumen as t2 on t1.idgambar=t2.id
		inner join tb_dokumen as t3 on t1.idicon=t3.id
		where t1.id>0 order by t1.urutan asc";
$rslayanan=$db->loadAll($query);

$jumlahbaris=ceil((float) sizeof($rslayanan)/2);

$pos=0;
for($i=0;$i<$jumlahbaris;$i++){
	?>
	<div class='box_daftar_layanan_main_baris'>
	<?php
	for($n=0;$n<3;$n++){
		if($pos<sizeof($rslayanan)){
			$deskripsi=$rslayanan[$pos]['deskripsi'];
	
			if(strlen($deskripsi)>170) {
				$strdeskripsi=mb_strimwidth($deskripsi, 0, 170, '');
				$deskripsi = substr($strdeskripsi,0,strrpos($strdeskripsi," "))." ...";
			}
			?>
			<a href="<?php echo NPAGE.'layanan?id='.$rslayanan[$pos]['id'];?>">
			<div class='box_daftar_layanan_main_kotak'>
				<div class="daftar_layanan_main_baris_boxgb"><img src="<?php echo NPAGE.$rslayanan[$pos]['foldergambar'].$rslayanan[$pos]['namagambar'];?>"/></div>
					
				<div class='layanan_main_boxisi_main'>
					<div class='layanan_main_boxicon'><img src='<?php echo NPAGE.$rslayanan[$pos]['foldericon'].$rslayanan[$pos]['namaicon'];?>'/></div>
					<div class='layanan_main_boxdata'>
					<div class='layanan_main_boxdata_judul'><?php echo $rslayanan[$pos]['nama'];?></div>
					<div class='layanan_main_boxdata_des'><?php echo $deskripsi;?></div>
					</div>"
					<div style='clear:both;'></div>
				</div>
			</div>
			</a>
			<?php
		}
		$pos++;
	}
	?>
	</div>
	<div style="clear: both;"></div>
	<?php
}
?>
</div>
<div style="clear: both;"></div>
<br />