@extends('layout')


@section('content')

<style type="text/css">
     .table-form>tbody>tr>th, .table-form>tfoot>tr>th, .table-form>thead>tr>td, .table-form>tbody>tr>td, .table-form>tfoot>tr>td{
            padding: 5px;
           -- vertical-align: middle;
        }
        table.table-form tbody>tr.selected, table.table-form tbody>tr.selected td, table.table-form tbody>tr>.selected{
            color: white !important;
            background-color: #49b6d6 !important;
        }

     table, th, td, input, textarea, select {
            color:  black !important; 
        }
        .help-block {
 
    margin-top: 0px!important;
    margin-bottom: 0px!important;
}
</style>
<div class="page-header page-header-default">
    <div class="breadcrumb-line">
        <ul class="breadcrumb">
            <li><a href="{{ url('upahharian') }}"><i class="icon-home2 position-left"></i> Gaji</a></li>
            <li class="active">Tambah</li>
        </ul>
    </div>
</div>

<div class="content">
    <div class="panel panel-flat">
        <?php
        $url=''; 
        if($ops==0){
            $url=url('upahharian/tambah');
        } else if($ops==1){
            $url=url('upahharian');
        }
        ?>
        <form class="form-horizontal" method="post" action="{{ url('upahharian/simpan') }}" autocomplete="off" >                
            {{csrf_field()}}
        <div class="panel-heading">
            <h5 class="panel-title">Form Input Gaji</h5>
            <div class="heading-elements">
                <ul class="icons-list">
                    <li><a href="<?= $url ?>" class="text-warning"><i class="icon-circle-left2 warning"></i> Kembali</a></li>
                </ul>
            </div>
        </div>
        <div class="panel-body">            
            <div class="col-sm-6">
            	@if($ops==1)
            	<div class="form-group">
            	    <label class="control-label col-sm-4">No Transaksi</label>
            	    <div class="col-sm-8">
            	        <input class="form-control" type="text" name="no_trans" placeholder="No Transaksi" value="<?= $no_trans ?>" required <?= $ops==1 ? 'readonly' : '' ?>/>
            	    </div>
            	</div>
            	@endif
            	<div class="form-group">
                    <label class="control-label col-sm-4">Tanggal Transaksi</label>
                    <div class="col-sm-8">
                        <input class="form-control @if($ops==0) set_datepicker @endif" type="text" name="tanggal" placeholder="Tanggal" value="<?= $tanggal ?>" required <?= $ops==1 ? 'readonly' : '' ?>/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4">Akun Bayar</label>                    
                    <div class="col-sm-8">
                        <select class="form-control select-search" name="akun_bayar" <?= $ops==1 ? 'disabled' : '' ?>>
                            <?php foreach ($akun as $key => $value) { 
                                ?> 
                                <option value="<?php echo $key; ?>" <?= $set_akun == $key ? ' selected="selected"' : '';?>><?php echo $value; ?></option> 
                            <?php } ?>
                        </select>
                    </div>                       
                </div>  
            </div>           

        </div>       

                <div class="table-responsive">
                    <table class="table table-stripped" id="table_gaji">
                        <thead>
                            <tr>
                                <th>No</th>
                                <th>ID Pegawai</th>
                                <th>Nama Pegawai</th>
                                <th>Lokasi Produksi</th>
                                <th>Bagian</th>
                                <th>Hari Normal</th>
                                <th>Absen (Hari)</th>
                                <th>Hari Kerja</th>
                                <th>Upah Perhari</th>
                                <th>Jumlah Jam Lembur</th>
                                <th>Upah Lembur/Jam</th>
                                <th>Jumlah Hari Lembur</th>
                                <th>Upah Lembur/Hari</th>
                                <th>Jumlah Jam UM Lembur</th>
                                <th>UM Lembur/Jam</th>
                                <th>Jumlah Hari UM Lembur</th>
                                <th>UM Lembur/Hari</th>
                                <th>Jumlah Hari UM. Desa</th>
                                <th>UM Ke Desa</th>
                                <th>Jumlah Hari UM. Kediri</th>
                                <th>UM Ke Kediri</th>
                                <th>Jumlah Jam Keterlambatan</th>
                                <th>Potongan Keterlambatan</th>
                                <th>Potongan Kas Bon</th>
                                <th>Upah Yang Diterima</th>
                            </tr>
                        </thead>
                    <tbody>
                        @php 
                        $no=1;
                        @endphp
                        @foreach ($gaji as $key => $value)
                             <tr>
                                <td>{{ $no }}</td>
                                <td>{{ $value['nomor_pegawai'] }}</td>
                                <td>{{ $value['nama_pegawai'] }}</td>
                                <td>{{ $value['nama_lokasi'] }}</td>
                                <td>{{ $value['nama_bagian'] }}</td>
                                <td>{{ $value['hari_normal'] }}</td>
                                <td>{{ $value['absen_hari'] }}</td>
                                <td>{{ $value['hari_kerja'] }}</td>
                                <td>{{ rupiah2($value['upah_perhari'], 0) }}</td>
                                <td>{{ $value['jumlah_jam_lembur'] }}</td>
                                <td>{{ rupiah2($value['upah_lembur_jam'], 0) }}</td>
                                <td>{{ $value['jumlah_hari_lembur'] }}</td>
                                <td>{{ rupiah2($value['upah_lembur_hari'], 0) }}</td>
                                <td>{{ $value['jumlah_jam_um_lembur'] }}</td>
                                <td>{{ rupiah2($value['um_lembur_jam'], 0) }}</td>
                                <td>{{ $value['jumlah_hari_um_lembur'] }}</td>
                                <td>{{ rupiah2($value['um_lembur_hari'], 0) }}</td>
                                <td>{{ $value['jumlah_hari_um_desa'] }}</td>
                                <td>{{ rupiah2($value['um_desa'], 0) }}</td>
                                <td>{{ $value['jumlah_hari_um_kediri'] }}</td>
                                <td>{{ rupiah2($value['um_kediri'], 0) }}</td>
                                <td>{{ $value['jumlah_jam_keterlambatan'] }}</td>
                                <td>{{ rupiah2($value['potongan_keterlambatan'], 0) }}</td>
                                <td>{{ rupiah2($value['potongan_kas_bon'], 0) }}</td>
                                <td>{{ rupiah2($value['upah_terima'], 0) }}

                                <input type="hidden" id="id_pegawai{{ $value['nomor_pegawai'] }}" name="id_pegawai[]" value="{{ $value['id_pegawai'] }}">

                                <input type="hidden" id="lokasi_pegawai{{ $value['nomor_pegawai'] }}" name="lokasi[]" value="{{ $value['id_lokasi'] }}">

                                <input type="hidden" id="hari_normal{{ $value['nomor_pegawai'] }}" name="hari_normal[]" value="{{ $value['hari_normal'] }}">

                                <input type="hidden" id="absen_hari{{ $value['nomor_pegawai'] }}" name="absen_hari[]" value="{{ $value['absen_hari'] }}">

                                <input type="hidden" id="hari_kerja{{ $value['nomor_pegawai'] }}" name="hari_kerja[]" value="{{ $value['hari_kerja'] }}">

                                <input type="hidden" id="upah_perhari{{ $value['nomor_pegawai'] }}" name="upah_perhari[]" value="{{ $value['upah_perhari'] }}">

                                <input type="hidden" id="jumlah_jam_lembur{{ $value['nomor_pegawai'] }}" name="jumlah_jam_lembur[]" value="{{ $value['jumlah_jam_lembur'] }}">

                                <input type="hidden" id="upah_lembur_jam{{ $value['nomor_pegawai'] }}" name="upah_lembur_jam[]" value="{{ $value['upah_lembur_jam'] }}">

                                <input type="hidden" id="jumlah_hari_lembur{{ $value['nomor_pegawai'] }}" name="jumlah_hari_lembur[]" value="{{ $value['jumlah_hari_lembur'] }}">

                                <input type="hidden" id="upah_lembur_hari{{ $value['nomor_pegawai'] }}" name="upah_lembur_hari[]" value="{{ $value['upah_lembur_hari'] }}">

                                <input type="hidden" id="jumlah_jam_um_lembur{{ $value['nomor_pegawai'] }}" name="jumlah_jam_um_lembur[]" value="{{ $value['jumlah_jam_um_lembur'] }}">

                                <input type="hidden" id="um_lembur_jam{{ $value['nomor_pegawai'] }}" name="um_lembur_jam[]" value="{{ $value['um_lembur_jam'] }}">

                                <input type="hidden" id="jumlah_hari_um_lembur{{ $value['nomor_pegawai'] }}" name="jumlah_hari_um_lembur[]" value="{{ $value['jumlah_hari_um_lembur'] }}">

                                <input type="hidden" id="um_lembur_hari{{ $value['nomor_pegawai'] }}" name="um_lembur_hari[]" value="{{ $value['um_lembur_hari'] }}">

                                <input type="hidden" id="jumlah_hari_um_desa{{ $value['nomor_pegawai'] }}" name="jumlah_hari_um_desa[]" value="{{ $value['jumlah_hari_um_desa'] }}">

                                <input type="hidden" id="um_desa{{ $value['nomor_pegawai'] }}" name="um_desa[]" value="{{ $value['um_desa'] }}">

                                <input type="hidden" id="jumlah_hari_um_kediri{{ $value['nomor_pegawai'] }}" name="jumlah_hari_um_kediri[]" value="{{ $value['jumlah_hari_um_kediri'] }}">

                                <input type="hidden" id="um_kediri{{ $value['nomor_pegawai'] }}" name="um_kediri[]" value="{{ $value['um_kediri'] }}">

                                <input type="hidden" id="jumlah_jam_keterlambatan{{ $value['nomor_pegawai'] }}" name="jumlah_jam_keterlambatan[]" value="{{ $value['jumlah_jam_keterlambatan'] }}">

                                <input type="hidden" id="potongan_keterlambatan{{ $value['nomor_pegawai'] }}" name="potongan_keterlambatan[]" value="{{ $value['potongan_keterlambatan'] }}">

                                <input type="hidden" id="potongan_kas_bon{{ $value['nomor_pegawai'] }}" name="potongan_kas_bon[]" value="{{ $value['potongan_kas_bon'] }}">

                                <input type="hidden" id="upah_terima{{ $value['nomor_pegawai'] }}" name="upah_terima[]" value="{{ $value['upah_terima'] }}">
                                </td>
                            </tr>
                            @php($no++)
                         @endforeach                
                    </tbody>
                </table>
            </div>
            <?php
                if($ops==0){?>
                    <button type="submit" class="btn btn-primary pull-right" id="btn_popup_simpan">Simpan</button>                    
            <?php } ?>             
        </form>   
    </div>
</div>
<script type="text/javascript">
    var tabel_gaji;

    $(document).ready(function(){
        table_gaji = $("#table_gaji").DataTable({
            "paging": false
        });
        table_gaji.on( 'order.dt search.dt', function () {
            table_gaji.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
                cell.innerHTML = i+1;
            });
        }).draw();
    })
</script>


@endsection