fix structure product categories table and crud product
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<i class="kt-font-brand flaticon2-line-chart"></i>
|
||||
</span>
|
||||
<h3 class="kt-portlet__head-title">
|
||||
Kategori Produk
|
||||
Tabel Kategori Produk
|
||||
</h3>
|
||||
</div>
|
||||
@can('create', $menus['product_categories.index'])
|
||||
@@ -28,8 +28,8 @@
|
||||
<table class="table table-striped table-bordered table-hover" id="product-categories-table" data-url="{{ route("product_categories.index") }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>NO</th>
|
||||
<th>Nama Kategori</th>
|
||||
<th>Parent</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -51,11 +51,18 @@
|
||||
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="category_id">
|
||||
<input type="hidden" id="category_id" name="id">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Nama Kategori</label>
|
||||
<input type="text" class="form-control" id="name" name="name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="parent_id" class="form-label">Induk Kategori (Opsional)</label>
|
||||
<select class="form-control" id="parent_id" name="parent_id">
|
||||
<option value="">-- Tidak ada (Kategori Utama) --</option>
|
||||
<!-- will be filled by JavaScript -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary" id="saveBtn">Simpan</button>
|
||||
@@ -64,7 +71,6 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- end modal --}}
|
||||
@endsection
|
||||
|
||||
|
||||
@@ -1,37 +1,73 @@
|
||||
@extends('layouts.backapp')
|
||||
|
||||
@section('content')
|
||||
<div class="kt-portlet kt-portlet--mobile" id="kt_blockui_datatable">
|
||||
<div class="kt-portlet__head kt-portlet__head--lg">
|
||||
<div class="kt-portlet__head-label">
|
||||
<span class="kt-portlet__head-icon">
|
||||
<i class="kt-font-brand flaticon2-line-chart"></i>
|
||||
</span>
|
||||
<h3 class="kt-portlet__head-title">
|
||||
Tambah Produk
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="kt-portlet__body">
|
||||
<div class="">
|
||||
|
||||
<div class="kt-portlet kt-portlet--mobile">
|
||||
<div class="kt-portlet__head kt-portlet__head--lg">
|
||||
<div class="kt-portlet__head-label">
|
||||
<span class="kt-portlet__head-icon">
|
||||
<i class="kt-font-brand flaticon2-line-chart"></i>
|
||||
</span>
|
||||
<h3 class="kt-portlet__head-title">Tambah Produk</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="kt-portlet__body">
|
||||
<form action="{{ route('products.store') }}" method="POST" id="productForm">
|
||||
@csrf
|
||||
|
||||
{{-- Product Info --}}
|
||||
<div class="form-group">
|
||||
<label for="code"><strong>Kode Produk</strong></label>
|
||||
<input type="text" name="code" id="code" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name"><strong>Nama Produk</strong></label>
|
||||
<input type="text" name="name" id="name" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="description"><strong>Deskripsi</strong></label>
|
||||
<textarea name="description" id="description" class="form-control" rows="3"></textarea>
|
||||
</div>
|
||||
|
||||
{{-- Product Category --}}
|
||||
<div class="form-group">
|
||||
<label for="product_category_id"><strong>Kategori Produk</strong></label>
|
||||
<select name="product_category_id" id="product_category_id" class="form-control" required>
|
||||
<option value="">-- Pilih Kategori --</option>
|
||||
@foreach ($categories as $category)
|
||||
<option value="{{ $category->id }}" disabled style="background-color: #f0f0f0;">
|
||||
{{ $category->name }}
|
||||
</option>
|
||||
@foreach ($category->children as $child)
|
||||
<option value="{{ $child->id }}"> {{ $child->name }}</option>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{-- Dynamic Dealer Stock Section --}}
|
||||
<div id="dealerData" data-dealers='@json($dealers)'></div>
|
||||
<div class="form-group">
|
||||
<label><strong>Stok per Dealer</strong></label>
|
||||
<div id="dynamicDealerRows"></div>
|
||||
|
||||
<button type="button" id="addDealerRow" class="btn btn-outline-primary mt-2">
|
||||
➕ Tambah Dealer
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{{-- Submit --}}
|
||||
<div class="form-group mt-4">
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
<a href="{{ route('products.index') }}" class="btn btn-secondary">Batal</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<!--begin: Datatable -->
|
||||
<table class="table table-striped table-bordered table-hover" id="stock-dealers-table" data-url="{{ route("products.index") }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>NO</th>
|
||||
<th>Kode</th>
|
||||
<th>Nama</th>
|
||||
<th>Address</th>
|
||||
<th>Stok</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<!--end: Datatable -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('javascripts')
|
||||
<script src="{{ mix('js/warehouse_management/products/create.js') }}"></script>
|
||||
@endsection
|
||||
95
resources/views/warehouse_management/products/edit.blade.php
Normal file
95
resources/views/warehouse_management/products/edit.blade.php
Normal file
@@ -0,0 +1,95 @@
|
||||
@extends('layouts.backapp')
|
||||
|
||||
@section('content')
|
||||
<div class="kt-portlet kt-portlet--mobile">
|
||||
<div class="kt-portlet__head kt-portlet__head--lg">
|
||||
<div class="kt-portlet__head-label">
|
||||
<span class="kt-portlet__head-icon">
|
||||
<i class="kt-font-brand flaticon2-line-chart"></i>
|
||||
</span>
|
||||
<h3 class="kt-portlet__head-title">Tambah Produk</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="kt-portlet__body">
|
||||
<form action="{{ route('products.update', $product->id) }}" method="POST" id="productForm">
|
||||
@csrf
|
||||
@method('PUT') {{-- Correctly spoof PUT method --}}
|
||||
|
||||
{{-- Product Info --}}
|
||||
<div class="form-group">
|
||||
<label for="code"><strong>Kode Produk</strong></label>
|
||||
<input type="text" name="code" id="code" class="form-control" value="{{ old('code', $product->code) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name"><strong>Nama Produk</strong></label>
|
||||
<input type="text" name="name" id="name" class="form-control" value="{{ old('name', $product->name) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="description"><strong>Deskripsi</strong></label>
|
||||
<textarea name="description" id="description" class="form-control" rows="3">{{ old('description', $product->description) }}</textarea>
|
||||
</div>
|
||||
|
||||
{{-- Product Category --}}
|
||||
<div class="form-group">
|
||||
<label for="product_category_id"><strong>Kategori Produk</strong></label>
|
||||
<select name="product_category_id" id="product_category_id" class="form-control" required>
|
||||
<option value="">-- Pilih Kategori --</option>
|
||||
@foreach ($categories as $category)
|
||||
<option value="{{ $category->id }}" disabled style="background-color: #f0f0f0;">
|
||||
{{ $category->name }}
|
||||
</option>
|
||||
@foreach ($category->children as $child)
|
||||
<option value="{{ $child->id }}" {{ $child->id == old('product_category_id', $product->product_category_id) ? 'selected' : '' }}>
|
||||
{{ $child->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{-- Stok per Dealer --}}
|
||||
<div id="dealerData" data-dealers='@json($dealers)'></div>
|
||||
<div class="form-group">
|
||||
<label><strong>Stok per Dealer</strong></label>
|
||||
<div id="dynamicDealerRows">
|
||||
@foreach($product->dealers as $index => $dealer)
|
||||
<div class="form-group row align-items-center dealer-stock-row">
|
||||
<div class="col-md-6">
|
||||
<select name="dealer_stock[{{ $index }}][dealer_id]" class="form-control">
|
||||
<option value="">-- Pilih Dealer --</option>
|
||||
@foreach ($dealers as $d)
|
||||
<option value="{{ $d->id }}" {{ $d->id == $dealer->id ? 'selected' : '' }}>
|
||||
{{ $d->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<input type="number" name="dealer_stock[{{ $index }}][quantity]" value="{{ $dealer->pivot->quantity }}" class="form-control" placeholder="Jumlah Stok" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="button" class="btn btn-danger btn-sm remove-dealer-row">Hapus</button>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<button type="button" id="addDealerRow" class="btn btn-outline-primary mt-2">➕ Tambah Dealer</button>
|
||||
</div>
|
||||
|
||||
{{-- Submit --}}
|
||||
<div class="form-group mt-4">
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
<a href="{{ route('products.index') }}" class="btn btn-secondary">Batal</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('javascripts')
|
||||
<script src="{{ mix('js/warehouse_management/products/edit.js') }}"></script>
|
||||
@endsection
|
||||
@@ -8,14 +8,14 @@
|
||||
<i class="kt-font-brand flaticon2-line-chart"></i>
|
||||
</span>
|
||||
<h3 class="kt-portlet__head-title">
|
||||
Produk
|
||||
Tabel Produk
|
||||
</h3>
|
||||
</div>
|
||||
@can('create', $menus['product_categories.index'])
|
||||
<div class="kt-portlet__head-toolbar">
|
||||
<div class="kt-portlet__head-wrapper">
|
||||
<div class="kt-portlet__head-actions">
|
||||
<button type="button" class="btn btn-bold btn-label-brand btn-sm" id="addProductCategory"> Tambah </button>
|
||||
<a href="{{ route('products.create') }}" class="btn btn-bold btn-label-brand btn--sm">Tambah</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -28,7 +28,6 @@
|
||||
<table class="table table-striped table-bordered table-hover" id="products-table" data-url="{{ route("products.index") }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>NO</th>
|
||||
<th>Kode</th>
|
||||
<th>Nama</th>
|
||||
<th>Kategori</th>
|
||||
|
||||
Reference in New Issue
Block a user