
<?php 
$nip=$row_user['employees_code'];    

if ($mod ==''){
    header('location:../404');
    echo'kosong';
}else{
    include_once 'mod/sw-header.php';
if(!isset($_COOKIE['COOKIES_MEMBER']) && !isset($_COOKIE['COOKIES_COOKIES'])){
        setcookie('COOKIES_MEMBER', '', 0, '/');
        setcookie('COOKIES_COOKIES', '', 0, '/');
        // Login tidak ditemukan
        setcookie("COOKIES_MEMBER", "", time()-$expired_cookie);
        setcookie("COOKIES_COOKIES", "", time()-$expired_cookie);
        session_destroy();
        header("location:./index");
}else{
  echo'<!-- App Capsule -->
    <div id="appCapsule">
    <div class="section mt-2">
    <div class="card">
    <div class="card-body">
   

<section class="content">
  <div class="row">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
      <div class="box box-solid">
        <div class="box-header with-border">
          <h3 class="box-title"><b>Data Gaji</b></h3>
        </div>
        <div class="box-body">
          <div class="table-responsive table-bordered">
            <table id="swdatatable" class="table table-bordered">
            <thead>
            <tr>
              <th style="width: 10px">No</th>
              <th>Tanggal</th>
              <th>Gapok</th>
              <th>Insentif</th>
              <th>Kerajinan</th>
              <th>LainLain</th>
              <th><b>Pendapatan</b></th>
              <th>Potongan</th>
              <th>BPJS</th>
              <th>Pinjaman</th>
              <th>LainLain</th>
              <th><b>Pengeluaran</b></th>
              <th><b>Netto</b></th>
            </tr>
            </thead>
            <tbody>';
            $query="SELECT a.*,(a.insentif+a.kerajinan+a.laind) AS penambahan,(a.pinjaman+a.bpjs+a.potongan+a.laink) AS pengurangan,b.`employees_name`,c.`position_name`,b.employees_code,(a.gpokok+a.kerajinan+a.insentif+a.laind) as dapat,(a.pinjaman+a.bpjs+a.potongan+a.laink) as keluar FROM slipgaji a
                    LEFT JOIN employees b ON  a.`nip`=b.`id` 
                    LEFT JOIN enae6276_dbabsen.`position` c ON c.`position_id`=b.`position_id`
                    LEFT JOIN building d ON d.`building_id`=b.`building_id`
                    where b.employees_code='$nip'
                    ORDER BY b.`building_id`,a.`nip`,a.`tgl` DESC";
            $result = $connection->query($query);
            if($result->num_rows > 0){
            $no=0;
           while ($row= $result->fetch_assoc()) {
              $no++;
              echo'
              <tr>
                <td class="text-center">'.$no.'</td>
                <td>'.$row['tgl'].'</td>
                <td>'.number_format($row['gpokok']).'</td>
                <td>'.number_format($row['insentif']).'</td>
                <td>'.number_format($row['kerajinan']).'</td>
                <td>'.number_format($row['laind']).'</td>
                <td><font><b>'.number_format($row['dapat']).'</b></font></td>
                <td>'.number_format($row['potongan']).'</td>
                <td>'.number_format($row['bpjs']).'</td>
                <td>'.number_format($row['pinjaman']).'</td>
                <td>'.number_format($row['laink']).'</td>
                <td><font><b>'.number_format($row['keluar']).'</b></font></td>
                <td><font><b>'.number_format($row['netto']).'</b></font></td>
                
              </tr>';}}
            echo'
            </tbody>
          </table>
          </div>
        </div>
    </div>
  </div> 
</section>
</div>
</div>
</div>
</div>
';


  }
  include_once 'mod/sw-footer.php';
} ?>