<div class="content-header">
        <div>
          <h4 class="content-title"><?php echo $title; ?></h4>
        </div>
      </div><!-- content-header -->
      <div class="content-body">
      	<div class="mb-2">
      		<?php if($status == '') { ?>
			<a href="admin/laporan/galang-dana/excel" class="btn btn-primary">
				<i class="fas fa-file-excel"></i>
			</a>
			<a href="admin/laporan/galang-dana/print" class="btn btn-primary" target="_blank">
				<i class="fas fa-print"></i>
			</a>
			<?php }else { ?>
				<a href="admin/laporan/galang-dana/excel/<?php echo $status; ?>" class="btn btn-primary">
					<i class="fas fa-file-excel"></i>
				</a>
				<a href="admin/laporan/galang-dana/print/<?php echo $status; ?>"  class="btn btn-primary" target="_blank">
					<i class="fas fa-print"></i>
				</a>
			<?php } ?>
			<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
				<i class="fas fa-filter"></i>
			</a>
      	</div>
      	<div class="collapse mg-t-5" id="collapseExample">
		  <div class="card card-body">
		  	<form action="" method="post">
		  		<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
		  		<div class="row">
		  			<div class="form-group col-md-3">
		  				<label>Status</label>
		  				<select name="status" class="form-control form-control-sm" required="">
		  					<option value="">-Pilih-</option>
		  					<option value="0">Pending</option>
		  					<option value="1">Aktif</option>
		  					<option value="2">Selesai</option>
		  					<option value="3">Ditolak</option>
		  				</select>
		  			</div>
		  			<div class="form-group col-md-3">
		  				<button style="margin-top: 29px;" type="submit" class="btn btn-success btn-sm">Lihat</button>
		  			</div>
		  		</div>
		  	</form>
		  </div>
		</div>
      	<table id="myTable" class="table">
	        <thead>
	          <tr>
	          	<th class="wd-5p">No</th>
	          	<th>Tgl</th>
				<th>Foto</th>
				<th>Dibutuhkan</th>
				<th>Terkumpul</th>
				<th>Sisa</th>
				<th>Waktu</th>
				<th>Judul</th>
				<th>Status</th>
	          </tr>
	        </thead>
	        <tbody>
	        	<?php $i = 1; ?>
				<?php foreach($galang as $gdan): ?>
<?php 
$terkumpul = 0;

$this->db->select('donasi_gdid, SUM(donasi_jml) as terkumpul');
$this->db->where('donasi_status', 2);
$this->db->where('donasi_gdid', $gdan['gd_id']);
$query = $this->db->get('tb_donasi');

if ($query->row()->terkumpul > 0) {
    $terkumpul = $query->row()->terkumpul;
}
 ?>
<?php $sisa = $gdan['gd_dana'] - $terkumpul; ?>
				<tr>
					<td><?php echo $i; ?>.</td>	
					<td><?php echo date('d-m-Y', strtotime($gdan['gd_tgl'])); ?></td>
					<td><a href="assets/home/img/<?php echo $gdan['gd_foto']; ?>" target="_blank"><img src="assets/home/img/<?php echo $gdan['gd_foto']; ?>" alt="<?php echo $gdan['gd_foto']; ?>" width="50"></a></td>
					<td><?php echo number_format($gdan['gd_dana'],0,',','.'); ?></td>
					<td>
						<?php if($terkumpul == $gdan['gd_dana']) { ?>
							<span class="badge badge-success"><?php echo number_format($terkumpul,0,',','.'); ?></span>
						<?php }else { ?>
							<?php echo number_format($terkumpul,0,',','.'); ?>
						<?php } ?>
					</td>
					<td><?php echo number_format($sisa,0,',','.'); ?></td>
					<td><?php echo date('d-m-Y', strtotime($gdan['gd_tgl_selesai'])); ?></td>
					<td><?php echo $gdan['gd_judul']; ?></td>
					<td>
						<?php if($gdan['gd_status'] == 0) { ?>
							<span class="badge badge-warning">Pending</span>
						<?php }else if($gdan['gd_status'] == 1) { ?>
							<span class="badge badge-info">Aktif</span>
						<?php }else if($gdan['gd_status'] == 2) { ?>
							<span class="badge badge-success">Selesai</span>
						<?php }else { ?>
							<span class="badge badge-danger">Ditolak</span>
						<?php } ?>
					</td>
				</tr>
				<?php $i++; ?>
				<?php endforeach; ?>
	        </tbody>
	      </table>
      </div><!-- content-body -->