From e11c5112080b3c3f9edf2d82d10f22d424fc0773 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 25 Sep 2022 08:51:11 +0800 Subject: [PATCH] fix terima/serah marhun penilai --- app/Http/Controllers/MarhunController.php | 134 ++++++++++++------ .../Mobile/LelongMobileController.php | 2 +- app/Models/CawanganLelong.php | 8 +- app/Models/Lelong.php | 5 + resources/views/includes/sidebar.blade.php | 4 +- resources/views/marhun/marhun.blade.php | 21 ++- .../marhun/senarailelongterimaserah.blade.php | 56 ++++++++ .../views/marhun/terimaserahmarhun.blade.php | 1 + .../views/pengesahan/mutumarhun.blade.php | 3 +- routes/web.php | 3 +- 10 files changed, 178 insertions(+), 59 deletions(-) create mode 100644 resources/views/marhun/senarailelongterimaserah.blade.php diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index 8fa3ec89..c4b54edb 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -360,24 +360,43 @@ class MarhunController extends Controller $lelongbid = LelongBid::where('id','=',$lelongBidMarhun->lelongbid_id)->first(); $lelong = Lelong::where('id','=',$lelongbid->lelong_id)->first(); - $perluPengesahan = false; - $parameterBezaBerat = 0.3; + // $perluPengesahan = false; + $parameterBezaBerat = 0.3; //parameterBezaBerat = (berat sebelum) - (berat selepas) $bezaBerat = $lelongBidMarhun->berat - $request->berat_emas; if ($bezaBerat > $parameterBezaBerat) { - $perluPengesahan = true; - $lelongBidMarhun->berat = $request->berat_emas; - $lelongBidMarhun->update(); + $pengesahan = new Pengesahan; + $pengesahan->lelong_id = $lelong->id; + $pengesahan->lelongbid_id = $lelongbid->id; + $pengesahan->lelongbidmarhun_id = $lelongBidMarhun->id; + $pengesahan->norujukan = $lelongbid->norujukan; + $pengesahan->diminta_oleh = $user->id; + $pengesahan->diminta_pada = $currentdate; + $pengesahan->status_ubah = 4; + $pengesahan->request_data = $request->berat_emas; + $pengesahan->save(); } else if ($lelongBidMarhun->karat > $request->karat) { - $perluPengesahan = true; - $lelongBidMarhun->karat = $request->karat; - $lelongBidMarhun->update(); - } else { - $lelongBidMarhun->id; + $pengesahan = new Pengesahan; + $pengesahan->lelong_id = $lelong->id; + $pengesahan->lelongbid_id = $lelongbid->id; + $pengesahan->lelongbidmarhun_id = $lelongBidMarhun->id; + $pengesahan->norujukan = $lelongbid->norujukan; + $pengesahan->diminta_oleh = $user->id; + $pengesahan->diminta_pada = $currentdate; + $pengesahan->status_ubah = 1; + $pengesahan->request_data = $request->karat; + $pengesahan->save(); + } + else { + // $lelongBidMarhun->id; $lelongBidMarhun->marhun = $request->marhun; + $lelongBidMarhun->old_berat = $lelongBidMarhun->berat; + $lelongBidMarhun->old_karat = $lelongBidMarhun->karat; + $lelongBidMarhun->old_nmarhun = $lelongBidMarhun->n_marhun; $lelongBidMarhun->berat = $request->berat_emas; $lelongBidMarhun->karat = $request->karat; + $lelongBidMarhun->n_marhun = $request->berat_emas * $lelongBidMarhun->harga; $lelongBidMarhun->update(); // $existingPengesahan = Pengesahan::where('lelongbidmarhun_id', '=', $request->idmarhun) @@ -385,34 +404,37 @@ class MarhunController extends Controller // ->delete(); } - if ($perluPengesahan == true) { - $pengesahan = Pengesahan::where('lelongbidmarhun_id', $request->idmarhun) - ->where('lelongbid_id', $lelongBidMarhun->lelongbid_id) - ->first(); + // if ($perluPengesahan == true) { + // $pengesahan = Pengesahan::where('lelongbidmarhun_id', $request->idmarhun) + // ->where('lelongbid_id', $lelongBidMarhun->lelongbid_id) + // ->first(); - if(!$pengesahan) - { - $pengesahan = new Pengesahan; - $pengesahan->lelong_id = $lelong->id; - $pengesahan->lelongbid_id = $lelongbid->id; - $pengesahan->lelongbidmarhun_id = $lelongBidMarhun->id; - $pengesahan->norujukan = $lelongbid->norujukan; - $pengesahan->diminta_oleh = $user->id; - $pengesahan->diminta_pada = $currentdate; - $pengesahan->status_ubah = 1; - $pengesahan->save(); - } else { - $pengesahan->id; - $pengesahan->lelong_id = $lelong->id; - $pengesahan->lelongbid_id = $lelongbid->id; - $pengesahan->lelongbidmarhun_id = $lelongBidMarhun->id; - $pengesahan->norujukan = $lelongbid->norujukan; - $pengesahan->diminta_oleh = $user->id; - $pengesahan->diminta_pada = $currentdate; - $pengesahan->status_ubah = 1; - $pengesahan->update(); - } - } + // if(!$pengesahan) + // { + + // $pengesahan = new Pengesahan; + // $pengesahan->lelong_id = $lelong->id; + // $pengesahan->lelongbid_id = $lelongbid->id; + // $pengesahan->lelongbidmarhun_id = $lelongBidMarhun->id; + // $pengesahan->norujukan = $lelongbid->norujukan; + // $pengesahan->diminta_oleh = $user->id; + // $pengesahan->diminta_pada = $currentdate; + // $pengesahan->status_ubah = 1; + // $pengesahan->save(); + + // } else { + // $pengesahan->id; + // $pengesahan->lelong_id = $lelong->id; + // $pengesahan->lelongbid_id = $lelongbid->id; + // $pengesahan->lelongbidmarhun_id = $lelongBidMarhun->id; + // $pengesahan->norujukan = $lelongbid->norujukan; + // $pengesahan->diminta_oleh = $user->id; + // $pengesahan->diminta_pada = $currentdate; + // $pengesahan->status_ubah = 1; + // $pengesahan->update(); + // } + // } + // dd($lelongBidMarhun); // $totallelbid = LelongBid::where('id', $lelongBidMarhun->lelongbid_id)->first(); // dd($totallelbid); @@ -472,6 +494,15 @@ class MarhunController extends Controller } + + public function senaraiLelongTerimaSerah() + { + + $lelong = Lelong::orderBy('id', 'desc')->get(); + + return view('marhun.senarailelongterimaserah', compact('lelong')); + } + public function senarailelongscan(Request $request){ $user = Auth::user(); @@ -1176,25 +1207,34 @@ class MarhunController extends Controller } - public function terimaserahmarhun() + public function terimaserahmarhun($lelong_id) { $user = Auth::user(); $caw = Cawangan::where('caw_code', '=', $user->kodcaw)->first(); $senaraiScanKeluar = ScanMarhun::where('kodcaw', '=', $caw->caw_code) + ->where('lelong_id', $lelong_id) ->whereNull('masa_terima') ->orderBy('id', 'desc') ->get(); - $sedangDinilai = ScanMarhun::whereNull('masa_serah') - ->orderBy('id', 'desc') - ->get(); + $sedangDinilai = ScanMarhun::where('kodcaw', '=', $caw->caw_code) + ->whereNull('masa_serah') + ->where('lelong_id', $lelong_id) + ->orderBy('id', 'desc') + ->get(); - $sudahSerah = ScanMarhun::whereNotNull('masa_serah') - ->orderBy('id', 'desc') - ->get(); + $sudahSerah = ScanMarhun::where('kodcaw', '=', $caw->caw_code) + ->whereNotNull('masa_serah') + ->where('lelong_id', $lelong_id) + ->orderBy('id', 'desc') + ->get(); - return view('marhun.terimaserahmarhun', compact('senaraiScanKeluar', 'sedangDinilai', 'sudahSerah')); + if ($senaraiScanKeluar || $sedangDinilai || $sudahSerah) { + return view('marhun.terimaserahmarhun', compact('senaraiScanKeluar', 'sedangDinilai', 'sudahSerah')); + } else { + return redirect()->route('marhun.senarailelongterimaserah')->with('failed', 'Tiada Surat Untuk Dilelong Pada Tarikh Ini.'); + } } public function terimaMarhun(Request $request) @@ -1208,7 +1248,7 @@ class MarhunController extends Controller $terimaMarhun->masa_terima = $current->toTimeString(); $terimaMarhun->update(); } - return redirect()->route('marhun.terimaserahmarhun')->with('success', 'Terima Marhun Berjaya Direkodkan'); + return redirect()->route('marhun.terimaserahmarhun', $terimaMarhun->lelong_id)->with('success', 'Terima Marhun Berjaya Direkodkan'); } public function serahMarhun(Request $request) @@ -1221,7 +1261,7 @@ class MarhunController extends Controller $serahMarhun->masa_serah = $current->toTimeString(); $serahMarhun->update(); } - return redirect()->route('marhun.terimaserahmarhun')->with('success', 'Serah Marhun Berjaya Direkodkan'); + return redirect()->route('marhun.terimaserahmarhun', $serahMarhun->lelong_id)->with('success', 'Serah Marhun Berjaya Direkodkan'); } public function listScanBarcode($lelong_id) diff --git a/app/Http/Controllers/Mobile/LelongMobileController.php b/app/Http/Controllers/Mobile/LelongMobileController.php index 531b0e9b..78802c0c 100644 --- a/app/Http/Controllers/Mobile/LelongMobileController.php +++ b/app/Http/Controllers/Mobile/LelongMobileController.php @@ -1014,7 +1014,7 @@ class LelongMobileController extends Controller $lelong[$index]['status'] = $status; } - if (empty($lelong)) { + if (!empty($lelong)) { return response()->json([ 'success' => true, 'lelong' => $lelong, diff --git a/app/Models/CawanganLelong.php b/app/Models/CawanganLelong.php index ba55f40f..fa3addcb 100644 --- a/app/Models/CawanganLelong.php +++ b/app/Models/CawanganLelong.php @@ -26,7 +26,13 @@ class CawanganLelong extends Model 'lokasi' ]; - public function lelongBid(){ + public function lelongBid() + { return $this->hasMany(LelongBid::class, 'caw_id', 'caw_id'); } + + public function cawangan() + { + return $this->hasOne(Cawangan::class, 'id'); + } } diff --git a/app/Models/Lelong.php b/app/Models/Lelong.php index 1b53360d..2433b8e2 100644 --- a/app/Models/Lelong.php +++ b/app/Models/Lelong.php @@ -20,4 +20,9 @@ class Lelong extends Model 'cajlelong', 'sts_lelong' ]; + + public function cawanganLelong() + { + return $this->hasMany(CawanganLelong::class, 'lelong_id'); + } } diff --git a/resources/views/includes/sidebar.blade.php b/resources/views/includes/sidebar.blade.php index 4ab5ebf5..4be85a69 100644 --- a/resources/views/includes/sidebar.blade.php +++ b/resources/views/includes/sidebar.blade.php @@ -65,8 +65,8 @@ @endhasrole @hasrole('penilai') -
  • - Terima/Serah Marhun +
  • + Terima/Serah Marhun
  • Semakan Marhun diff --git a/resources/views/marhun/marhun.blade.php b/resources/views/marhun/marhun.blade.php index f0eac3c6..5def0387 100644 --- a/resources/views/marhun/marhun.blade.php +++ b/resources/views/marhun/marhun.blade.php @@ -126,11 +126,6 @@ @@ -286,8 +285,12 @@ @endif @@ -319,8 +322,12 @@ @@ -349,8 +356,12 @@ diff --git a/resources/views/marhun/senarailelongterimaserah.blade.php b/resources/views/marhun/senarailelongterimaserah.blade.php new file mode 100644 index 00000000..f394d1ec --- /dev/null +++ b/resources/views/marhun/senarailelongterimaserah.blade.php @@ -0,0 +1,56 @@ +@extends('layouts.app') + +@section('content') + +
    +
    +
    +
    +
    +

    Terima Serah Marhun

    + @if ($message = Session::get('success')) +
    +

    {{ $message }}

    +
    + @elseif ($message = Session::get('failed')) +
    +

    {{ $message }}

    +
    + @endif + + + + + + + + + + @foreach ($lelong as $index) + + + + + @if($index->sts_lelong == 0) + + @endif + + + @endforeach + +
    BilBatch LelongTarikh LelongStatus LelongTindakan
    {{$loop->iteration}}{{$index->id}}{{$index->tarikh_lelong}} + + + +
    +
    +
    +
    +
    +
    + + + +@endsection \ No newline at end of file diff --git a/resources/views/marhun/terimaserahmarhun.blade.php b/resources/views/marhun/terimaserahmarhun.blade.php index a54fef90..892560c5 100644 --- a/resources/views/marhun/terimaserahmarhun.blade.php +++ b/resources/views/marhun/terimaserahmarhun.blade.php @@ -17,6 +17,7 @@

    {{ $message }}

    @endif + Kembali