set_stock.blade.php

mail@pastecode.io avatar
unknown
php_laravel_blade
2 years ago
5.9 kB
2
Indexable
Never
@extends('templates/main')
@section('css')
<link rel="stylesheet" href="{{ asset('css/manage_product/product/style.css') }}">
@endsection
@section('content')
<div class="row page-title-header">
  <div class="col-12">
    <div class="page-header d-flex justify-content-between align-items-center">
      <h4 class="page-title">Setting Stok Awal</h4>
      <div class="d-flex justify-content-start">
        <div class="row">
          <div class="col-11">
            <input type="text" class="form-control form-control-lg h-100" name="search" placeholder="Cari barang">
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<div class="row modal-group">
  <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel"
      aria-hidden="true">
      <div class="modal-dialog">
          <div class="modal-content">
              <div class="modal-header">
                  <h5 class="modal-title" id="editModalLabel">Set Stok</h5>
                  <button type="button" class="close close-btn" data-dismiss="modal" aria-label="close">
                      <span aria-hidden="true">&times;</span>
                  </button>
              </div>
              <form action="{{url('setting_stok_awal/set')}}" method="get" target="_blank">
                  @csrf
                  <div class="modal-body">
                    <input type="hidden" id="kode_barang" name="kode_barang">
                    <div class="form-group row">
                      <label class="col-lg-3 col-md-3 col-sm-12 col-form-label font-weight-bold">Stok Besar</label>
                      <div class="col-lg-9 col-md-9 col-sm-12">
                        <input type="number" class="form-control" name="stok_besar" required>
                      </div>
                    </div>
                    <div class="form-group row">
                      <label class="col-lg-3 col-md-3 col-sm-12 col-form-label font-weight-bold">Stok Kecil</label>
                      <div class="col-lg-9 col-md-9 col-sm-12">
                        <input type="number" class="form-control" name="stok_kecil" required>
                      </div>
                    </div>
                    <div class="custom-control custom-switch">
                      <input type="checkbox" class="custom-control-input" name="stok" id="stok">
                      <label class="custom-control-label" for="stok">Stok Awal/Stok</label>
                    </div>
                  </div>
                  <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="submit" class="btn btn-primary">Submit</button>
                  </div>
              </form>
          </div>
      </div>
  </div>
</div>
<div class="row">
  <div class="col-12 grid-margin">
    <div class="card card-noborder b-radius">
      <div class="card-body">
        <div class="row">
          <div class="col-12 table-responsive">
            <table class="table table-custom">
              <thead>
                <tr>
                  <th></th>
                  <th>Barang</th>
                  <th>Stok Besar</th>
                  <th>Stok Kecil</th>
                </tr>
              </thead>
              <tbody>
                @foreach($products as $product)
                <tr>
                  @php
                      $productAwal = DB::table('stok_awal')->where('kode_barang', $product->kode_barang)->first();
                  @endphp
                  <td>
                    <button type="button" class="btn btn-edit btn-icons btn-rounded btn-secondary" data-toggle="modal"
                      data-target="#editModal" data-nama="{{ $product->nama_barang }}" data-kode="{{ $product->kode_barang }}">
                      <i class="mdi mdi-pencil"></i>
                    </button>
                  </td>
                  <td>
                    <span class="kd-barang-field">{{ $product->nama_barang }}</span><br><br>
                    <span class="nama-barang-field">{{ $product->kode_barang }}</span>
                  </td>
                  @if($productAwal)
                  <td>
                    {{ $productAwal->jumlah_besar }}
                  </td>
                  <td>
                    {{ $productAwal->jumlah_kecil }}
                  </td>
                  @else
                  <td>0</td>
                  <td>0</td>
                  @endif
                </tr>
                @endforeach
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
@endsection
@section('script')
<script src="{{ asset('plugins/js/quagga.min.js') }}"></script>
<script src="{{ asset('js/manage_product/product/script.js') }}"></script>
<script type="text/javascript">
  @if ($message = Session::get('update_success'))
    swal(
        "Berhasil!",
        "{{ $message }}",
        "success"
    );
  @endif

  @if ($message = Session::get('update_failed'))
    swal(
        "",
        "{{ $message }}",
        "error"
    );
  @endif
  $(document).on('click', '.btn-edit', function () {
    var nama = $(this).data('nama');
    var kode = $(this).data('kode');
    $('#editModal').modal('show');
    $('#editModal').find('.modal-title').text('Set Stok ' + nama);
    $('#editModal').find('#kode_barang').val(kode);
  });
  $(document).on('click', '.filter-btn', function(e){
    e.preventDefault();
    var data_filter = $(this).attr('data-filter');
    $.ajax({
      method: "GET",
      url: "{{ url('/product/filter') }}/" + data_filter,
      success:function(data)
      {
        $('tbody').html(data);
      }
    });
  });
</script>
@endsection