<?php //print_r($usertype);exit; ?>
    <section class="content-header">
      <h1>
        Upcoming Membership Payments
      </h1>
      <ol class="breadcrumb">
        <li><a href="<?php echo base_url().'admin';?>"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">List</li>
      </ol>
    </section>

    <section class="content">
      <div class="row">
        <?php echo $this->utility->showMsg();?>
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">Management</h3>
              
              </div>
               
              <div></div>
            <!-- /.box-header -->
            <div class="box-body">
			<form action="" method="post">
				<div class="form-group">
                  <div class="row">
                   <div class="col-sm-4">
                      <label class="col-sm-4 control-label">From Date</label>

                      <div class="col-sm-8">
                          <input type="text" name="fromDate" id="fromDate" value="<?php if($this->input->post('fromDate')){ echo date('Y/m/d', strtotime($this->input->post('fromDate'))); }?>">

                      </div>
                   </div>
                   <div class="col-sm-4">
                      <label class="col-sm-4 control-label">To Date</label>

                      <div class="col-sm-8">
                          <input type="text" name="toDate" id="toDate" value="<?php if($this->input->post('toDate')){ echo date('Y/m/d', strtotime($this->input->post('toDate'))); }?>">
                      </div>
                   </div>
				   <div class="col-sm-4">
                      <div class="col-sm-8">
                          <input type="submit" class="btn btn-black " value="Search" id="add">
                      </div>
                   </div>
                  </div>
                </div>
			</form>
      <a target="_blank" href="<?php echo base_url().'admin/order/download_upcoming/'; ?>"><input type="button" class="btn btn-info" value="Download Upcoming Membership Invoice" id="download"></a>
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>#</th>
                  <th>Order No.</th>
                  <th>Order Date</th>
				  <th>Payment Date</th>
                  <th>Cart Value(&euro;)</th>
                  <th>Total(&euro;)</th>
                  <th>Payment Method</th>
                  <th>Members mail</th>
				  <th>CC Ref ID</th>
				  
                </tr>
                </thead>
                 <?php if(count($orders)>0)
                {?>
                <tbody>
               <?php
                $i=1;
				$total = 0; 
                foreach ($orders as $data) 
                {
                ?>
                <tr>
                    <td><?php echo $i;?></td>
                    <td><?php echo $data['order_id_masked']; ?></td>
                    <td><?php echo date('Y-m-d',$data['created']); ?></td>
					<td><?php if($data['time']==182){ echo date('Y-m-d',($data['created']+(182*86400)));} else{ echo date('Y-m-d',($data['created']+(365*86400))); } ?></td>
                    <td><?php echo number_format($data['total_base']/100,2,',','.'); ?></td>
                    <td><?php echo number_format($data['total_sum']/100,2,',','.');  ?></td>
                    <td><?php if($data['payment_method_id']==12){ echo 'Bank Transfer'; } elseif($data['payment_method_id']==13){ echo 'Saferpay'; } elseif($data['payment_method_id']==14){ echo 'Stripe'; } else{ echo 'Pay by cash'; } ?></td>
                    <td><?php echo $data['email']; ?></td>
					<td><?php if($data['payment_method_id']==13){ echo $data['cc_ref_id']; } ?></td>
				</tr>

               <?php $i++; $total = $total+$data['total_sum']; } ?>

                </tbody>
                <?php } ?>
                <tfoot>
               
                </tfoot>
              </table>
			  Total Upcoming Membership Payment Amount : <?php echo number_format($total/100,2,',','.'); ?> &euro;
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    

    
<script>
  $(function () {
    $("#example1").DataTable();
  });
  
	$("#fromDate").datetimepicker();
	$("#toDate").datetimepicker({
	  //minDate: $("#fromDate").val(),
	});
</script>