<?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; ?>
            </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">
								<div class="row">
	              	<div class="col-md-11">
	              		<form class="form-inline"   action="<?php echo base_url('transaksi'); ?>" method="POST" >
	              			<label>
	              				Tanggal awal &nbsp;:&nbsp;
	              			</label>
	              			<input type="date" name="tgl_awal" required="" class="form-control" placeholder="yyyy/mm/dd" />
	              			<label>
	              				&nbsp; Tanggal akhir &nbsp;:&nbsp;
	              			</label>
	              			<input  type="date" name="tgl_akhir" required="" class="form-control" placeholder="yyyy/mm/dd" />
	              			 
	              			<label>
                        &nbsp; Pilih Kantor &nbsp;:&nbsp;
                      </label>
                      <?php
                      $username = $this->session->userdata("username"); 
                      $this->db->where('username',$username);
                      $query = $this->db->get('tb_admin');
                      $row = $query->row();
                      $data['id_admin']= $row->id;
                      $data['nama_admin']= $row->nama_admin;
                      $data['id_kantor']= $row->id_kantor;
                      $id_admin2 = $row->id;
                      $level = $row->level;
                      $id_kantor2 = $row->id_kantor;

                      $this->db->where('id_kantor',$id_kantor2);
                      $query = $this->db->get('tb_kantor');
                      $rowss = $query->row();
                      $kantor= $rowss->nama_kantor;
                         ?>
                          <?php  
                            if($level =='manager' ){
                          ?> 
                      <select name="id_kantor" class="form-control">
                        
                        <option value="semua"  >semua</option>
                        <?php  foreach($kantor3 as $kantor3) : ?> 
                          <option value="<?php echo $kantor3->id_kantor; ?>"><?php echo $kantor3->nama_kantor; ?></option>
                        <?php   endforeach; ?>

                         
                      </select>
                       <?php }else{ ?>
                          
                        <select name="id_kantor" class="form-control">
                       
                        
                          <option value="<?php echo $id_kantor2; ?>"><?php echo $kantor; ?></option>
                         

                         
                      </select>

                        <?php

                       } ?>
                     
	              			<label>
	              				&nbsp; Pembayaran &nbsp;:&nbsp;
	              			</label>
	              			<select name="metode_bayar" class="form-control">
	              				<option value="semua"  >semua</option>
	              				<?php  foreach($metode as $metode) : ?> 
	              					<option value="<?php echo $metode->id_metode; ?>"><?php echo $metode->nama_metode; ?></option>
	              				<?php  	endforeach; ?>


	              			</select>
	              			&nbsp; <button  type="submit" class="btn btn-info btn-small">
	              				<i class="icon-search bigger-110"></i>
	              				Tampil
	              			</button>

	              		</form> 
	              	</div>  	
	              	<div class="col-md-1">
	              		&nbsp; <a href="<?php echo base_url('transaksi'); ?>"> <button    class="btn btn-warning btn-small">
	              			<i class="icon-search bigger-110"></i>
	              			Kembali
	              		</button></a>  
	                </div>     
                </div>                          
               

              </div>
              <!-- /.card-header -->
              <div class="card-body">
              	<table id="example1" class="table table-bordered table-striped">
              		<thead>
              			<tr>
              				<th>No</th>
              				<th>ID Transaksi</th>
              				<th>Kantor</th>
              				<th>Member</th>
              				<th style="text-align: right;">Sub Total</th>
              				<th style="text-align: right;">Potongan</th>
              				<th style="text-align: right;">Total</th>
              				<th>Bayar</th>
              				<th>Kembali</th>
              				<th>Status</th>
              				<th>Pembayaran</th>

              				<th>Kasir</th>
              				<th>Aksi</th>
              				
              			</tr>
              		</thead>
              		<tbody>
              			<?php $no=1; foreach($transaksi as $rows) : ?> 
              				<tr>
												<td><?php echo $no; ?></td>
              					<td><a href="<?php echo base_url('transaksi/detail_transaksi/'); ?><?php echo $rows->id_transaksi; ?>" target="_blank"><?php echo $rows->id_transaksi; ?></a></td>
              					<td>
              							<?php 
			              				$id_kantor = $rows->id_kantor; 
			              				$sql_menu = "SELECT * FROM tb_kantor WHERE  id_kantor = '$id_kantor' ";
			              				$main_menu = $this->db->query($sql_menu)->result();
			              				foreach ($main_menu as $maink) {
			              				echo  $maink->nama_kantor;

			              				}
			              				?>
              					</td>
              					<td> 
              						<?php 
			              				$id_member = $rows->id_member; 
			              				$sql_menu = "SELECT * FROM tb_member WHERE  id_member = '$id_member' ";
			              				$main_menu = $this->db->query($sql_menu)->result();
			              				foreach ($main_menu as $maink) {
			              				echo  $maink->nama_member;

			              				}
			              				?>
              					</td>
              					<td style="text-align: right;"><?php echo nominal($rows->sub_total); ?></td>
              					<td style="text-align: right;"><?php echo nominal($rows->potongan); ?></td>
              					<td style="text-align: right;"><?php echo nominal($rows->total); ?></td>
              						<td style="text-align: right;"><?php echo nominal($rows->bayar); ?></td>
              							<td style="text-align: right;"><?php echo nominal($rows->kembali); ?></td>
              					<td><?php echo $rows->status; ?></td>
              					<td><?php 
			              				  $id_metode = $rows->metode_bayar; 
			              				$sql_menuk = "SELECT * FROM tb_metode WHERE  id_metode = '$id_metode' ";
			              				$main_menuk = $this->db->query($sql_menuk)->result();
			              				foreach ($main_menuk as $mainkk) {
			              							 
			              								echo $rows->metode_bayar;
			              						 

			              				} 
			              				if($id_metode =='cash'){
			              					echo "cash";
			              				}
			              				?>
			              					
			              				</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>
              				


              						<a target="print_popup"    href="<?php echo base_url('cetak/form_cetak/'.$rows->id_transaksi); ?>" onclick="window.open('about:blank','print_popup','width=400,height=500');window.location.reload();" type="button" alt="cetak" ><i class="fa fa-print"></i></a>  

                          <?php 
                          $username = $this->session->userdata("username");  
                          $this->db->where('username',$username);
                          $query = $this->db->get('tb_admin');
                          $row = $query->row();
                         
                          $level = $row->level;

                           ?>
                          <?php  
                            if($level =='manager' or $level =='admin' ){
                          ?>  
              						| <a href=""   type="button" class="bg-warning" data-toggle="modal" data-target="#modal-retur<?php echo $rows->id_transaksi; ?>" alt="retur"><i class="fa fa-undo "></i></a>
                           <?PHP } ?> 
              					 	<?php  
                            if($level =='manager'  ){
                          ?>  
              						| <a href=""   type="button" class="bg-danger" data-toggle="modal" data-target="#modal-hapus<?php echo $rows->id_transaksi; ?>" alt="hapus"><i class="fa fa-trash "></i></a>
                           <?PHP } ?> 

              						<form class="form-horizontal" action="<?php echo base_url('transaksi/code_retur_pembelian'); ?>" method="POST" enctype="multipart/form-data" />  
              							<div class="modal fade" id="modal-retur<?php echo $rows->id_transaksi; ?>">
              								<div class="modal-dialog">
              									<div class="modal-content bg-warning">
              										<div class="modal-header">
              											<h4 class="modal-title">Retur Pembelian </h4>
              											<button type="button" class="close" data-dismiss="modal" aria-label="Close">
              												<span aria-hidden="true">&times;</span>
              											</button>
              										</div>
              										<div class="modal-body">
              											<h4>Apakah Retur Pembelian ID, <?php echo $rows->id_transaksi; ?> ?</h4>
              											<!-- id kirim -->
              											<input type="hidden" name="id_transaksi" value="<?php echo $rows->id_transaksi; ?>">


              										</div>
              										<div class="modal-footer justify-content-between">
              											<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              											<button type="submit" class="btn btn-primary">Retur</button>
              										</div>
              									</div>
              									<!-- /.modal-content -->
              								</div>
              								<!-- /.modal-dialog -->
              							</div>
              						</form>

              						<form class="form-horizontal" action="<?php echo base_url('transaksi/code_hapus_pembelian'); ?>" method="POST" enctype="multipart/form-data" />  
              							<div class="modal fade" id="modal-hapus<?php echo $rows->id_transaksi; ?>">
              								<div class="modal-dialog">
              									<div class="modal-content bg-danger">
              										<div class="modal-header">
              											<h4 class="modal-title">Hapus Data Pembelian </h4>
              											<button type="button" class="close" data-dismiss="modal" aria-label="Close">
              												<span aria-hidden="true">&times;</span>
              											</button>
              										</div>
              										<div class="modal-body">
              											<h4>Apakah Hapus Pembelian ID, <?php echo $rows->id_transaksi; ?> ?</h4>
              											<!-- id kirim -->
              											<input type="hidden" name="id_transaksi" value="<?php echo $rows->id_transaksi; ?>">


              										</div>
              										<div class="modal-footer justify-content-between">
              											<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              											<button type="submit" class="btn btn-primary">Hapus</button>
              										</div>
              									</div>
              									<!-- /.modal-content -->
              								</div>
              								<!-- /.modal-dialog -->
              							</div>
              						</form>

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

              		</tbody>

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