<?php
if(count(get_included_files())==1) exit("Direct access not permitted.");
$mod = basename(__FILE__, '.php');
$page->tbCss($mod);
$page->tbJs($mod);
?>
<div class="box_main_agenda">
	<a href="<?php echo NPAGE.'agenda';?>">
		<h2>INFO AGENDA</h2>
	</a>
	<?php
	$halaman=1;
	$jumlahbaris=10;
	if(isset($_GET['page']) && $_GET['page']>0){
		$halaman=$_GET['page'];
	}
	$page->addLoad("daftaragenda.sethalaman(".$halaman.")");
	
	$posisihalaman=$halaman-1;
	
	$query="select SQL_CALC_FOUND_ROWS id,
		id,tanggal,judul,keterangan
		from tb_agenda where status=1 order by tanggal desc limit ?,? ";
	$rsagenda=$db->loadAll($query,array($posisihalaman,$jumlahbaris));
	
	$jumlahhalaman=1;
	$qrow="SELECT FOUND_ROWS() as totalbaris;";
	$rsrow=$db->loadAssoc($qrow);
	if(isset($rsrow['totalbaris'])){
		$jumlahhalaman=ceil($rsrow['totalbaris']/$jumlahbaris);
	}
	
	foreach ($rsagenda as $obj) {
		$haltgl=explode(" ", $db->halfdate($obj['tanggal']));
		$dd="";
		$mm="";
		$yy="";
		if(sizeof($haltgl)==3){
			$dd=$haltgl[0];
			$mm=$haltgl[1];
			$yy=$haltgl[2];
		}
		
		$arrtgl=explode(" ", $obj['tanggal']);
		$jam="";
		if(sizeof($arrtgl)==2){
			$jam=substr($arrtgl[1], 0,5);
		}
		?>
		<div class="box_mod_agenda">
			
			<div class="box_mod_agenda_judul">
				<div class="mod_agenda_tanggal">
					<div class="mod_agenda_tanggal_1"><?php echo $haltgl[0];?></div>
					<div class="mod_agenda_bulan"><?php echo $haltgl[1];?></div>
					<div><?php echo $haltgl[2];?></div>
					<div class="mod_agenda_tahun"><?php echo $jam;?></div>
				</div>
				<div class="mod_agenda_detail">
					<div class="mod_agenda_judul"><?php echo $obj['judul'];?></div>
					<div class="mod_agenda_keterangan">
						<?php 
						$string=mb_strimwidth((strip_tags($obj['keterangan'],"<p>")), 0, 330, '');
						$string = substr($string,0,strrpos($string," ")); 
						echo $string." ...";
						?>
					</div>
					<div style="clear: both;"></div>
					<a href="<?php echo NPAGE.'agenda?id='.$obj['id'];?>">
						<div class="tombol_agenda_detail">Detail Agenda</div>
					</a>
					<div style="clear: both;"></div>
				</div>
				<div style="clear: both;"></div>
			</div>
			
			
			
		</div>
		<?php
	}
	?>
	
</div>
<div class="box_halaman">
	Halaman: <select id="sl_halaman" onchange="daftaragenda.gantihalaman()">
		<?php
		for($i=0;$i<$jumlahhalaman;$i++){
			?>
			<option value="<?php echo ($i+1);?>"><?php echo ($i+1);?></option>
			<?php
		}
		?>
	</select>
</div>