<body class="wrap-all-content">

    <!-- <div class="se-pre-con"></div> -->
    <!-- Main -->
    <main role="main" class="container with-navbar" style="padding:0px 0px 0px 0px; max-width: 480px !important;">
        <!-- Content -->
        
<nav class="container navbar fixed-top navbar-default p-0 title benihbaik_solid" style="max-width: 480px;">
    <div class="nav-wrapper">
        <div class="navbar-text title-navbar box-nav">
            <a href="/" class="navbar-text back">
                <i class="fa fa-arrow-left" style="color:#828282;"></i>
            </a>
            <span class="title-nav"><?php echo $vkategori; ?></span>
        </div>
    </div>
</nav>

<div class="main-wrapper">
    <div style="padding: 70px 0px 40px 0px;">
                    <?php if($panggilan) { ?>
        <div class="box-wrap pb-3">
                <h1 class="title-box">Panggilan Mendesak</h1>
                <div class="wrapper-campaign" id="camp-category">
                    <?php foreach($panggilan as $mendesak): ?>
                        <?php 
$batas_galang_dana_date = new DateTime($mendesak['gd_tgl_selesai']);
$tanggal_sekarang = new DateTime();
$interval = $tanggal_sekarang->diff($batas_galang_dana_date);
$jumlah_hari = $interval->days;
 ?>
 <?php 
$terkumpul = 0;

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

if ($query->row()->terkumpul > 0) {
    $terkumpul = $query->row()->terkumpul;
}
 ?>
                <?php if($terkumpul == 0) { ?>
                <?php }else { ?>
                <?php $progres = $mendesak['gd_dana'] / $terkumpul; ?>
                <?php $progres1 = 100 / $progres; ?>
                <?php } ?>
                            <div class="card-camp">
                                <div class="card-header-camp p-0">
                                    <img class="thumb" src="assets/home/img/<?php echo $mendesak['gd_foto']; ?>" alt="camp" onerror="this.onerror=null;this.src='https://m.benihbaik.com/img/image_sementara/image-not-found.png';">
                                </div>
                                <div class="card-body-camp">
                                    <div class="category"> <?php echo $vkategori; ?></div>
                                        <h2 class="camp-title"><?php echo $mendesak['gd_judul']; ?></h2>
                                        <div class="desc">
                                            <?php echo word_limiter($mendesak['gd_isi'],13); ?>
                                        </div>
                                        <div class="box-total">
                                            <span class="text-reg">Dana terkumpul</span>
                                            <span class="nominal">Rp <?php echo number_format($terkumpul,0,',','.'); ?></span>
                                        </div>

                                        <div class="box-progress" style="height: 10px;">
                                            <span style="width:<?php echo round($progres1); ?>%;">
                                            <span class="progress"></span></span>
                                        </div>

                                        <div class="box-ld-target">
                                            <span class="left-day">
                                                <i class="far fa-clock"></i> <?php if($batas_galang_dana_date < $tanggal_sekarang) { ?>
                    <?php }else { ?>
                        <?php echo $jumlah_hari; ?> hari lagi
                    <?php } ?>
                                            </span>
                                            <span class="target">
                                                Dari Rp <?php echo number_format($mendesak['gd_dana'],0,',','.'); ?>
                                            </span>  
                                        </div>

                                        <a href="donasi/<?php echo $mendesak['gd_url']; ?>" class="donasi">
                                            Donasi
                                        </a>
                                </div>

                            </div>
                        <?php endforeach; ?>
                    </div>
            </div>
                        <?php }else { ?>
                        <?php } ?>
            
                            <div class="space"></div>
            
            <div class="space"></div>
            <div class="box-wrap pt-2">
                <h1 class="title-box" style="margin: 0px">Pilihan Campaign</h1>
                <div class="wrapper-list-camp" id="list_campaign">
                    <?php foreach($galang as $gal): ?>
                        <?php 
$batas_galang_dana_date = new DateTime($gal['gd_tgl_selesai']);
$tanggal_sekarang = new DateTime();
$interval = $tanggal_sekarang->diff($batas_galang_dana_date);
$jumlah_hari = $interval->days;
 ?>
 <?php 
$terkumpul = 0;

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

if ($query->row()->terkumpul > 0) {
    $terkumpul = $query->row()->terkumpul;
}
 ?>
                <?php if($terkumpul == 0) { ?>
                <?php }else { ?>
                <?php $progres = $gal['gd_dana'] / $terkumpul; ?>
                <?php $progres1 = 100 / $progres; ?>
                <?php } ?>
                <a class="item-list" href="donasi/<?php echo $gal['gd_url']; ?>">
        <img class="thumb-list" src="assets/home/img/<?php echo $gal['gd_foto']; ?>" alt="thumb-list" onerror="this.onerror=null;this.src='https://m.benihbaik.com/img/image_sementara/image-not-found.png';">
        <div class="info-camp">
            <h3 class="title-list-camp"><?php echo $gal['gd_judul']; ?></h3> 
            <p class="user"><?php echo $profil['nama']; ?> <span class="verif"><i class="fa fa-check" aria-hidden="true"></i></span> </p>
            <div class="box-progress progress-list-camp">
                <span style="width:<?php echo round($progres1); ?>%;"><span class="progress"></span></span>
            </div>
            <div class="collected-text">Dana terkumpul</div>
            <div class="collected">
                <span class="nominal-list">Rp <?php echo number_format($terkumpul,0,',','.'); ?></span>             
                <span class="left-day-list"><?php if($batas_galang_dana_date < $tanggal_sekarang) { ?>
                    <?php }else { ?>
                        <?php echo $jumlah_hari; ?> hari lagi
                    <?php } ?></span> 
            </div>
        </div>
    </a>
<?php endforeach; ?>
    </div>
            </div>
        </div>
    </div>

</div>

        <!-- Content -->
    </main>
    <!-- Main -->