<?php foreach($kontak as $kontak) :   endforeach; ?>
<?php foreach($admin_login as $user) :   endforeach; ?> 
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark"> 
                 <?php echo $title1; ?> <?php $no=1; foreach($member as $rowss) : echo $rowss->nama_member;   $no++; endforeach; ?>
            </h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item active"><?php echo $title1; ?></li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
      
          
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
          <div class="card">
              <div class="card-header">
               Total Point Saat Ini : <?php $no=1; foreach($member as $rowss) : echo $rowss->point;   $no++; endforeach; ?>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
               <table id="example1" class="table table-bordered table-striped">
                  <thead>
                    <tr>
                      <th>No</th>
                      <th>Date</th>
                      <th>ID Struk</th>
                      <th>Status</th>
                      <th width="130">Tambahan</th>
                      <th width="130">Potongan</th>
                      <th></th>
                    
                      
                    </tr>
                  </thead>
                  <tbody>
                    <?php $no=1; foreach($tampil as $rows) : ?> 
                    <tr>
                      <td><?php echo $no; ?></td>
                     
                      <td style="text-align: right;"><?php echo $rows->date; ?>
                         
                      </td> 
                      <td style="text-align: left;"><?php echo $rows->id_transaksi; ?>
                         
                      </td> 
                      <td style="text-align: left;"><?php echo $rows->status; ?>
                         
                      </td> 
                      <td style="text-align: right;">

                        <?php $status=$rows->status; if($status=='tambahan') { echo $rows->point; } ?>
                         
                      </td>
                      <td style="text-align: right;">
                         <?php $status=$rows->status; if($status=='potongan' or $status=='potongan-retur') { echo $rows->point; } ?>
                       
                      </td>
                      <td></td>
                     
                       
                    </tr>
                    <?php $no++; endforeach; ?>


                  </tbody>
                  <footer>
                    <tr>
                      <td></td>
                      <td></td>
                      <td></td>
                      <td>Total</td>
                      <td style="text-align: right;"><?php 
                          $ktp2= $this->input->post('ktp');
                        $sql_menu = " select SUM(tb_history_point_member.point) AS
                           total_tambahan from tb_member, tb_history_point_member where
                            tb_history_point_member.id_member = tb_member.id_member AND
                             tb_member.ktp = '$ktp2'  
                          AND  tb_history_point_member.status = 'tambahan'   ";
                            $main_menu = $this->db->query($sql_menu)->result();
                            foreach ($main_menu as $data) {
                           echo $tambahan=$data->total_tambahan;
                            }
                        
                        ?>     </td>
                     <td style="text-align: right;"><?php 
                          $ktp3= $this->input->post('ktp');
                        $sql_menu = " select SUM(tb_history_point_member.point) AS
                           total_potongan from tb_member, tb_history_point_member where
                            tb_history_point_member.id_member = tb_member.id_member AND
                             tb_member.ktp = '$ktp3'  
                          AND  tb_history_point_member.status = 'potongan'   ";
                            $main_menu = $this->db->query($sql_menu)->result();
                            foreach ($main_menu as $dataq) {
                             $potongan1=$dataq->total_potongan;
                            }
                        
                        ?>  
                        <?php 
                          $ktp4= $this->input->post('ktp');
                        $sql_menu = " select SUM(tb_history_point_member.point) AS
                           total_potongan from tb_member, tb_history_point_member where
                            tb_history_point_member.id_member = tb_member.id_member AND
                             tb_member.ktp = '$ktp4'  
                          AND  tb_history_point_member.status = 'potongan-retur'  ";
                            $main_menu = $this->db->query($sql_menu)->result();
                            foreach ($main_menu as $dataw) {
                             $potongan2=$dataw->total_potongan;

                            echo $potongan= $potongan1+ $potongan2;
                            }
                        
                        ?>    </td>
                        <td style="text-align: right;"><?php echo $t= $tambahan - $potongan ; ?></td>

                    </tr>
                  </footer>

                </table>
              </div>
              <!-- /.card-body -->
            </div>
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

   