Anons79 Mini Shell

Directory : /home/aplikasiposinfo/www/bendahara2.aplikasipos.info/resources/views/transaksi/
Upload File :
Current File : /home/aplikasiposinfo/www/bendahara2.aplikasipos.info/resources/views/transaksi/edit.blade.php

@extends('template')

@section('content')
    <h3 style="color: black;">{{ $title }}</h3>
    @include('message')
    <br>
    <form action="/transaksi/{{ $transaksi->id }}" id="transaksi" method="post">
        <div class="card">
            <div class="card-header">Rincian Biaya</div>
            <div class="card-body" style="color: black;">
                @method('put')
                @csrf
                <div class="form-group">
                    <label for="">Rekening<span class="text-muted text-danger">*</span></label>
                    <select name="kode" class="form-control" id="kode">
                        <option value="">Pilih Rekening</option>
                        @foreach ($rekening as $a)
                            <option value="{{ $a->id }}"
                                {{ old('kode', $transaksi->rekening_id) == $a->id ? 'selected' : '' }}>{{ $a->kode }}
                                | {{ $a->nama }} | @foreach ($a->sub_kegiatan as $b)
                                    {{ $b->nama }}
                                @break
                            @endforeach | {{ $a->tahun_rekening->tahun }}</option>
                    @endforeach
                </select>
                <div id="notif">

                </div>
            </div>
            <div class="form-group">
                <label for="">Sub Kegiatan<span class="text-muted text-danger">*</span></label><br>
                <select name="sub" class="form-control" data-placeholder="Pilih Sub Kegiatan" id="sub"
                    required>
                    <option></option>
                    @foreach ($sub as $a)
                        <option value="{{ $a->id }}"
                            {{ old('sub', $transaksi->sub_kegiatan_id) == $a->id ? 'selected' : '' }}>
                            {{ $a->nama }}</option>
                    @endforeach
                </select>
                <div id="notif0">
                    @error('sub')
                        <small class="form-text text-muted text-danger pl-3"
                            style="font-style: italic">{{ $message }}</small>
                    @enderror
                </div>
            </div>
            {{-- <div class="form-group">
                    <label for="">Tahun Rekening</label>
                    <select name="tahun" class="form-control" id="tahun">
                        <option value="">Pilih Tahun</option>
                        @foreach ($tahun as $a)
                            <option value="{{$a->id}}" {{(old('tahun', $transaksi->tahun_rekening_id) == $a->id) ? "selected" : ""}}>{{$a->tahun}}</option>
                        @endforeach
                    </select>
                    <div id="notif1">

                    </div>
                </div> --}}
            <div class="form-group">
                <label for="">No. BKU<span class="text-muted text-danger">*</span></label>
                <input type="text" name="no_bku" class="form-control"
                    value="{{ old('no_bku', $transaksi->no_bku) }}" placeholder="Input No.BKU" id="no_bku">
            </div>
            <div id="notif1">

            </div>
            <div class="form-group">
                <label for="">Tanggal<span class="text-muted text-danger">*</span></label>
                {{-- <input type="text" name="title" class="form-control" placeholder="Input Role" id=""> --}}
                <input type="date" name="tanggal" class="form-control"
                    value="{{ old('tanggal', $transaksi->tanggal) }}" id="tanggal">
            </div>
            <div id="notif2">

            </div>
            <div class="form-group">
                <label for="">Uraian<span class="text-muted text-danger">*</span></label>
                <input type="text" name="uraian" class="form-control"
                    value="{{ old('uraian', $transaksi->uraian) }}" placeholder="Input Uraian" id="uraian">
            </div>
            <div id="notif3">

            </div>
            <div class="form-group">
                <label for="">Jumlah Anggaran (Rp)<span class="text-muted text-danger">*</span></label>
                <input type="text" readonly data-type="currency" name="maksimals" class="form-control"
                    value="{{ old('maksimals', number_format($transaksi->sub_kegiatan->jumlah, 0, ',', ',')) }}"
                    placeholder="Maksimal Anggaran" id="maksimals">
                <input type="hidden" readonly name="maksimal" class="form-control"
                    value="{{ old('maksimal', $transaksi->sub_kegiatan->jumlah) }}" placeholder="Maksimal Anggaran"
                    id="maksimal">
            </div>
            <div id="notif4">

            </div>
            <div class="form-group">
                <label for="">Sisa Anggaran (Rp)<span class="text-muted text-danger">*</span></label>
                <input type="text" data-type="currency" readonly name="sisas" class="form-control"
                    value="{{ old('sisas', number_format($transaksi->sub_kegiatan->sisa, 0, ',', ',')) }}"
                    placeholder="Sisa Anggaran" id="sisas">
                <input type="hidden" readonly name="sisa" class="form-control"
                    value="{{ old('sisa', $transaksi->sub_kegiatan->sisa) }}" placeholder="Sisa Anggaran"
                    id="sisa">
            </div>
            <div id="notif5">

            </div>
            <div class="form-group">
                <label for="">Rekening (Rp)<span class="text-muted text-danger">*</span></label>
                <input type="text" name="rekenings" class="form-control"
                    value="{{ old('rekenings', number_format($transaksi->rekening, 0, ',', ',')) }}"
                    placeholder="Input Rekening" id="rekenings" readonly>
                <input type="hidden" name="rekening" class="form-control"
                    value="{{ old('rekening', $transaksi->rekening) }}" placeholder="Input Rekening" id="rekening"
                    readonly>
            </div>
            <div id="notif6">

            </div>
            {{-- <div class="form-group">
                    <div class="form-check">
                        <input type="checkbox" name="uang_muka"
                            {{ old('uang_muka', $transaksi->uang_muka) == 'true' ? 'checked' : '' }}
                            class="form-check-input" id="">
                        <label class="form-check-label" for="type1">
                            : Uang Muka
                        </label>
                    </div>
                </div> --}}
            <div class="form-group">
                <label for="">Type<span class="text-muted text-danger">*</span></label>
                <div class="form-check">
                    <input class="form-check-input" type="radio" name="type" value="0"
                        id="flexRadioDefault1" {{ old('type', $transaksi->type) == 0 ? 'checked' : '' }}>
                    <label class="form-check-label" for="type1">
                        Debit
                    </label>
                </div>
                <div class="form-check">
                    <input class="form-check-input" type="radio" name="type" value="1"
                        {{ old('type', $transaksi->type) == 1 ? 'checked' : '' }} id="flexRadioDefault2">
                    <label class="form-check-label" for="type2">
                        Kredit
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label for="">Pilih Aktiva<span class="text-muted text-danger"></span></label>
                <select name="uang_muka" id="status" class="form-control">
                    {{-- <option value="false" {{ old('uang_muka', $transaksi->uang_muka) == 'false' ? 'selected' : '' }}>
                        Kas
                    </option>
                    <option value="true" {{ old('uang_muka', $transaksi->uang_muka) == 'true' ? 'selected' : '' }}>
                        Uang Muka</option> --}}
                    @foreach ($kas as $a)
                        <option value="{{ $a->id }}"
                            {{ old('uang_muka', $transaksi->ka_id) == $a->id ? 'selected' : '' }}>{{ $a->nama }}
                        </option>
                    @endforeach
                </select>
            </div>
            <div class="form-group">
                <label for="">Pilih Kewajiban dan Ekuitas : <span
                        class="text-muted text-danger"></span></label>
                <select name="ekuitas" id="status" class="form-control">
                    {{-- <option value="false">Kas</option>
                    <option value="true">Uang Muka</option> --}}
                    @foreach ($ekuitas as $a)
                        <option value="{{ $a->id }}"
                            {{ old('ekuitas', $transaksi->ekuitas_id) == $a->id ? 'selected' : '' }}>
                            {{ $a->nama }} |
                            {{ $a->type == 0 ? 'Kewajiban' : 'Ekuitas' }}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group" id="uang_muka_N">
                <label for="">Nominal Uang Muka (Rp)<span class="text-muted text-danger">*</span></label>
                <input type="text" name="nominal_uang_mukas" class="form-control"
                    value="{{ old('nominal_uang_mukas', number_format($transaksi->nominal_uang_muka, 0, ',', ',')) }}"
                    placeholder="Input Nominal Uang Muka" id="nominal_uang_mukas">
                <input type="hidden" data-type="currency" name="nominal_uang_muka" class="form-control"
                    value="{{ old('nominal_uang_muka', $transaksi->nominal_uang_muka) }}"
                    placeholder="Input Nominal Uang Muka" id="nominal_uang_muka" readonly>
            </div>
        </div>
    </div>
    <div class="card">
        <div class="card-header">Rincian Anggaran</div>
        <div class="card-body" style="overflow-x: scroll;">
            <div class="form-group">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th style="vertical-align: middle;">Item Pengeluaran</th>
                            <th colspan="2">
                                <center>Volume</center>
                            </th>
                            <th style="vertical-align: middle;">Harga Satuan (Rp)</th>
                            <th style="vertical-align: middle;">Sub Total (Rp)</th>
                            <th style="vertical-align: middle;">Anggaran</th>
                            <th style="vertical-align: middle;">Action</th>
                        </tr>
                    </thead>
                    <tbody class="field_wrapper">
                        <?php $no = 1; ?>
                        @foreach ($transaksi->anggaran as $a)
                            <?php $no++; ?>
                            <tr>
                                <td>
                                    <input type="hidden" name="ids[]" value="{{ old('ids', $a->id) }}"
                                        placeholder="Item Pengeluaran" class="form-control" id="">
                                    <input type="text" name="items[]" value="{{ old('item', $a->item) }}"
                                        placeholder="Item Pengeluaran" class="form-control" id="">
                                </td>
                                <td>
                                    <input type="number" name="kalis[]"
                                        value="{{ old('kali', $a->value_volume_1) }}" list="{{ $no }}"
                                        placeholder="Volume" class="form-control kali"
                                        id="kali_{{ $no }}">
                                </td>
                                <td>
                                    <input type="text" name="nama_volume_1s[]"
                                        value="{{ old('nama_volume_1', $a->nama_volume_1) }}" placeholder="Satuan"
                                        class="form-control" id="">
                                </td>
                                {{-- <td>
                                        <input type="number" name="units[]"
                                            value="{{ old('unit', $a->value_volume_2) }}" list="{{ $no }}"
                                            placeholder="Value Volume 2" class="form-control unit"
                                            id="unit_{{ $no }}">
                                    </td>
                                    <td>
                                        <input type="text" name="nama_volume_2s[]"
                                            value="{{ old('nama_volume_2', $a->nama_volume_2) }}"
                                            placeholder="Nama Volume 2" class="form-control" id="">
                                    </td> --}}
                                <td>
                                    <input type="text" data-type="currency"
                                        value="{{ old('harga_satuan', number_format($a->harga_satuan, 0, ',', ',')) }}"
                                        name="harga_satuans[]" list="{{ $no }}" placeholder="Harga Satuan"
                                        class="form-control harga_satuans" id="harga_satuans_{{ $no }}">
                                    <input type="hidden" name="harga_satuans[]"
                                        value="{{ old('harga_satuan', $a->harga_satuan) }}"
                                        list="{{ $no }}" placeholder="Harga Satuan"
                                        class="form-control harga_satuan" id="harga_satuan_{{ $no }}">
                                </td>
                                <td>
                                    <input type="text"
                                        value="{{ old('sub_total', number_format($a->sub_total, 0, ',', ',')) }}"
                                        name="sub_totals[]" list="{{ $no }}" placeholder="Sub Total"
                                        class="sub_totals form-control" readonly id="sub_totals_{{ $no }}">
                                    <input type="hidden" name="sub_totals[]"
                                        value="{{ old('sub_total', $a->sub_total) }}" list="{{ $no }}"
                                        placeholder="Sub Total" class="sub_total form-control" readonly
                                        id="sub_total_{{ $no }}">
                                </td>
                                <td>
                                    <select name="anggaran[]" class="form-control" list="0" id="anggaran_0">
                                        <option value="A"
                                            {{ old('anggaran', $a->type) == 'A' ? 'selected' : '' }}>A
                                        </option>
                                        <option value="B"
                                            {{ old('anggaran', $a->type) == 'B' ? 'selected' : '' }}>B
                                        </option>
                                        <option value="C"
                                            {{ old('anggaran', $a->type) == 'C' ? 'selected' : '' }}>C
                                        </option>
                                    </select>
                                </td>
                                <td>
                                    @if ($loop->iteration == 1)
                                        <button class="btn btn-success" type="button" id="add_Link"> <i
                                                class="fas fa-plus"></i> </button>
                                    @else
                                        <button class="btn btn-danger" type="button" id="delete_link"> <i
                                                class="fas fa-minus"></i> </button>
                                    @endif
                                </td>
                            </tr>
                        @endforeach
                        @if ($no < 2)
                            <tr>
                                <td>
                                    <input type="text" name="item[]" placeholder="Item Pengeluaran"
                                        class="form-control" id="">
                                </td>
                                <td>
                                    <input type="number" name="kali[]" list="0" placeholder="Volume"
                                        class="form-control kali" id="kali_0">
                                </td>
                                <td>
                                    <input type="text" name="nama_volume_1[]" placeholder="Satuan"
                                        class="form-control" id="">
                                </td>
                                {{-- <td>
                                        <input type="number" name="unit[]" list="0" placeholder="Value Volume 2"
                                            class="form-control unit" id="unit_0">
                                    </td>
                                    <td>
                                        <input type="text" name="nama_volume_2[]" placeholder="Nama Volume 2"
                                            class="form-control" id="">
                                    </td> --}}
                                <td>
                                    <input type="text" data-type="currency" name="harga_satuans[]" list="0"
                                        placeholder="Harga Satuan" class="form-control harga_satuans"
                                        id="harga_satuans_0">
                                    <input type="hidden" name="harga_satuan[]" list="0"
                                        placeholder="Harga Satuan" class="form-control harga_satuan"
                                        id="harga_satuan_0">
                                </td>
                                <td>
                                    <input type="text" name="sub_totals[]" list="0" placeholder="Sub Total"
                                        class="sub_totals form-control" readonly id="sub_totals_0">
                                    <input type="hidden" name="sub_total[]" list="0" placeholder="Sub Total"
                                        class="sub_total form-control" readonly id="sub_total_0">
                                </td>
                                <td>
                                    <select name="anggaran[]" class="form-control" list="0" id="anggaran_0">
                                        <option value="A">A</option>
                                        <option value="B">B</option>
                                        <option value="C">C</option>
                                    </select>
                                </td>
                                <td>
                                    <button class="btn btn-success" type="button" id="add_Link"> <i
                                            class="fas fa-plus"></i> </button>
                                </td>
                            </tr>
                        @endif
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="card">
        <div class="card-body">
            <div class="d-flex bd-highlight mb-1">
                <div class="p-2 bd-highlight">
                    <a href="/transaksi" class="btn btn" style="background-color: #D7AE47">
                        <span class="text-light" style="font-size: 15px;">Kembali</span>

                    </a>
                </div>
                <div class="ml-auto p-2 bd-highlight">
                    <button type="submit" id="simpan" class="btn btn" style="background-color: #52F258">
                        <span class="text-light" style="font-size: 15px;">Simpan</span>
                    </button>
                </div>
            </div>
        </div>
    </div>
