<div class="table-responsive mt-3 mb-4 px-3">
	<table class="table table-bordered">
		<thead class="table-light">
			<tr>
				<th style="width: 200px">Tanggal</th>
				<th>Aktivitas</th>
			</tr>
		</thead>
		<tbody>
			<?php 
				$start      = $input['start'];
				$end       	= $input['end'];
				$limit      = $input['limit'];
				$active     = $input['active'];
				$admin      = $this -> session -> mart_id;

				if(!empty($start) AND !empty($end)) {
					$this -> db -> where('DATE(tgl) >=', $start);
					$this -> db -> where('DATE(tgl) <=', $end);
				}

				$this -> db -> where('id_admin', $admin);
				$total_data = $this -> db -> get('aktivitas') -> num_rows();
				$offset     = $limit * ($active - 1);
				$max_page   = ceil(($total_data / $limit) + 1);

				$pagination = [
					'active'     => $active,
					'max_page'   => $max_page,
				];

				if(!empty($start) AND !empty($end)) {
					$this -> db -> where('DATE(tgl) >=', $start);
					$this -> db -> where('DATE(tgl) <=', $end);
				}

				$this -> db -> limit($limit, $offset);
				$this -> db -> order_by('id', 'DESC');
				$this -> db -> where('id_admin', $admin);
				$data = $this -> db -> get('aktivitas') -> result();

				if($data) :
					foreach($data as $item) :
			?>

				<tr>
					<td>
						<?= date('d M Y H:i', strtotime($item -> tgl)) ?> WIB
					</td>
					<td>
						<?= $item -> keterangan ?>
					</td>
				</tr>
				
			<?php endforeach ?>
			<?php endif ?>
  
            <?php if(count($data) == 0) : ?>  
                    <tr>
                        <td colspan="2">
                            <div class="text-center">
                                Belum ada aktivitas
                            </div>
                        </td>
                    </tr>       
            <?php endif ?>
		</tbody>
	</table>
</div>

<?= $this -> app -> pagination($pagination) ?>