<!DOCTYPE html>
<!--
This is a starter template page. Use this page to start your new project from
scratch. This page gets rid of all links and provides the needed markup only.
-->
<?php foreach($kontak as $kontak) :   endforeach; ?> 
 
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="x-ua-compatible" content="ie=edge">

  <title>Laporan Buku Kas</title>
  <!-- DataTables -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <!-- SweetAlert2 -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css">
  <!-- Toastr -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/toastr/toastr.min.css">
  <link rel="icon" href="<?php echo base_url();?>images/kontak/<?php echo $kontak->logo ;?>" type="image/png" /> 
  <!-- Font Awesome Icons -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/plugins/fontawesome-free/css/all.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/dist/css/adminlte.min.css">
  <!-- Google Font: Source Sans Pro -->
  
</head>
<body class="hold-transition sidebar-collapse layout-top-nav"  >
<div class="wrapper">

   

 

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
       
      
      
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <div class="content">

        <div class="row">
          <div class="col-lg-12">
            <div class="card card-success card-outline">
              <div class="card-body">
                <div class="row">
                  <div class="col-lg-12">
                    
                    <h2>LAPORAN BUKU KAS </h2>
                    
                    <h5>LAPORAN <?php echo  ucwords($jenis_laporan).", " ;?>  <?php if($jenis_laporan =='harian'){
                      echo "Tanggal : ".$tanggal;
                    }else if($jenis_laporan =='bulanan'){
                      echo "Bulan : ".bulan_cetak(date($bulan))." Tahun ".$tahun;
                    } else if($jenis_laporan =='pilihan'){
                      echo "Tanggal : ".tgl_indo(date($tanggal_awal))." s/d ".tgl_indo(date($tanggal_akhir));

                    } else if($jenis_laporan =='kasir'){
                        $username = $this->session->userdata("username");  
                        $this->db->where('username',$username);
                        $query = $this->db->get('tb_admin');
                        $row = $query->row();
                       
                        $nama_admin = $row->nama_admin;
                      echo "Tanggal : ".tgl_indo(date($tanggal))." , Kasir : ".$nama_admin;

                    } 
                    ?> </h5>
                       
                  </div>
                </div><!-- /.row -->
                <table  class="table table-bordered ">
                  <thead>
                    <tr style="background-color: #bddb8e ">
                      <th>No</th>
                      
                      <th>Date</th>
                     
                      <th>Petugas</th>
                      <th >Keterangan</th>
                      <th style="text-align: right;">Pemasukan </th>
                      <th style="text-align: right;">Pengeluaran</th>
                      
                    </tr>
                  </thead>
                  <tbody>

                    <?php $no=1; foreach($bukukas as $rows) : ?> 
                    <tr>
                      <td><?php echo $no; ?></td>

                       <td><?php echo tgl_indo($rows->date); ?></td>
                      <td> 
                        <?php 
                        $id_admin = $rows->id_admin; 
                        $sql_menu = "SELECT * FROM tb_admin WHERE  id = '$id_admin' ";
                        $main_menu = $this->db->query($sql_menu)->result();
                        foreach ($main_menu as $maink) {
                          echo  $maink->nama_admin;

                        }
                        ?>
                      </td>
                      <td><?php echo $rows->keterangan;  ?></td>
                      <td style="text-align: right"><?php if($rows->jenis == 'pemasukan'){ echo nominal($rows->nominal); }else{ echo "-"; } ?></td> 
                      <td style="text-align: right"><?php if($rows->jenis == 'pengeluaran'){ echo nominal($rows->nominal); }else{ echo "-"; } ?></td>


                       


                   
                  </tr>
                  
                  <?php $no++; endforeach; ?>

               
                
                     <?php
 

                     if($jenis_laporan =='harian'){

                       $query1 = $this->db->query("SELECT SUM(nominal) as pemasukan FROM tb_bukukas where jenis='pemasukan' and   date(tb_bukukas.date) = '$tanggal'  "); 
                       $row1 = $query1->row_array();
                       $pemasukan = $row1['pemasukan'];
                       $query2 = $this->db->query("SELECT SUM(nominal) as pengeluaran FROM tb_bukukas where jenis='pengeluaran' and   date(tb_bukukas.date) = '$tanggal'  "); 
                       $row2 = $query2->row_array();
                       $pengeluaran = $row2['pengeluaran'];




                     }else  if($jenis_laporan =='bulanan'){
                        $query1 = $this->db->query("SELECT SUM(nominal) as pemasukan FROM tb_bukukas where jenis='pemasukan' and month(tb_bukukas.date)='$bulan' and year(tb_bukukas.date) ='$tahun'    "); 
                        $row1 = $query1->row_array();
                        $pemasukan = $row1['pemasukan'];
                        $query2 = $this->db->query("SELECT SUM(nominal) as pengeluaran FROM tb_bukukas where jenis='pengeluaran' and month(tb_bukukas.date)='$bulan' and year(tb_bukukas.date) ='$tahun'  "); 
                        $row2 = $query2->row_array();
                        $pengeluaran = $row2['pengeluaran'];


                    }else  if($jenis_laporan =='pilihan'){

                          if($id_admin == 'all'){
                           $query1 = $this->db->query("SELECT SUM(nominal) as pemasukan FROM tb_bukukas where jenis='pemasukan' and tb_bukukas.date BETWEEN '$tanggal_awal' AND '$tanggal_akhir'    "); 
                           $row1 = $query1->row_array();
                           $pemasukan = $row1['pemasukan'];
                           $query2 = $this->db->query("SELECT SUM(nominal) as pengeluaran FROM tb_bukukas where jenis='pengeluaran' and tb_bukukas.date BETWEEN '$tanggal_awal' AND '$tanggal_akhir'  "); 
                           $row2 = $query2->row_array();
                           $pengeluaran = $row2['pengeluaran'];


                         }else{
                           $query1 = $this->db->query("SELECT SUM(nominal) as pemasukan FROM tb_bukukas where jenis='pemasukan' and tb_bukukas.date BETWEEN '$tanggal_awal' AND '$tanggal_akhir'   and tb_bukukas.id_admin ='$id_admin' "); 
                           $row1 = $query1->row_array();
                           $pemasukan = $row1['pemasukan'];
                           $query2 = $this->db->query("SELECT SUM(nominal) as pengeluaran FROM tb_bukukas where jenis='pengeluaran' and tb_bukukas.date BETWEEN '$tanggal_awal' AND '$tanggal_akhir' and tb_bukukas.id_admin ='$id_admin' "); 
                           $row2 = $query2->row_array();
                           $pengeluaran = $row2['pengeluaran'];

                           }
 

                    }

                     // $query1 = $this->db->query("SELECT SUM(nominal) as pemasukan FROM tb_bukukas where jenis='pemasukan' and month(tb_bukukas.date)='$bulan' and year(tb_bukukas.date) ='$tahun' "); 
                     // $row1 = $query1->row_array();
                     // $pemasukan = $row1['pemasukan'];
                     // $query2 = $this->db->query("SELECT SUM(nominal) as pengeluaran FROM tb_bukukas where jenis='pengeluaran' and month(tb_bukukas.date)='$bulan' and year(tb_bukukas.date) ='$tahun' "); 
                     // $row2 = $query2->row_array();
                     // $pengeluaran = $row2['pengeluaran'];
                     ?>
                    <tr>
                      <td colspan="4">Total</td>
                      <td style="text-align: right"><strong><?php echo nominal($pemasukan);?></strong></td>
                      <td style="text-align: right"><strong><?php echo nominal($pengeluaran);?></strong></td>
                    </tr>
                    <tr>
                      <td colspan="3">Saldo</td>
                      <td style="text-align: right" colspan="2"> </td>
                      <td style="text-align: right"><strong><?php echo nominal($pemasukan - $pengeluaran);?></strong></td>
                    </tr>

                   </tbody>
                  

              </table>
 
              <hr>
             
              <div class="row">
                <div class="col-lg-12">
                  <table width="100%" border="0">
                    <tr>

                      <td >Mangetahui,</td>
                      <td width="400px;"  ></td>
                      <td ><?php echo $kontak->kab_kota ; ?>, <?php echo tgl_indo(date('Y-m-d'));  ?></td>
                    </tr>
                    <tr>
                      <td>Manager </td>
                      <td width="400px;"></td>
                      <td>Admin</td>
                    </tr>
                    <tr height="70px;">
                      <td></td>
                      <td></td>
                      <td></td>
                    </tr>
                    <tr>
                      <td> (............................) </td>
                      <td width="400px;"></td>
                      <td><strong><?php echo $nama_admin; ?></strong></td>
                    </tr>
                  </table>

                </div><!-- /.row -->
              </div>
            </div>

             
          </div>
          <!-- /.col-md-6 -->
          
          <!-- /.col-md-6 -->
        </div>
        <!-- /.row -->
      
    </div>
   
  </div>
  <!-- /.content-wrapper -->

   
 




 
<!-- jQuery -->
<script src="<?php echo base_url();?>assets/plugins/jquery/jquery.min.js"></script>
<script src="<?php echo base_url().'assets/js/jquery.js'?>"></script>
<script src="<?php echo base_url().'assets/js/numeral.min.js'?>"></script>
<!-- Bootstrap 4 -->
<script src="<?php echo base_url();?>assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE App -->
<script src="<?php echo base_url();?>assets/dist/js/adminlte.min.js"></script>
 
<!-- DataTables -->
<script src="<?php echo base_url();?>assets/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url();?>assets/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="<?php echo base_url();?>assets/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="<?php echo base_url();?>assets/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
 
<!-- AdminLTE for demo purposes -->
<script src="<?php echo base_url();?>assets/dist/js/demo.js"></script>
 
</body>
</html>
