diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index 8fa3ec89..b4145503 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -19,10 +19,9 @@ use App\Models\LelongBid; use App\Models\LelongBidMarhun; use App\Models\LelKarat; use App\Models\LelKarat_temp; - use App\Models\Pengesahan; use App\Models\GadaiMarhun; -use App\Models\ScanMarhun; +use App\Models\ScanSemak; use App\Models\TangguhLelong; use Carbon\Carbon; @@ -360,24 +359,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 +403,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 +493,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 +1206,35 @@ 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) - ->whereNull('masa_terima') + $senaraiScanKeluar = ScanSemak::where('kodcaw', '=', $caw->caw_code) + ->where('lelong_id', $lelong_id) + ->whereNull('terima_marhun') ->orderBy('id', 'desc') ->get(); - $sedangDinilai = ScanMarhun::whereNull('masa_serah') - ->orderBy('id', 'desc') - ->get(); + $sedangDinilai = ScanSemak::where('kodcaw', '=', $caw->caw_code) + ->whereNotNull('terima_marhun') + ->whereNull('serah_marhun') + ->where('lelong_id', $lelong_id) + ->orderBy('id', 'desc') + ->get(); - $sudahSerah = ScanMarhun::whereNotNull('masa_serah') - ->orderBy('id', 'desc') - ->get(); + $sudahSerah = ScanSemak::where('kodcaw', '=', $caw->caw_code) + ->whereNotNull('serah_marhun') + ->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) @@ -1203,12 +1243,12 @@ class MarhunController extends Controller $current = Carbon::now(); foreach ($request->scanKeluar_id as $index) { - $terimaMarhun = ScanMarhun::where('id', '=', $index)->first(); + $terimaMarhun = ScanSemak::where('id', '=', $index)->first(); $terimaMarhun->penilai_id = $user->id; - $terimaMarhun->masa_terima = $current->toTimeString(); + $terimaMarhun->terima_marhun = $current->toDateTimeString(); $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) @@ -1217,11 +1257,11 @@ class MarhunController extends Controller $current = Carbon::now(); foreach ($request->sedangDinilai_id as $index) { - $serahMarhun = ScanMarhun::where('id', '=', $index)->first(); - $serahMarhun->masa_serah = $current->toTimeString(); + $serahMarhun = ScanSemak::where('id', '=', $index)->first(); + $serahMarhun->serah_marhun = $current->toDateTimeString(); $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) @@ -1234,15 +1274,15 @@ class MarhunController extends Controller ->where('caw_id', '=', $caw->id) ->get(); - $senaraiScanKeluar = ScanMarhun::where('lelong_id', '=', $lelong_id) + $senaraiScanKeluar = ScanSemak::where('lelong_id', '=', $lelong_id) ->where('kodcaw', '=', $caw->caw_code) - ->whereNull('masa_scanmasuk') + ->whereNull('scan_masuk') ->orderBy('id', 'desc') ->get(); - $senaraiScanMasuk = ScanMarhun::where('lelong_id', '=', $lelong_id) + $senaraiScanMasuk = ScanSemak::where('lelong_id', '=', $lelong_id) ->where('kodcaw', '=', $caw->caw_code) - ->whereNotNull('masa_scanmasuk') + ->whereNotNull('scan_masuk') ->orderBy('id', 'desc') ->get(); @@ -1255,21 +1295,20 @@ class MarhunController extends Controller $user = Auth::user(); $current = Carbon::now(); - $checkExisting = ScanMarhun::where('norujukan', '=', $request->norujukan_barcode) - ->whereNull('masa_scanmasuk') + $checkExisting = ScanSemak::where('norujukan', '=', $request->norujukan_barcode) + ->whereNull('scan_masuk') ->get(); if ($checkExisting->isEmpty()) { $lelongbidItem = LelongBid::where('norujukan', '=', $request->norujukan_barcode)->first(); - $scanKeluar = new ScanMarhun; + $scanKeluar = new ScanSemak(); $scanKeluar->kodcaw = $lelongbidItem['kodcaw']; $scanKeluar->lelong_id = $lelongbidItem['lelong_id']; $scanKeluar->lelongbid_id = $lelongbidItem['id']; $scanKeluar->norujukan = $lelongbidItem['norujukan']; $scanKeluar->khazanah_id = $user['id']; - $scanKeluar->tarikh_scankeluar = $current->toDateString(); - $scanKeluar->masa_scankeluar = $current->toTimeString(); + $scanKeluar->scan_keluar = $current->toDateTimeString(); $scanKeluar->save(); return redirect()->route('marhun.scanbarcode', $request->lelong_id) @@ -1285,19 +1324,18 @@ class MarhunController extends Controller $user = Auth::user(); $current = Carbon::now(); - $scanMasuk = ScanMarhun::where('norujukan', '=', $request->norujukan_barcode) - ->whereNull('masa_scanmasuk') + $scanMasuk = ScanSemak::where('norujukan', '=', $request->norujukan_barcode) + ->whereNotNull('serah_marhun') ->first(); if ($scanMasuk) { - $scanMasuk->tarikh_scanmasuk = $current->toDateString(); - $scanMasuk->masa_scanmasuk = $current->toTimeString(); + $scanMasuk->scan_masuk = $current->toDateTimeString(); $scanMasuk->update(); return redirect()->route('marhun.scanbarcode', $request->lelong_id) ->with('success', 'Marhun Berjaya Di Scan Masuk Ke Peti Besi.'); } else { return redirect()->route('marhun.scanbarcode', $request->lelong_id) - ->with('failed', 'Marhun Gagal Di Scan Masuk Ke Peti Besi.'); + ->with('failed', 'Gagal Scan, Marhun Belum Diserah Oleh Penilai.'); } } 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/app/Models/ScanSemak.php b/app/Models/ScanSemak.php new file mode 100644 index 00000000..8eb1ec51 --- /dev/null +++ b/app/Models/ScanSemak.php @@ -0,0 +1,26 @@ +integer('status')->default(0); //1 = terima, 2 = tangguh lelong $table->integer('status_ubah')->default(0); //1 = ubah mutu, 2 = tambah marhun, 3 = hapus marhun, 4 = ubah berat, 5 = ubah mutu & berat, 6 = tangguh lelong pc $table->timestamps(); - - // $table->foreign('lelong_id') - // ->references('id')->on('lelong') - // ->onDelete('cascade'); - - // $table->foreign('lelongbid_id') - // ->references('id')->on('lelongbid') - // ->onDelete('cascade'); - - // $table->foreign('lelongbidmarhun_id') - // ->references('id')->on('lelongbidmarhun') - // ->onDelete('cascade'); - }); - Schema::create('scanmarhun', function (Blueprint $table) { + Schema::create('scan_semak', function (Blueprint $table) { $table->id(); $table->string('kodcaw'); $table->unsignedBigInteger('lelong_id')->unsigned(); $table->integer('lelongbid_id'); $table->string('norujukan'); $table->string('khazanah_id', '100'); - $table->date('tarikh_scankeluar'); - $table->time('masa_scankeluar'); $table->string('penilai_id', '100')->nullable(); - $table->time('masa_terima')->nullable(); - $table->time('masa_serah')->nullable(); - $table->date('tarikh_scanmasuk')->nullable(); - $table->time('masa_scanmasuk')->nullable(); + $table->datetime('scan_keluar'); + $table->datetime('terima_marhun')->nullable(); + $table->datetime('serah_marhun')->nullable(); + $table->datetime('scan_masuk')->nullable(); + $table->timestamps(); + }); + + Schema::create('scan_jual', function (Blueprint $table) { + $table->id(); $table->timestamps(); }); @@ -69,5 +59,7 @@ class CreatePengesahanTable extends Migration public function down() { Schema::dropIfExists('pengesahan'); + Schema::dropIfExists('scan_semak'); + Schema::dropIfExists('scan_jual'); } } 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/scanbarcode.blade.php b/resources/views/marhun/scanbarcode.blade.php index cea84c74..5d6e9042 100644 --- a/resources/views/marhun/scanbarcode.blade.php +++ b/resources/views/marhun/scanbarcode.blade.php @@ -38,30 +38,28 @@
    -
    - - - - - - - - - - - - @foreach($lelongbid as $index) - - - - - - - - @endforeach - -
    BilNo RujukanMarhunN. MarhunBerat
    {{$loop->iteration}}{{$index->norujukan}}{{$index->marhun}}{{ number_format($index->nilaimarhun, 2, '.', ',')}}{{$index->berat}}
    -
    + + + + + + + + + + + + @foreach($lelongbid as $index) + + + + + + + + @endforeach + +
    BilNo RujukanMarhunN. MarhunBerat
    {{$loop->iteration}}{{$index->norujukan}}{{$index->marhun}}{{ number_format($index->nilaimarhun, 2, '.', ',')}}{{$index->berat}}
    @@ -74,30 +72,26 @@
    -
    - - - - - - - - - - - - @foreach ($senaraiScanKeluar as $index) - - - - - - - - @endforeach - -
    BilNo RujukanStatusTarikh Scan KeluarMasa Scan Keluar
    {{$loop->iteration}}{{$index->norujukan}}Berada Di Luar Peti Besi{{$index->tarikh_scankeluar}}{{$index->masa_scankeluar}}
    -
    + + + + + + + + + + + @foreach ($senaraiScanKeluar as $index) + + + + + + + @endforeach + +
    BilNo RujukanTarikh/Masa Scan KeluarStatus
    {{$loop->iteration}}{{$index->norujukan}}{{$index->scan_keluar}}Berada Di Luar Peti Besi
    @@ -110,34 +104,32 @@
    -
    - - - - - - - - - - - - - - @foreach ($senaraiScanMasuk as $index) - - - - - - - - - - @endforeach - -
    BilNo RujukanStatusTarikh Scan KeluarMasa Scan KeluarTarikh Scan MasukMasa Scan Masuk
    {{$loop->iteration}}{{$index->norujukan}}Berada Di Dalam Peti Besi{{$index->tarikh_scankeluar}}{{$index->masa_scankeluar}}{{$index->tarikh_scanmasuk}}{{$index->masa_scanmasuk}}
    -
    + + + + + + + + + + + + + + @foreach ($senaraiScanMasuk as $index) + + + + + + + + + + @endforeach + +
    BilNo RujukanStatusTarikh/Masa Scan KeluarTarikh/Masa Terima MarhunTarikh/Masa Serah MarhunTarikh/Masa Scan Masuk
    {{$loop->iteration}}{{$index->norujukan}}{{$index->scan_keluar}}{{$index->terima_marhun}}{{$index->serah_marhun}}{{$index->scan_masuk}}Berada Di Dalam Peti Besi
    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..483d260f 100644 --- a/resources/views/marhun/terimaserahmarhun.blade.php +++ b/resources/views/marhun/terimaserahmarhun.blade.php @@ -17,6 +17,7 @@

    {{ $message }}

    @endif + Kembali