diff --git a/app/Http/Controllers/Api/V1/ParkingOperationController.php b/app/Http/Controllers/Api/V1/ParkingOperationController.php
new file mode 100644
index 0000000..ba52735
--- /dev/null
+++ b/app/Http/Controllers/Api/V1/ParkingOperationController.php
@@ -0,0 +1,118 @@
+show($request->input('transaksi'))->getData();
+
+ // dd($transaksi)->status;
+ // dd($transaksi->getData());
+ Log::info(get_class($transaksi));
+ dd(get_class($transaksi));
+ // if ($transaksi->status === true && $transaksi->member === false) {
+ // }
+ return;
+
+ }
+
+ /**
+ * Display the specified resource.
+ *
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function show($id)
+ {
+ $transaksi = TransaksiParkir::where('no_pol','LIKE', '%' .$id . '%')->first();
+
+ if (!$transaksi) {
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Kendaraan belum masuk atau transaksi tidak ditemukan'
+ ]);
+ }
+
+ $isMember = $transaksi->status_transaksi == '3' ? true : false;
+
+ return response()->json([
+ 'status' => true,
+ 'member' => $isMember,
+ 'data' => [
+ 'id' => $transaksi->id,
+ 'no_pol' => $transaksi->no_pol,
+ 'id_kendaraan' => $transaksi->id_mobil,
+ 'waktu_masuk' => $transaksi->waktu_masuk,
+ 'status' => $transaksi->status,
+ 'status_transaksi' => $transaksi->status_transaksi
+ ]
+ ]);
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ *
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function edit($id)
+ {
+ //
+ }
+
+ /**
+ * Update the specified resource in storage.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function update(Request $request, $id)
+ {
+ //
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ *
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function destroy($id)
+ {
+ //
+ }
+}
diff --git a/app/Http/Controllers/Apps/ModifiedTransaksi.php b/app/Http/Controllers/Apps/ModifiedTransaksi.php
index de660b7..eb2e29d 100644
--- a/app/Http/Controllers/Apps/ModifiedTransaksi.php
+++ b/app/Http/Controllers/Apps/ModifiedTransaksi.php
@@ -62,7 +62,7 @@ public function show($id)
// } else (
// $condition = where('no_pol', $id);
// )
- // $vehicle = JenisMobil::all();
+ // $vehicle = VehicleItem::all();
// $data = TransaksiParkir::select('no_pol','waktu_masuk','waktu_keluar','jm.nama as vehicle','id_kendaraan','np.nama as gateIn', 'id_pintu_masuk','jm.nama as vehiclename')
// ->leftJoin('jenis_mobil as jm', 'jm.id', '=', 'transaksi_parkir.id_kendaraan')
// ->leftJoin('nama_pos as np', 'np.id', '=', 'transaksi_parkir.id_pintu_masuk')
@@ -76,7 +76,7 @@ public function show($id)
// ]);
Log::info('ID: ' . $id);
- $vehicle = JenisMobil::all();
+ $vehicle = VehicleItem::all();
$query = TransaksiParkir::select(
'no_pol',
diff --git a/app/Http/Controllers/Http/Setup/Vehicle/MasterVehicleController.php b/app/Http/Controllers/Http/Setup/Vehicle/MasterVehicleController.php
new file mode 100644
index 0000000..ee651ee
--- /dev/null
+++ b/app/Http/Controllers/Http/Setup/Vehicle/MasterVehicleController.php
@@ -0,0 +1,90 @@
+get();
+
+ // dd($vehicle);
+
+ return view ('setup.vehicle.vehicle', compact('vehicle'));
+ }
+
+ /**
+ * Show the form for creating a new resource.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function create()
+ {
+ //
+ }
+
+ /**
+ * Store a newly created resource in storage.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return \Illuminate\Http\Response
+ */
+ public function store(Request $request)
+ {
+ //
+ }
+
+ /**
+ * Display the specified resource.
+ *
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function show($id)
+ {
+ //
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ *
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function edit($id)
+ {
+ //
+ }
+
+ /**
+ * Update the specified resource in storage.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function update(Request $request, $id)
+ {
+ //
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ *
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function destroy($id)
+ {
+ //
+ }
+}
diff --git a/app/Http/Controllers/Http/Setup/Vehicle/ModifiedVehiclepriceController.php b/app/Http/Controllers/Http/Setup/Vehicle/ModifiedVehiclepriceController.php
new file mode 100644
index 0000000..a3104dd
--- /dev/null
+++ b/app/Http/Controllers/Http/Setup/Vehicle/ModifiedVehiclepriceController.php
@@ -0,0 +1,130 @@
+where('id_mobil', $id)->first();
+
+ Log::info(json_encode($vehicleRates));
+ return $vehicleRates;
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ *
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function edit($id)
+ {
+ //
+ }
+
+ /**
+ * Update the specified resource in storage.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function update(Request $request, $id)
+ {
+ // Log::info($request->all());
+ // $id = $request->id_mobil;
+
+ $dataQuery = MasterTarif::find($id);
+ try {
+
+ Log::info($request->all());
+
+ $dataQuery->fill($request->all());
+
+ if (! $dataQuery->isDirty()) {
+ // if($dataQuery->isDirty()) {
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Tidak ada perubahan data'
+ ]);
+ // }
+
+ }
+ Log::info('Data yang di simpan' . json_encode($dataQuery->getDirty()));
+ $dataQuery->save();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Data berhasil di ubah'
+ ]);
+ } catch (\Throwable $th) {
+ //throw $th;
+ Log::info('Data yang di simpan' . json_encode($dataQuery->getDirty()));
+
+ // Log::info($request->all());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Gagal menyimpan data ' . $th->getMessage(),
+ ]);
+ }
+
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ *
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function destroy($id)
+ {
+ //
+ }
+}
diff --git a/app/Models/JenisMobil.php b/app/Models/JenisMobil.php
deleted file mode 100644
index cb384c1..0000000
--- a/app/Models/JenisMobil.php
+++ /dev/null
@@ -1,22 +0,0 @@
- 'string',
- ];
-
- protected $fillable = [
- 'nama','short_cut'
- ];
-
-}
diff --git a/app/Models/MasterTarif.php b/app/Models/MasterTarif.php
new file mode 100644
index 0000000..150994a
--- /dev/null
+++ b/app/Models/MasterTarif.php
@@ -0,0 +1,30 @@
+belongsTo(JenisMobil::class, 'id', 'jenis_mobil');
+ return $this->belongsTo(VehicleItem::class, 'id', 'jenis_mobil');
}
}
diff --git a/app/Models/VehicleItem.php b/app/Models/VehicleItem.php
index 5c2095c..03fb477 100644
--- a/app/Models/VehicleItem.php
+++ b/app/Models/VehicleItem.php
@@ -7,12 +7,19 @@
class VehicleItem extends Model
{
- protected $connection = 'pgsql_second';
+ // protected $connection = 'pgsql_second';
protected $table = 'jenis_mobil';
+ protected $primaryKey = 'id';
public $timestamps = false;
+ protected $keyType = 'string';
+
use HasFactory;
protected $fillable = [
'id', 'nama', 'tanggal', 'short_cut', 'orang', 'validasi', 'need_access'
];
+
+ public function VehiclePrice () {
+ return $this->hasOne(MasterTarif::class, 'id', 'id_mobil');
+ }
}
diff --git a/app/Services/Parking/RateParkingService.php b/app/Services/Parking/RateParkingService.php
new file mode 100644
index 0000000..f5db873
--- /dev/null
+++ b/app/Services/Parking/RateParkingService.php
@@ -0,0 +1,86 @@
+waktu_gratis) {
+ Log::info('GP Rules : ');
+ return $parkingPrice;
+ } else if ( $tarifVehicle->waktu_gratis !== 0 && $tarifVehicle->tarif_periode !== 0) {
+ Log::info('GP Rules : ');
+ $parkingPrice = $parkingPrice + $tarifVehicle->tarif_period;
+ $duration = $duration - $tarifVehicle->waktu_gratis;
+ Log::info('Setelah GP : ' . $parkingPrice . ' Durasi parkir : ' . $duration);
+ }
+
+ ## Hitung Tarif pertama
+ $firstPrice = 0;
+ $firstDuration = $tarifVehicle->frek_interval * ($tarifVehicle->interval * 60);
+ Log::info('Firstime rules : ' . $firstDuration);
+ // if ($duration >= $firstDuration) {
+ do {
+ $duration -= ($tarifVehicle->interval * 60);
+ $parkingPrice += $tarifVehicle->tarif_interval;
+ $firstPrice++;
+ } while ($firstPrice < $tarifVehicle->frek_interval);
+ Log::info('Tarif jam pertama : ' . $parkingPrice . ' Sisa durasi : ' . $duration);
+ // }
+
+ // Log::info($firstDuration);
+ ## Hitung tarif kedua
+ $secondPrice = 1;
+ // Log::info($tarifVehicle->frek_waktu2 . ' - ' . $tarifVehicle->waktu2);
+ $secondDuration = $tarifVehicle->frek_waktu2 * ($tarifVehicle->waktu2 * 60);
+ if ($duration >= $secondDuration) {
+ Log::info('');
+ Log::info('Secondtime rules : ' . $secondDuration);
+ do {
+ $duration -= ($tarifVehicle->waktu2 * 60);
+ $parkingPrice += $tarifVehicle->tarif_interval;
+ $secondPrice++;
+ } while ($secondPrice < $tarifVehicle->frek_waktu2);
+
+ Log::info('Tarif jam kedua : ' . $parkingPrice . ' Sisa durasi : ' . $duration);
+ }
+
+ $nextDuration = 0;
+ $lastDuration = $tarifVehicle->waktu_tarif * 60;
+ if ($duration <= $lastDuration && $duration > 0) {
+ Log::info('');
+ Log::info('Sisa Durasi ' . $duration);
+ do {
+ $duration -= ($tarifVehicle->waktu_tarif * 60);
+ $parkingPrice += $tarifVehicle->tarif;
+ // $nextDuration++;
+ } while ($duration > 0);
+ Log::info('Tarif jam berikutnya : ' . $parkingPrice . ' Sisa durasi : ' . $duration);
+ }
+
+ Log::info('Tarif Parkir Anda : ' . $parkingPrice . ' Sisa durasi : ' . $duration);
+
+
+ // if ($tarifVehicle->time_base_maks == 1) {
+ // if ($parkingPrice > $tarifVehicle->maksimum) {
+ // $parkingPrice = $tarifVehicle->maksimum;
+ // }
+ // }
+
+
+
+ return $parkingPrice;
+ }
+}
\ No newline at end of file
diff --git a/public/js/setup/gate.js b/public/js/setup/gate.js
new file mode 100644
index 0000000..044d64c
--- /dev/null
+++ b/public/js/setup/gate.js
@@ -0,0 +1,160 @@
+ $(document).ready(function () {
+
+ $(document).on('click', '.hardware-button', function () {
+ let row = $(this).closest('tr');
+
+ // kalau sudah ada baris edit, hapus dulu
+ $('.edit-row').remove();
+
+ let id = $(this).data('id');
+ let nama = $(this).data('nama');
+ $.ajax({
+ url: "{{ route('hardware.show', '') }}/" + id,
+ type: 'GET',
+ success: function (r) {
+ console.log(r);
+
+ let colSpan = row.children('td').length;
+
+ // Field yang mau ditampilkan (pilih sendiri mau yang mana)
+ let fields = [
+ ['printer1_avail', 'Printer Status'],
+ ['printer1_conn', 'Printer Connection'],
+ ['printer1_spd', 'Printer Speed/Baudrate'],
+ ['video1_avail', 'Kamera Status'],
+ ['video1_conn', 'Kamera URL/Path'],
+ ['sound_avail', 'Sound Status'],
+ ['bg_avail', 'BGate Status'],
+ ['bg_conn', 'BGate Connection'],
+ ['bank_reader_avail', 'Reader BANK Status'],
+ ['bank_reader_comm', 'Reader BANK Connection'],
+ ['bank_reader_key', 'Reader BANK Key/Parameter'],
+ ];
+
+ let rows = '';
+
+ for (let i = 0; i < fields.length; i ++) {
+
+ let f1 = fields[i];
+
+ rows += `
+
+ | ${f1[1]} |
+
+ ${formatValue(f1[0], r[f1[0]])}
+
+ |
+
+ `;
+ }
+
+ let editHtml = `
+
+
+
+
+
+
+
+
+ | Setting |
+ Value |
+
+
+
+ ${rows}
+
+
+
+
+ |
+
+ `;
+
+ row.after(editHtml);
+ },
+ error: function (xhr) {
+ console.error(xhr.responseText);
+ }
+ });
+ });
+
+ // MODE EDIT
+ $(document).on('click', '.btn-edit', function () {
+
+ $('.view-mode').addClass('d-none');
+ $('.edit-mode').removeClass('d-none');
+
+ $('.btn-edit').addClass('d-none');
+ $('.btn-save, .btn-cancel').removeClass('d-none');
+ });
+
+ // CANCEL
+ $(document).on('click', '.btn-cancel', function () {
+
+ $('.edit-mode').addClass('d-none');
+ $('.view-mode').removeClass('d-none');
+
+ $('.btn-save, .btn-cancel').addClass('d-none');
+ $('.btn-edit').removeClass('d-none');
+ });
+
+ // SAVE
+ $(document).on('click', '.btn-save', function () {
+
+ let dataToSend = {};
+
+ $('.edit-mode').each(function () {
+ let key = $(this).data('key');
+ dataToSend[key] = $(this).val();
+ });
+
+ console.log(dataToSend);
+ let gateId = $('.edit-row').data('id');
+
+ $.ajax({
+ url: "{{ route('hardware.update', '') }}/" + gateId,
+ type: "PUT",
+ data: {
+ _token: "{{ csrf_token() }}",
+ data: dataToSend
+ },
+ success: function () {
+
+ $('.edit-mode').each(function () {
+ let val = $(this).val();
+ $(this).siblings('.view-mode').text(val);
+ });
+
+ $('.btn-cancel').click();
+ alert('Berhasil disimpan 🔥');
+ }
+ });
+ });
+
+ function formatValue(key, value) {
+
+ // kalau field *_avail kita kasih badge
+ if (key.includes('_avail')) {
+
+ if (value == 1) {
+ return `ON`;
+ } else {
+ return `OFF`;
+ }
+ }
+
+ // default
+ return value ?? '-';
+ }
+ });
\ No newline at end of file
diff --git a/public/js/setup/vehicle.js b/public/js/setup/vehicle.js
new file mode 100644
index 0000000..cc1f1df
--- /dev/null
+++ b/public/js/setup/vehicle.js
@@ -0,0 +1,117 @@
+$(document).ready(function () {
+
+ $.validator.addClassRules('no-spinner-time', {
+ required: true,
+ min: 1
+ });
+
+ $.validator.messages.min = "Nilai tidak boleh 0";
+
+ $('#show-tarif').validate({
+ errorClass: 'text-danger',
+
+ highlight: function(element) {
+ $(element).addClass('is-invalid');
+ },
+
+ unhighlight: function(element) {
+ $(element).removeClass('is-invalid');
+ },
+
+ errorPlacement: function(error, element) {
+ error.insertAfter(element);
+ }
+ });
+
+ $(document).on('click', '.vehicle-price', function () {
+
+
+ let id = $(this).data('id');
+ let nama = $(this).data('nama');
+ console.log(id);
+
+ let url = "{{ route('vehicle-price.show',':id') }}";
+ url = url.replace(':id', id);
+
+ $.ajax({
+ url: '/setup/master/price/' + id,
+ type: 'GET',
+ success: function (r) {
+ console.log(r);
+ $('#id_mobil').val(r.id_mobil);
+ $('.title').text('Ubah Tarif Kendaraan ' + nama);
+ $('#waktu_gratis').val(r.waktu_gratis); // waktu kurang dari n pertama
+ $('#tarif_period').val(r.tarif_period); // adalah
+ $('#frek_interval').val(r.frek_interval); // 1
+ $('#interval').val(r.interval); // X n menit pertama
+ $('#tarif_interval').val(r.tarif_interval); // adalah Rp.
+ $('#bayar_dimuka').val(r.bayar_dimuka).trigger('change');
+ $('#asuransi_incl').val(r.asuransi_incl);
+ $('#frek_waktu2').val(r.frek_waktu2); // waktu 1
+ $('#waktu2').val(r.waktu2); // xn menit berikutnya
+ $('#tarif2').val(r.tarif2); // adalah Rp.
+ $('#tarif').val(r.tarif); // tarif berikut nya
+ $('#waktu_tarif').val(r.waktu_tarif); // per n menit
+ $('#maksimum').val(r.maksimum);
+ if(r.time_base == 1) {
+ $('#maks_cond').val(r.time_base_maks).show();
+ $('#maksimum-cond').val(0).trigger('change');
+ $('.maks_cond_day').hide();
+ $('#maks_cond_day').hide();
+ } else {
+ $('#maks_cond').hide();
+ $('#maksimum-cond').val(1).trigger('change');
+ $('.maks_cond_day').show();
+ $('#maks_cond_day').val(r.min_per_hari).show();
+ }
+ $('#denda').val(r.denda);
+ $('#denda_member').val(r.denda_member);
+ }
+ });
+ });
+
+ $('#maksimum-cond').on('change', function() {
+ let selectMaxCond = $(this).val();
+ if (selectMaxCond == 0 ) {
+ $('#maks_cond').show().val(24);
+ $('.maks_cond_day').hide();
+ $('#maks_cond_day').val(1).hide();
+ } else if (selectMaxCond == 1) {
+ $('#maks_cond').hide();
+ $('.maks_cond_day').show();
+ $('#maks_cond_day').show().val(60);
+ } else {
+
+ }
+ });
+
+ $('.simpan').on('click', function () {
+
+ if (!$('#show-tarif').valid()) {
+ return false;
+ }
+
+ let vehicleRate = $('#show-tarif').serialize();
+
+ let id = $('#id_mobil').val();
+ // let url = "{{ route('vehicle.update',':id') }}";
+ let url = $(this).data('url');
+ url = url.replace(':id', id);
+ console.log(url);
+
+ $.ajax({
+ url: url,
+ type: 'PUT',
+ headers: {
+ 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
+ },
+ data: vehicleRate,
+ success: function(r) {
+ console.log(r);
+
+ $('#modal-vehicle').modal('hide');
+ }
+ });
+ });
+
+});
\ No newline at end of file
diff --git a/resources/views/layouts/guest.blade.php b/resources/views/layouts/guest.blade.php
index c904e71..de1f8ed 100644
--- a/resources/views/layouts/guest.blade.php
+++ b/resources/views/layouts/guest.blade.php
@@ -23,7 +23,7 @@
- All New Manufacture - {{ $locationSettings->namaperusahaan }}
+ ({{ $locationSettings->namalokasi }}) - All New Manufacture ({{ $locationSettings->namaperusahaan }})
diff --git a/resources/views/layouts/master.blade.php b/resources/views/layouts/master.blade.php
index 2696eaa..de4b38f 100644
--- a/resources/views/layouts/master.blade.php
+++ b/resources/views/layouts/master.blade.php
@@ -6,7 +6,7 @@
- All New Manufacture
+ ({{ $locationSettings->namalokasi }}) - All New Manufacture
diff --git a/resources/views/layouts/partial/horizontal-menu.blade.php b/resources/views/layouts/partial/horizontal-menu.blade.php
index 766d76c..7969c0b 100644
--- a/resources/views/layouts/partial/horizontal-menu.blade.php
+++ b/resources/views/layouts/partial/horizontal-menu.blade.php
@@ -24,7 +24,7 @@