Browse Source

Update: Api mobile

master
unknown 1 year ago
parent
commit
cc2afbf4d6
  1. 44
      app/Http/Controllers/PengembalianController.php
  2. 10
      app/Models/asset_status.php
  3. 110
      composer.lock
  4. 81
      resources/views/dashboard/Pengembalian/edit.blade.php
  5. 2
      resources/views/dashboard/Pengembalian/index.blade.php

44
app/Http/Controllers/PengembalianController.php

@ -63,18 +63,32 @@ class PengembalianController extends Controller
public function update(Request $request, $id)
{
$request->validate([
'asset_id' => 'required',
'peti_id' => 'required',
'exit_at' => 'required',
'exit_pic' => 'required',
'est_pengembalian' => 'required',
'exit_warehouse' => 'required',
'enter_at' => 'required',
'enter_pic' => 'required',
'enter_warehouse' => 'required',
'kondisi_peti' => 'required',
]);
try {
$peminjaman = asset_status::findOrFail($id);
$peminjaman['updated_by'] = Auth::user()->fullname; // Menambahkan ID pengguna sebagai updated_by
$peminjaman->update($request->all());
// Update atribut-atribut yang diperlukan
$peminjaman->enter_pic = Auth::user()->id;
$peminjaman->updated_by = Auth::user()->id;
$peminjaman->peti_id = $request->input('peti_id');
$peminjaman->exit_at = $request->input('exit_at');
$peminjaman->est_pengembalian = $request->input('est_pengembalian');
$peminjaman->exit_warehouse = $request->input('exit_warehouse');
$peminjaman->enter_at = $request->input('enter_at');
$peminjaman->enter_warehouse = $request->input('enter_warehouse');
$peminjaman->kondisi_peti = $request->input('kondisi_peti');
// dd($peminjaman);
$peminjaman->save();
return redirect()->route('dashboard.pengembalian.index')->with('success', 'Data peminjaman berhasil diperbaharui');
} catch (\Throwable $th) {
@ -85,21 +99,29 @@ class PengembalianController extends Controller
// public function update(Request $request, $id)
// {
// // dd($request->all());
// $request->validate([
// 'asset_id' => 'required',
// 'peti_id' => 'required',
// 'exit_at' => 'required',
// 'exit_pic' => 'required',
// 'est_pengembalian' => 'required',
// 'exit_warehouse' => 'required',
// 'enter_at' => 'required',
// 'enter_pic' => 'required',
// 'enter_warehouse' => 'required',
// 'kondisi_peti' => 'required',
// ]);
// // dd($request);
// try {
// $peminjaman = asset_status::findOrFail($id);
// $peminjaman['updated_by'] = Auth::user()->fullname; // Menambahkan ID pengguna sebagai updated_by
// $peminjaman['enter_pic'] = Auth::user()->id; // Menambahkan ID pengguna sebagai updated_by
// $peminjaman['updated_by'] = Auth::user()->id; // Menambahkan ID pengguna sebagai updated_by
// dd($peminjaman);
// $peminjaman->update($request->all());
// return redirect()->route('pengembalian.index')->with('success', 'Data peminjaman berhasil diperbaharui');
// return redirect()->route('dashboard.pengembalian.index')->with('success', 'Data peminjaman berhasil diperbaharui');
// } catch (\Throwable $th) {
// return redirect()->back()->with('error', 'Data peminjaman gagal diperbaharui');
// // Tampilkan pesan kesalahan untuk debugging
// return redirect()->back()->with('error', 'Data peminjaman gagal diperbaharui: ' . $th->getMessage());
// }
// }

10
app/Models/asset_status.php

@ -17,12 +17,12 @@ class asset_status extends Model
'peti_id', //sudah
'exit_at', //sudah
'est_pengembalian', //sudah
'exit_pic', //sudah
'exit_pic', // di controler
'exit_warehouse', //sudah
'enter_at',
'enter_pic',
'enter_warehouse',
'kondisi_peti',
'enter_at', // //sudah
'enter_pic', // //sudah
'enter_warehouse', // //sudah
'kondisi_peti', // //sudah
'created_by',
'updated_by',
];

110
composer.lock generated

@ -1811,6 +1811,7 @@
},
{
"name": "lcobucci/clock",
<<<<<<< HEAD
"version": "3.0.0",
"source": {
"type": "git",
@ -1821,11 +1822,27 @@
"type": "zip",
"url": "https://api.github.com/repos/lcobucci/clock/zipball/039ef98c6b57b101d10bd11d8fdfda12cbd996dc",
"reference": "039ef98c6b57b101d10bd11d8fdfda12cbd996dc",
=======
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/lcobucci/clock.git",
"reference": "c7aadcd6fd97ed9e199114269c0be3f335e38876"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lcobucci/clock/zipball/c7aadcd6fd97ed9e199114269c0be3f335e38876",
"reference": "c7aadcd6fd97ed9e199114269c0be3f335e38876",
>>>>>>> 549f8b9a361a5f1f70601f56ab3f8b0290f617ad
"shasum": ""
},
"require": {
"php": "~8.1.0 || ~8.2.0",
<<<<<<< HEAD
"psr/clock": "^1.0"
=======
"stella-maris/clock": "^0.1.7"
>>>>>>> 549f8b9a361a5f1f70601f56ab3f8b0290f617ad
},
"provide": {
"psr/clock-implementation": "1.0"
@ -1859,7 +1876,11 @@
"description": "Yet another clock abstraction",
"support": {
"issues": "https://github.com/lcobucci/clock/issues",
<<<<<<< HEAD
"source": "https://github.com/lcobucci/clock/tree/3.0.0"
=======
"source": "https://github.com/lcobucci/clock/tree/2.3.0"
>>>>>>> 549f8b9a361a5f1f70601f56ab3f8b0290f617ad
},
"funding": [
{
@ -1871,45 +1892,51 @@
"type": "patreon"
}
],
<<<<<<< HEAD
"time": "2022-12-19T15:00:24+00:00"
=======
"time": "2022-12-19T14:38:11+00:00"
>>>>>>> 549f8b9a361a5f1f70601f56ab3f8b0290f617ad
},
{
"name": "lcobucci/jwt",
"version": "4.3.0",
"version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/lcobucci/jwt.git",
"reference": "4d7de2fe0d51a96418c0d04004986e410e87f6b4"
"reference": "55564265fddf810504110bd68ca311932324b0e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lcobucci/jwt/zipball/4d7de2fe0d51a96418c0d04004986e410e87f6b4",
"reference": "4d7de2fe0d51a96418c0d04004986e410e87f6b4",
"url": "https://api.github.com/repos/lcobucci/jwt/zipball/55564265fddf810504110bd68ca311932324b0e9",
"reference": "55564265fddf810504110bd68ca311932324b0e9",
"shasum": ""
},
"require": {
"ext-hash": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-sodium": "*",
"lcobucci/clock": "^2.0 || ^3.0",
"lcobucci/clock": "^2.0",
"php": "^7.4 || ^8.0"
},
"require-dev": {
"infection/infection": "^0.21",
"infection/infection": "^0.20",
"lcobucci/coding-standard": "^6.0",
"mikey179/vfsstream": "^1.6.7",
"phpbench/phpbench": "^1.2",
"mikey179/vfsstream": "^1.6",
"phpbench/phpbench": "^0.17",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/php-invoker": "^3.1",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"psr-4": {
"Lcobucci\\JWT\\": "src"
@ -1933,7 +1960,7 @@
],
"support": {
"issues": "https://github.com/lcobucci/jwt/issues",
"source": "https://github.com/lcobucci/jwt/tree/4.3.0"
"source": "https://github.com/lcobucci/jwt/tree/4.0.4"
},
"funding": [
{
@ -1945,7 +1972,7 @@
"type": "patreon"
}
],
"time": "2023-01-02T13:28:00+00:00"
"time": "2021-09-28T19:18:28+00:00"
},
{
"name": "league/commonmark",
@ -4442,6 +4469,53 @@
},
"time": "2021-02-08T20:43:55+00:00"
},
{
"name": "stella-maris/clock",
"version": "0.1.7",
"source": {
"type": "git",
"url": "https://github.com/stella-maris-solutions/clock.git",
"reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stella-maris-solutions/clock/zipball/fa23ce16019289a18bb3446fdecd45befcdd94f8",
"reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8",
"shasum": ""
},
"require": {
"php": "^7.0|^8.0",
"psr/clock": "^1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"StellaMaris\\Clock\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Heigl",
"role": "Maintainer"
}
],
"description": "A pre-release of the proposed PSR-20 Clock-Interface",
"homepage": "https://gitlab.com/stella-maris/clock",
"keywords": [
"clock",
"datetime",
"point in time",
"psr20"
],
"support": {
"source": "https://github.com/stella-maris-solutions/clock/tree/0.1.7"
},
"time": "2022-11-25T16:15:06+00:00"
},
{
"name": "symfony/console",
"version": "v6.3.4",

81
resources/views/dashboard/Pengembalian/edit.blade.php

@ -16,63 +16,34 @@
@method('PUT')
<div class="form-group">
<label for="peti_id" class="col-form-label">Pilih Detail Peti:</label>
<select class="form-control" name="peti_id" type="text" id="peti_id">
<option disabled selected>Pilih Detail Peti</option>
@foreach ($peti as $data_peti)
<option value="{{ $data_peti->id }}" data-warehouse-id="{{ $data_peti->warehouse_id }}">
{{ $data_peti->fix_lot }}
</option>
@endforeach
</select>
<label for="exit_at" class="col-form-label">Tanggal Peminjaman:</label>
<input class="form-control" name="exit_at" type="date" id="exit_at" value="{{ old('exit_at') }}"
placeholder="Masukan Tanggal Peminjaman" required>
<label for="est_pengembalian" class="col-form-label">Estimasi Tanggal Pengembalian:</label>
<input class="form-control" name="est_pengembalian" type="date" id="est_pengembalian"
value="{{ old('est_pengembalian') }}" placeholder="Masukan Estimasi Tanggal Peminjaman" required>
<label for="exit_warehouse" class="col-form-label">Asal Gudang :</label>
<select class="form-control" name="exit_warehouse" type="text" id="exit_warehouse">
<option disabled selected>Pilih Asal Gudang</option>
@foreach ($warehouse as $data)
<option value="{{ $data->id }}">{{ $data->name }}</option>
@endforeach
</select>
<div>
<input class="form-control" hidden name="peti_id" type="text" id="peti_id"
value="{{ $peminjaman->peti_id }}" readonly>
<input class="form-control" value="{{ $peminjaman->peti->fix_lot }}" readonly>
</div>
{{--
<!-- Elemen input readonly untuk menampilkan nama aset -->
<label for="asset_name" class="col-form-label">Nama Asset:</label>
<input class="form-control" name="asset_name" type="text" id="asset_name"
value="{{ $peminjaman->asset->name }}" readonly required>
<label for="exit_at" class="col-form-label">Tanggal Peminjaman:</label>
<input class="form-control" name="exit_at" type="date" id="exit_at"
value="{{ \Carbon\Carbon::parse($peminjaman->exit_at)->format('Y-m-d') }}"
placeholder="Masukan Tanggal Keluar" readonly required>
value="{{ $peminjaman->exit_at }}" readonly>
<label for="exit_pic" class="col-form-label">PJ Keluar:</label>
<input class="form-control" name="exit_pic" type="text" id="exit_pic"
value="{{ $peminjaman->exit_pic }}" placeholder="Masukan Nama PJ Keluar" readonly required>
<label for="est_pengembalian" class="col-form-label">Estimasi Tanggal Pengembalian:</label>
<input class="form-control" name="est_pengembalian" type="date" id="est_pengembalian"
value="{{ $peminjaman->est_pengembalian }}" readonly>
<label for="exit_warehouse" class="col-form-label">Asal Gudang :</label>
<input type="hidden" name="exit_warehouse" id="exit_warehouse"
value="{{ $peminjaman->exit_warehouse }}">
<input class="form-control" type="text" value="{{ $peminjaman->warehouse->name }}" readonly required>
<div>
<input class="form-control" hidden name="exit_warehouse" type="text" id="exit_warehouse"
value="{{ $peminjaman->exit_warehouse }}" readonly>
<input class="form-control" value="{{ $peminjaman->warehouse->name }}" readonly>
</div>
<label for="enter_at" class="col-form-label">Tanggal Pengembalian:</label>
<input class="form-control" name="enter_at" type="date" id="enter_at"
value="{{ \Carbon\Carbon::parse($peminjaman->enter_at)->format('Y-m-d') }}"
placeholder="Masukan Tanggal Asset" required>
<label for="enter_pic" class="col-form-label">PJ Pengembalian:</label>
<input class="form-control" name="enter_pic" type="text" id="enter_pic"
value="{{ old('enter_pic', $peminjaman->enter_pic) }}" placeholder="Masukan Nama PJ Pengembalian"
pattern="[^0-9]+" oninput="this.value=this.value.replace(/[0-9]/g,'');" required>
value="{{ \Carbon\Carbon::parse($peminjaman->enter_at)->format('Y-m-d') }}" required>
<label for="enter_warehouse" class="col-form-label">Tujuan Pengembalian Gudang:</label>
<select class="form-control" name="enter_warehouse" type="text" id="enter_warehouse">
<option disabled selected>Pilih Nama Asset</option>
<option disabled selected>Pilih Tujuan Gudang</option>
@foreach ($warehouse as $data_warehouse)
<option value="{{ $data_warehouse->id }}"
@if ($data_warehouse->id == $peminjaman->enter_warehouse) selected
@ -80,9 +51,29 @@
{{ $data_warehouse->name }}</option>
@endforeach
</select>
<label for="kondisi_peti" class="col-form-label">Kondisi Peti:</label>
<input class="form-control" name="kondisi_peti" type="text" id="kondisi_peti"
value="{{ old('kondisi_peti', $peminjaman->kondisi_peti) }}" placeholder="Masukan kondisi peti"
pattern="[^0-9]+" oninput="this.value=this.value.replace(/[0-9]/g,'');" required>
</div>
{{--
</div> --}}
<div class="modal-footer d-flex justify-content-center">
<a href="{{ route('dashboard.peminjaman.index') }}" class="btn btn-secondary">Kembali</a>
<a href="{{ route('dashboard.pengembalian.index') }}" class="btn btn-secondary">Kembali</a>
<button type="submit" class="btn btn-primary">Simpan</button>
</div>
</form>

2
resources/views/dashboard/Pengembalian/index.blade.php

@ -22,6 +22,7 @@
<th>No</th>
<th>Kode Peti</th>
<th>Tgl Peinjaman</th>
<th>Estimasi Pengembalian</th>
<th>PJ Peminjaman</th>
<th>Asal WH Peminjaman</th>
<th>Tgl Pengembalian</th>
@ -45,6 +46,7 @@
<td>{{ $data->peti->customer->code_customer }} -
{{ $data->peti->tipe_peti->type }}</td>
<td>{{ \Carbon\Carbon::parse($data->exit_at)->format('d/m/Y') }}</td>
<td>{{ \Carbon\Carbon::parse($data->est_pengembalian)->format('d/m/Y') }}</td>
<td>{{ $data->exit_pic }}</td>
<td>{{ $data->warehouse->name }}</td>
<td>

Loading…
Cancel
Save