<?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-12">
	              		<form class="form-inline"   action="<?php echo base_url('kantor/data_faktur'); ?>" 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 $kanto3->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; Status &nbsp;:&nbsp;
	              			</label>
	              			<select class="form-control" name="status">
	              				<option value="semua"  >semua</option>
	              				<option value="LUNAS">LUNAS</option>
	              				<option value="HUTANG">HUTANG</option>
	              				<option value="BARANG DITERIMA">BARANG DITERIMA</option>
	              				<option value="KIRIM BARANG">KIRIM BARANG</option>
	              			</select>
	              			<label>
	              				&nbsp; Jenis &nbsp;:&nbsp;
	              			</label>
	              			<select class="form-control" name="jenis">
	              						<option value="masuk">masuk</option>
              							<option value="keluar">keluar</option>
	              			</select>
	              			&nbsp; <button  type="submit" class="btn btn-info btn-small">
	              				<i class="icon-search bigger-110"></i>
	              				Tampil
	              			</button>

	              		</form> 
	              	</div>  	
	              </div>   
                <div class="row">
                  <div class="col-md-12">
                  <hr>
                   <a href="<?php echo base_url('kantor/faktur'); ?>"> <button    class="btn btn-success btn-small">
                     
                      New Faktur Masuk
                    </button></a> 
                    <a href="<?php echo base_url('kantor/faktur_keluar'); ?>"> <button    class="btn btn-warning btn-small">
                     
                      New Faktur Kirim Barang
                    </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>Date </th>
              				<th>ID Faktur</th>
              				<th>Jenis</th>
              				<th>Kantor</th>
              				<th>Supliyer</th>
              				 
              				<th style="text-align: right;">Nominal</th>
              			 
              				<th>Status</th>
              				<th>Jatuh Tempo</th>
              				<th>Admin</th>
              				<th>Aksi</th>
              				
              			</tr>
              		</thead>
              		<tbody>
              			<?php $no=1; foreach($faktur as $rows) : ?> 
              				<tr>
												<td><?php echo $no; ?></td>
                        <td><?php echo $rows->date; ?></td>
              					<td><a href="<?php echo base_url('kantor/detail_faktur/'); ?><?php echo $rows->id_faktur; ?>" target="_blank"><?php echo $rows->id_faktur; ?></a></td>
              					<td><?php echo $rows->jenis; ?></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_supliyer = $rows->id_supliyer; 
			              				$sql_menu = "SELECT * FROM tb_supliyer WHERE  id_supliyer = '$id_supliyer' ";
			              				$main_menu = $this->db->query($sql_menu)->result();
			              				foreach ($main_menu as $maink) {
			              				echo  $maink->nama_supliyer;

			              				}
			              				?>
              					</td>
              					<td style="text-align: right;"><?php echo nominal($rows->nominal); ?></td>
              					 
              					<td><?php echo $status=  $rows->status; ?></td>
              					<td><?php echo $rows->jatuh_tempo; ?></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  
                            if($level =='manager' or $level =='admin' ){
                          ?> 
													<!-- <a href="<?php echo base_url('kantor/code_restok_faktur'); ?>/<?php echo $rows->id_faktur;  ?>" onclick="return confirm('Apakah Anda Yakin Restok Faktur, ? Klik Oke jika Lanjut')" type="button" alt="restok" ><i class="fa fa-undo"></i></a>  -->
													<?php if ($status != "LUNAS") {  ?>
														<a href="<?php echo base_url('kantor/code_lunas_faktur'); ?>/<?php echo $rows->id_faktur;  ?>" onclick="return confirm('Apakah Anda Yakin Faktur Sudah Lunas, ? Klik Oke jika Lanjut')" type="button" alt="update" ><i class="fa fa-check"> Pelunasan</i></a> 
													<?php } ?>
															<a href="<?php echo base_url('kantor/code_hapus_faktur'); ?>/<?php echo $rows->id_faktur;  ?>" onclick="return confirm('Apakah Anda Yakin Membatalkan Faktur, ? Klik Oke jika Lanjut')" type="button" alt="hapus" ><i class="fa fa-trash"></i></a>  
                           <?php  
                           }
                          ?> 
              					 
              					</td>
              				</tr>
              			<?php $no++; endforeach; ?>

              		</tbody>

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