 <?php 
use App\Models\MainpageModel;
$home = new MainpageModel();
 ?>
 <div class="content-wrapper">
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark">All Donation</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
              <li class="breadcrumb-item"><a href="#">Report</a></li>
              <li class="breadcrumb-item active">All Donation</li>

            </ol>
          </div>
        </div>
      </div>
    </div>
    <section class="content">
      <div class="container-fluid">
        <div class="card card-default">
          <div class="card-header">
           <form method="GET" action=
            "">
                <div class="container">
                  <div class="row">
                    <div class="col-sm-4">
                       <div class="form-group">
                        <label class="" for="from_date">Start Date &nbsp;&nbsp;&nbsp;</label>
                        <input required="" type="date" name="start_date" class="form-control datepicker" id="from_date">
                      </div>
                    </div> 

                   
                    <div class="col-sm-4">
                      <div class="form-group end_date">
                          <label class="" for="to_date">End Date &nbsp;&nbsp;&nbsp;</label>
                          <input required=""  type="date" name="end_date" class="form-control datepicker" id="to_date" >
                      </div>
                    </div>
                    <div class="col-sm-3">
                     <label style="color: #fff;">s</label>
                      <div class="form-group end_date">
                           
                          <button style="float: right;" type="submit" class="btn btn-success">Search</button>
                      </div>
                    </div>
                  </div>
                </div>  
              
            <?php echo form_close()?>
          </div>
        </div><!--/. container-fluid -->
    </section>
    <section class="content">
      <div class="container-fluid">
        <div class="card card-default">
          <div class="card-header">
            <h3 class="card-title">View All Donation</h3>
          </div>
            <div class="card-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>id</th>
                  <th>Name</th>
                  <th>Address & Contact Info</th>
                  <th>Project</th>
                  <th>Amount</th>
                  <th>Transaction Details</th>
                  <th></th>
                </tr>
                </thead>
                <tbody>
                <?php $i=1; 
                $ttl_commission = 0;
                foreach ($all_report as $key => $report):
                $ttl_commission += $report->donation_amount;
                $project = $home->get_all_featured_project_by_id($report->donation_project_id);
                ?>
                <tr>
                  <td><?php echo $i ?></td>
                  <td>
                    <?php echo $report->donation_name ?>
                    <?php if($report->donation_status == 1 && $report->donation_amount > 10000): ?>
                      <br/>
                      <span class="badge badge-success">Elite Dono</span>
                    <?php endif; ?>
                  </td>
                  <td><?php echo $report->donation_address ?>, <?php echo $report->donation_area ?>, <?php echo $report->donation_dist ?>, <?php echo $report->donation_state ?> - <?php echo $report->donation_pin ?>
                    <br/>
                     Mob : <b><?php echo $report->donation_mobile ?></b>
                    <?php if($report->donation_email): ?>
                      <br/>
                      Email : <b><?php echo $report->donation_email ?></b>
                    <?php endif; ?>
                  </td>
                  <td><?php echo $project->project_title ?></td>
                  <td><i style="font-size:12px" class="fa fa-rupee-sign"></i> <b><?php echo $report->donation_amount ?></b></td>
                  
                  <td>
                    Date : <b><?php echo date('d-m-Y', strtotime($report->donation_date)) ?></b>
                    <br/>
                    Name in Acc : <b><?php echo $report->donation_name_in_acc ?></b>
                    <br/>
                    Transaction ID : <b><?php echo $report->donation_pay_id ?></b>
                    <br/>
                     Payment Type : <b>
                      <?php if($report->donation_payment_type == 1): ?>
                        One Time
                      <?php else: ?>
                        Monthly 
                      <?php endif;?>
                     </b>
                     <?php if($report->d_eight_g_form == 1): ?>
                      <br/>
                      8G Form : <b>Yes</b>
                      <br/>
                      PAN : <b><?php echo $report->d_pan_card ?></b>
                    <?php else: ?>
                      <br/>
                      8G Form : <b>No</b>
                    <?php endif;?>
                  </td>

                  <td>
                    <?php if($report->donation_status == 0): ?>
                    <a href="<?php echo base_url(); ?>/admin/report/approve_donation/<?php echo $report->donation_id ?>" class="btn btn-success btn-xs"><i class="fa fa-check"></i></a>
                    <br/>
                    <a href="<?php echo base_url(); ?>/admin/report/delete_donation/<?php echo $report->donation_id ?>" onclick="return confirm('Are you sure you want to delete this Donation?')" class="btn btn-danger btn-xs"><i class="fa fa-close"></i></a>
                    <?php else: ?>
                      <span class="badge badge-success">Approved</span>
                    <?php endif;?>
                  </td>
                </tr>
                <?php $i++; ?>
                <?php endforeach; ?>
                </tbody>
                <tfoot>
                  <tr>
                    <td colspan="4"><strong>Total</strong></td>
                    <td ><i style="font-size:12px" class="fa fa-rupee-sign"></i> <b><?php echo $ttl_commission; ?></b></td>
                    <td colspan="2"></td>
                  </tr>
                </tfoot>
              </table>
            </div>
          </div>
      </div>
    </section>
  </div>