</form>
<script>
    @section('jquery')
        $('#kode').select2();
        $('#sub').select2();
        $('#tahun').select2();

        @if ($transaksi->uang_muka == 'true')
            $('#uang_muka_N').show();
            // $(this).val(formatNumber($(this).val().toString()));
        @else
            $('#uang_muka_N').hide();
        @endif

        $('#kode').change(function() {
            var iteration = 0;
            // console.log("Sapi");
            $.ajax({
                url: '/rekening/create?rekening=' + $(this).val(),
                type: "GET",
                dataType: 'json',
                success: function(data) {
                    //console.log(data.jumlah);
                    $('#sub').append("<option value=''>Pilih Sub Kegiatan</option>")
                    $.each(data.sub_kegiatan, function(index, value) {
                        $('#sub').append("<option value='" + value.id + "'>" + value.nama +
                            "</option>");
                    });

                    $('#sub').val(data.sub_kegiatan[0].id).change();
                }
            });
        });

        $('#sub').change(function() {
            var iteration = 0;
            // console.log("Sapi");
            $.ajax({
                url: '/rekening/create?sub_kegiatan=' + $(this).val(),
                type: "GET",
                dataType: 'json',
                success: function(data) {
                    //console.log(data.jumlah);
                    $('#maksimals').val(formatNumber(data.sub.jumlah));
                    $('#sisas').val(formatNumber(data.sub.sisa));
                    $('#maksimal').val(data.sub.jumlah);
                    $('#sisa').val(data.sub.sisa);
                }
            });
        });

        var status = true;

        function validasi(field, kode, pesan) {
            if ($(field).val() === '') {
                $(field).parents('.form-group').addClass('is-invalid');
                $(kode).html('<br><p class="text-danger">' + pesan + '</p>');
                status = false;
                // return false;
            } else {
                $(kode).html('');
            }
        }

        $('#simpan').click(function() {
            status = true;
            validasi('#kode', '#notif', 'kegiatan Wajib diisi!');
            validasi('#sub', '#notif0', 'Sub kegiatan Wajib diisi!');
            validasi('#no_bku', '#notif1', 'No BKU Wajib diisi!');
            validasi('#tanggal', '#notif2', 'Tanggal Wajib diisi!');
            validasi('#uraian', '#notif3', 'Uraian Wajib diisi!');
            validasi('#maksimal', '#notif4', 'Jumlah Anggaran Wajib diisi!');
            validasi('#sisa', '#notif5', 'Sisa Anggaran Wajib diisi!');
            validasi('#rekening', '#notif6', 'Rekening Wajib diisi!');
            if (status == false) {
                return false;
            }

            // console.log($('#rekening').val());
            // console.log($('#maksimal').val());
            // if ( $('#kode').val() === '') {
            //     // Add is-invalid class when select2 element is required
            //     $('#kode').parents('.form-group').addClass('is-invalid');
            //     $('#notif').html('<br><p class="text-danger">Rekening Wajib diisi!</p>');
            //     // Stop submiting
            //     // e.preventDefault();
            //     return false;
            // }
            // if ( $('#tahun').val() === ''){
            //     // Add is-invalid class when select2 element is required
            //     $('#tahun').parents('.form-group').addClass('is-invalid');
            //     $('#notif1').html('<br><p class="text-danger">Tahun Rekening Wajib diisi!</p>');
            //     // Stop submiting
            //     // e.preventDefault();
            //     return false;
            // }
            if (parseInt($('#rekening').val()) > parseInt($('#sisa').val())) {
                // alert("Jumlah Rencana tidak boleh lebih besar dari jumlah anggaran!");
                let message = 'Jumlah Rencana tidak boleh lebih besar dari jumlah anggaran!';
                Swal.fire({
                    icon: 'error',
                    title: 'Gagal!',
                    text: message,
                });
                return false;
            } else {
                $('#transaksi').submit();
                // document.forms["myform"].onsubmit = validateForm;x
            }
        });

        // COunting

        function sub_total(id) {
            // var sub = ($('#kali_' + id).val() * $('#unit_' + id).val()) * $('#harga_satuan_' + id).val();
            var sub = $('#kali_' + id).val() * $('#harga_satuan_' + id).val();
            $('#sub_total_' + id).val(sub);
            $('#sub_totals_' + id).val(formatNumber(sub.toString()));
        }

        function total() {
            var sum = 0;
            $('.sub_total').each(function(i, e) {
                var v = parseInt($(e).val());
                if (!isNaN(v)) {
                    sum += v;
                    $('#rekenings').val(formatNumber(sum.toString()));
                    $('#rekening').val(sum);
                }
            });
        }

        $(document).on('keyup', '.kali', function() {
            sub_total($(this).attr('list'));
            total();
        });

        $(document).on('keyup', '.unit', function() {
            sub_total($(this).attr('list'));
            total();
        });

        // $(document).on('keyup', '.harga_satuan', function() {
        //     sub_total($(this).attr('list'));
        //     total();
        // });

        $(document).on('keyup', '.harga_satuans', function() {
            $('#harga_satuan_' + $(this).attr('list')).val(backformatNumber($(this).val().toString()));
            sub_total($(this).attr('list'));
            //console.log($(this).val());
            $(this).val(formatNumber($(this).val().toString()));
            total();
        });

        $('#status').change(function() {
            if ($(this).val() == 'true') {
                $('#uang_muka_N').show();
            } else {
                $('#uang_muka_N').hide();
            }
        });

        $(document).on('keyup', '#nominal_uang_mukas', function() {
            $('#nominal_uang_muka').val(backformatNumber($(this).val().toString()));
            $(this).val(formatNumber($(this).val().toString()));
        });


        let RincianVal = "{{ $no + 1 }}";
        $('#add_Link').click(function() {
            var fieldHTML = `<tr>
                    <td>
                        <input type="text" name="item[]" placeholder="Item Pengeluaran" class="form-control" id="">
                    </td>
                    <td>
                        <input type="number" name="kali[]" list="` + RincianVal +
                `" placeholder="Volume" class="form-control kali" id="kali_` + RincianVal + `">
                    </td>
                    <td>
                        <input type="text" name="nama_volume_1[]" placeholder="Satuan" class="form-control" id="">
                    </td>` +
                // <td>
                //     <input type="number" name="unit[]" list="` + RincianVal +
                // `" placeholder="Value Volume 2" class="form-control unit" id="unit_` + RincianVal + `">
                // </td>
                // <td>
                //     <input type="text" name="nama_volume_2[]" placeholder="Nama Volume 2" class="form-control" id="">
                // </td>
                `<td>
                        <input type="text" data-type="currency" name="harga_satuans[]" list="` + RincianVal +
                `" placeholder="Harga Satuan" class="form-control harga_satuans" id="harga_satuans_` +
                RincianVal + `">
                        <input type="hidden" name="harga_satuan[]" list="` + RincianVal +
                `" placeholder="Harga Satuan" class="form-control harga_satuan" id="harga_satuan_` +
                RincianVal + `">
                    </td>
                    <td>
                        <input type="text" name="sub_totals[]" list="` + RincianVal +
                `" placeholder="Sub Total" class="sub_totals form-control" readonly id="sub_totals_` +
                RincianVal + `">
                        <input type="hidden" name="sub_total[]" list="` + RincianVal +
                `" placeholder="Sub Total" class="sub_total form-control" readonly id="sub_total_` +
                RincianVal + `">
                    </td>
                    <td>
                        <select name="anggaran[]" class="form-control" list="` + RincianVal + `" id="anggaran_` +
                RincianVal + `">
                            <option value="A">A</option>
                            <option value="B">B</option>
                            <option value="C">C</option>
                        </select>
                    </td>
                    <td>
                        <button class="btn btn-danger" type="button" id="delete_link"> <i class="fas fa-minus"></i> </button>
                    </td>
                </tr>`;
            $('.field_wrapper').append(fieldHTML);
            RincianVal += 1;
        });

        $(document).on('click', '#delete_link', function(e) {
            e.preventDefault();
            $(this).closest('tr').remove();
        });
    @endsection
</script>
@endsection

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]