Files
lelong/resources/views/marhun/marhun.blade.php
T
2023-02-05 10:17:54 +08:00

903 lines
51 KiB
PHP

@extends('layouts.app')
@push('additional_scripts')
<script src="https://cdn.jsdelivr.net/npm/image-capture@0.4.0/lib/imagecapture.min.js"></script>
<script src="{{ asset('js/marhun-photo-capture.js').'?'.rand(1,1000) }}"></script>
<script src="{{ asset('js/marhun-photo-capture-reload-https.js') }}"></script>
<script src="{{ asset('js/marhun-photo-capture-debugger.js') }}"></script>
<script src="{{ asset('js/marhun-photo-viewer.js') }}"></script>
<script>
var marhun_camera_config_chrome = @json(config('marhun_camera.marhun_cameras_chrome'));
var marhun_camera_config_firefox= @json(config('marhun_camera.marhun_cameras_firefox'));
let modalOverallPhotoCapture = new marhunPhotoCapturerFactory('#modaloverallphoto-capture');
let modalOverallPhotoCaptureUpdate = new marhunPhotoCapturerFactory('#modaloverallphoto-capture-update');
let modalOverallPhotoCapturePerMarhun = new marhunPhotoCapturerFactory('#modalpermarhunphoto-capture');
let modalOverallPhotoCapturePerMarhunUpdate = new marhunPhotoCapturerFactory('#modalpermarhunphoto-capture-update');
let marhunPhotoCapturerReloadHttps = new marhunPhotoCapturerReloadHttpsFactory();
let marhunPhotoCapturerDebuggerObj = new marhunPhotoCapturerDebugger();
let marhunPhotoViewerOverall = new marhunPhotoViewerFactory('a.btn-view-overall-marhun-photo');
let marhunPhotoViewerPerMarhun = new marhunPhotoViewerFactory('a.viewPhotoEachMarhunLink');
</script>
@endpush
@push('additional_styles')
<link rel="stylesheet" href="{{ asset('css/marhun-registrations-webcam.css') }}">
<link rel="stylesheet" href="{{ asset('css/viewer.min.css') }}">
<link rel="stylesheet" href="{{ asset('css/fix-page-zoom-when-modal-load.css') }}">
@endpush
@section('content')
<div class="container-fluid">
@include('marhun.partials.camera_modals_per_marhun')
@include('marhun.partials.camera_modals')
<div class="row ">
<div class="col mx-auto p-4">
<div class="card">
<div class="card-header header-style">
<a href=" {{ route('marhun.senaraimarhun', ['lelong_id'=>$lelongbid->lelong_id]) }}" class="header-style-icon">
<i class="fas fa-arrow-left"></i>
</a>
<div class="header-style-title">
No Rujukan : {{ $lelongbid->norujukan }}
</div>
</div>
<div class="card-body">
@if ($message = Session::get('success'))
<div class="alert mt-2 alert-success">
<p>{{ $message }}</p>
</div>
@endif
<form id="deletePhoto" action="{{route('marhun.deletephotomarhun')}}" method="POST">
@csrf
<input type="hidden" id="filemarhun_id" name="filemarhun_id" value="">
<input type="hidden" name="lelongbid_id" value="{{ $lelongbid['id'] }}">
<input type="hidden" name="lelong_id" value="{{ $lelongbid['lelong_id'] }}">
</form>
<form id="formdelete" action="{{ route('marhun.submitdelete') }}" method="POST">
@csrf
<input type="hidden" name="type" value="User">
<input type="hidden" name="lelongbidmarhun_id" id="lelongbidmarhun_id" >
<input type="hidden" name="lelongbid_id" id="lelongbid_id">
</form>
<form id="formsemak" action="{{ route('marhun.semak', [ $lelongbid, $lelong_id ]) }}" method="GET">
<input type="hidden" name="type" value="User">
<input type="hidden" name="lelongbidmarhun_id" id="lelongbidmarhun_id">
<input type="hidden" name="lelongbid_id" id="lelongbid_id">
</form>
<br>
{{-- <h4> No Rujukan : <td>{{ $lelongbid->norujukan }}</td>
</h4> --}}
<div class="row justify-content-center">
<div class="col-6">
<div class="card card-overall-marhun">
<div class="card-header">Keseluruhan Marhun</div>
<div class="card-body pl-0 pr-0" style="align-self: center; justify-content: center;">
@if ($lelongbid['filemarhun_filename'] != null)
<button type="button" data-toggle="modal" onclick="kesulurahanMarhunData(this)" data-lelongid="{{$lelongbid['lelong_id']}}" data-lelongbidid="{{$lelongbid['id']}}" data-lelongbid_status_semak="{{ $lelongbid['status_semak'] }}" data-fileid="{{ $lelongbid['filemarhun_id'] }}" data-target="#modaloverallphoto">
<img src="{{ route('marhun.showphotomarhun', ['norujukan_sag' => $lelongbid['norujukan'], 'filemarhun_id' => $lelongbid['filemarhun_id']]) }}" width="100%">
</button>
@else
<p>Tiada Data</p>
<div class="container d-flex justify-content-between p-0 mr-4">
<button
data-dismiss="modal"
onclick="modalOverallPhotoCapture.initiateTakeMarhunPhoto()" type="button"
class="btn btn-primary btn-md text-white"
>Ambil Gambar Marhun
</button>
<button
type="button"
data-toggle="modal"
data-target="#modaloverallphoto"
class="btn btn-primary btn-md text-white"
>Muat Naik Gambar Marhun</button>
</div>
@endif
</div>
</div>
</div>
</div>
<br>
<table class='table table-bordered table-hover' id="marhun" style="width:100%">
<thead class="bg-primary text-white">
<tr>
<th class="text-center">Barang</th>
<th>Gambar</th>
<th>Marhun</th>
<th>Karat</th>
<th>Berat</th>
<th>Harga(RM)</th>
<th>Nilai Marhun</th>
<th>Harga Asas</th>
<th>Nota</th>
<th class="text-center">Tindakan</th>
</tr>
</thead>
<tbody>
@foreach ($marhun as $item)
<tr>
<td class="text-center"> {{ $loop->iteration }} </td>
<td class="p-2 m-2" style="border: 1px solid black; width: 100px; height: 130px">
@if (empty($item->eachmarhun_filename))
<div class="btn-group" role="group" style="width: 100%;">
<span data-toggle="tooltip" data-placement="top" title="Muat naik gambar per marhun">
<button data-toggle="modal" onclick="eachMarhunData(this)"
class="btn btn-lg text-" data-lelongid="{{ $lelongbid['lelong_id'] }}"
data-lelongbidid="{{ $lelongbid['id'] }}"
data-loop="{{ $loop->iteration }}"
data-fileid="{{ $item->eachmarhun_id }}"
data-filename="{{ $item->eachmarhun_filename }}"
data-marhun="{{ $item->marhun }}" data-marhunid="{{ $item->id }}"
data-target="#modaleachphoto"
style="border-radius: 0 !important">
<i class="fas fa-upload"></i>
</button>
</span>
<span data-toggle="tooltip" data-placement="top" title="Ambil gambar per marhun">
<button data-toggle="modal" onclick="eachMarhunDataCapturePhoto(this)"
class="btn btn-lg" data-lelongid="{{ $lelongbid['lelong_id'] }}"
data-lelongbidid="{{ $lelongbid['id'] }}"
data-loop="{{ $loop->iteration }}"
data-fileid="{{ $item->eachmarhun_id }}"
data-filename="{{ $item->eachmarhun_filename }}"
data-marhun="{{ $item->marhun }}" data-marhunid="{{ $item->id }}"
style="border-radius: 0 !important">
<i class="fas fa-camera"></i>
</button>
</span>
</div>
<img src="{{ asset('img/no-image.png') }}" alt="Tambah / Padam Gambar"
style="width:100%; border: 1px solid #dee2e6" />
@else
<button data-toggle="modal" onclick="eachMarhunData(this)"
data-lelongid="{{ $lelongbid['lelong_id'] }}"
data-lelongbidid="{{ $lelongbid['id'] }}" data-loop="{{ $loop->iteration }}"
data-fileid="{{ $item->eachmarhun_id }}"
data-filename="{{ $item->eachmarhun_filename }}"
data-marhun="{{ $item->marhun }}" data-marhunid="{{ $item->id }}"
data-lelongbid_status_semak="{{ $lelongbid['status_semak'] }}"
data-target="#modaleachphoto">
<img src="{{ url($item->eachmarhun_filename) }}" alt="Tambah / Padam Gambar"
style="max-width:100px; border: 1px solid #dee2e6" />
</button>
@endif
</td>
<td>{{ $item->marhun }}</td>
<td>
@if($item->karat != null)
{{ $item->karat }}
@else
{{ $item->old_karat }}
@endif
</td>
<td>
@if($item->berat != null)
{{ $item->berat }}
@else
{{ $item->old_berat }}
@endif
</td>
<td>
@if($item->harga != null)
{{ $item->harga }}
@else
{{ $item->old_harga }}
@endif
</td>
<td>
@if($item->n_marhun != null)
{{ number_format($item->n_marhun, 2, '.', ',') }}
@else
{{ number_format($item->old_nmarhun, 2, '.', ',') }}
@endif
</td>
<td>
@if($item->hargaasas != null)
{{ number_format($item->hargaasas, 2, '.', ',') }}
@else
{{ number_format($item->old_hargaasas, 2, '.', ',') }}
@endif
</td>
<td>{{ $item->nota }}</td>
<td class="text-center">
@if($lelongbid->status_semak == 1)
<span class="badge badge-success">Telah Semak<br></span>
@elseif($lelongbid->status_semak == 0)
@if(isset($item->pengesahan['status']))
@if($item->pengesahan['status_ubah'] == 1 )
<a href="{{ route('marhun.lihatubahmutumarhun', ['norujukan'=>$lelongbid->norujukan, $lelong_id]) }}"><span class="badge badge-warning">Tunggu Pengesahan<br><i>Ubah Mutu</i></span></a>
@elseif($item->pengesahan['status_ubah'] == 2)
<a href="{{ route('marhun.lihatubahmutumarhun', ['norujukan'=>$lelongbid->norujukan, $lelong_id]) }}"><span class="badge badge-warning">Tunggu Pengesahan<br><i>Tambah Marhun</i></span></a>
@elseif($item->pengesahan['status_ubah'] == 3)
<a href="{{ route('marhun.lihatubahmutumarhun', ['norujukan'=>$lelongbid->norujukan, $lelong_id]) }}"><span class="badge badge-warning">Tunggu Pengesahan<br><i>Hapus Marhun</i></span></a>
@elseif($item->pengesahan['status_ubah'] == 4)
<a href="{{ route('marhun.lihatubahmutumarhun', ['norujukan'=>$lelongbid->norujukan, $lelong_id]) }}"><span class="badge badge-warning">Tunggu Pengesahan<br><i>Ubah Berat</i></span></a>
@elseif($item->pengesahan['status_ubah'] == 5)
<a href="{{ route('marhun.lihatubahmutumarhun', ['norujukan'=>$lelongbid->norujukan, $lelong_id]) }}"><span class="badge badge-warning">Tunggu Pengesahan<br><i>Ubah Mutu & Berat</i></span></a>
@elseif($item->pengesahan['status_ubah'] == 7)
<a href="{{ route('marhun.lihatubahmutumarhun', ['norujukan'=>$lelongbid->norujukan, $lelong_id]) }}"><span class="badge badge-warning">Tunggu Pengesahan<br><i>Ubah Marhun</i></span></a>
@elseif($item->pengesahan['status_ubah'] == 8)
<a href="{{ route('marhun.lihatubahmutumarhun', ['norujukan'=>$lelongbid->norujukan, $lelong_id]) }}"><span class="badge badge-warning">Tunggu Pengesahan<br><i>Ubah Mutu, Berat & Marhun</i></span></a>
@elseif($item->pengesahan['status_ubah'] == 9)
<a href="{{ route('marhun.lihatubahmutumarhun', ['norujukan'=>$lelongbid->norujukan, $lelong_id]) }}"><span class="badge badge-warning">Tunggu Pengesahan<br><i>Ubah Mutu & Marhun</i></span></a>
@elseif($item->pengesahan['status_ubah'] == 10)
<a href="{{ route('marhun.lihatubahmutumarhun', ['norujukan'=>$lelongbid->norujukan, $lelong_id]) }}"><span class="badge badge-warning">Tunggu Pengesahan<br><i>Ubah Berat & Marhun</i></span></a>
@elseif($item->pengesahan['status'] == 1)
<span class="badge badge-warning">Telah Sah</i></span>
@endif
@else
<a class="btn m-1 btn-primary" onclick="kemaskini(this)" data-idmarhun="{{ $item->id }}" data-marhun="{{ $item->marhun }}" data-karat="{{ $item->karat }}" data-berat="{{ $item->berat }}" data-harga="{{ $item->harga }}" data-nmarhun="{{ $item->n_marhun }}" data-hargaasas="{{ $item->hargaasas }}" data-nota="{{ $item->nota }}" data-toggle="tooltip" data-placement="top" title="Kemaskini Marhun" style="margin-right:30px"><i class="far fa-edit"></i></a>
@endif
@else
<a class="btn m-1 btn-primary" onclick="kemaskini(this)" data-idmarhun="{{ $item->id }}" data-marhun="{{ $item->marhun }}" data-karat="{{ $item->karat }}" data-berat="{{ $item->berat }}" data-harga="{{ $item->harga }}" data-nmarhun="{{ $item->n_marhun }}" data-hargaasas="{{ $item->hargaasas }}" data-nota="{{ $item->nota }}" data-toggle="tooltip" data-placement="top" title="Kemaskini Marhun" style="margin-right:30px"><i class="far fa-edit"></i></a>
{{-- <a class="confirmdel" id="btndelete" data-lelongbidmarhun="{{ $item->id }}" data-lelongbid="{{ $item->lelongbid_id }}" data-toggle="tooltip" data-placement="top" title="Padam Marhun"><i class="far fa-trash-alt"></i></a> --}}
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="modal-footer" style="margin-top:2%;">
{{-- {{dump($status['status'])}} --}}
@if($lelongbid->status_semak == 0)
@if(isset($status['status']))
@if($status['status'] == 0)
<button style="width:20%;" class="btn btn-warning">Dalam Proses Pengesahan</button>
@elseif($status['status'] == 1)
<button style="width:7%;" class="btn btn-info" >Telah Sah</button>
@else
<button style="width:7%;" class="btn btn-success button-confirm-marhun" onclick="confirm()" data-is_overall_marhun_photo_uploaded="{{ $lelongbid['filemarhun_filename'] != null }}">Semak/button>
@endif
@else
<button style="width:7%;" class="btn btn-success button-confirm-marhun" onclick="confirm()" data-is_overall_marhun_photo_uploaded="{{ $lelongbid['filemarhun_filename'] != null }}">Semak</button>
@endif
{{-- <button style="width:7%;" class="btn btn-warning">Dalam Proses Pengesahan</button> --}}
@elseif($lelongbid->status_semak == 1)
<button class="btn btn-success btn-sm hovernone-success" disabled>SUDAH DISEMAK</button>
@endif
</div>
</div>
</div>
</div>
<div class="modal fade" tabindex="-1" id="modalkemaskini">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Kemaskini Marhun</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="{{ route('marhun.kemaskiniMarhun') }}" method="POST" id="formkemaskini">
@csrf
<div class="row justify-content-center">
<div class="col-md-8">
<div class="form-group row">
<input type="hidden" name="idmarhun" id="idmarhun">
<div class="col-md-4">No Rujukan</div>
<div class="col-md-8"><input class="form-control" type="text"
name="norujukan_marhun" id="norujukan_marhun"
value="{{ $lelongbid->norujukan }}" readonly></div>
<div class="col-md-4">Marhun</div>
<div class="col-md-8">
<select class="form-control" name="marhun" id="selectmarhun">
<option disabled selected value> -- Pilih Jenis Marhun -- </option>
@foreach ($emasall as $emas)
<option value="{{ $emas->marhun }}"> {{ $emas->descpt }}</option>
@endforeach
</select>
</div>
<div class="col-md-4">Karat</div>
<div class="col-md-8">
<select class="form-control" name="karat" id="selectkarat"
data-karatall="{{ $lelkarat }}" onchange="calc(this,'karat')">
<option disabled selected value> -- Pilih Karat -- </option>
@foreach ($karatall as $karat)
<option value="{{ $karat->karat }}"> {{ $karat->keterangan }}
</option>
@endforeach
</select>
</div>
<div class="col-md-4">Berat</div>
<div class="col-md-8"><input class="form-control" type="text"
name="berat_emas" id="berat_emas" oninput="calc(this,'berat')"></div>
<div class="col-md-4">Harga</div>
<div class="col-md-8"><input class="form-control .harga" type="text"
name="harga" id="harga" readonly></div>
<div class="col-md-4">Nilai Marhun</div>
<div class="col-md-8"><input class="form-control" type="text"
name="nilai_marhun" id="nilai_marhun" readonly></div>
<div class="col-md-4">Harga Asas</div>
<div class="col-md-8"><input class="form-control" type="text"
name="harga_asas" id="harga_asas" readonly></div>
<div class="col-md-4">Nota</div>
<div class="col-md-8"><input class="form-control" type="text" name="nota"
id="nota" readonly></div>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" style="width:15%;"
data-dismiss="modal">Kembali</button>
<button type="button" class="btn btn-primary" style="width:15%;"
onclick="updateform()">Simpan</button>
</div>
</div>
</div>
</div>
<div class="modal fade" tabindex="-1" id="modaltambahmarhun">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Tambah Marhun</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="{{ route('marhun.tambahmarhun') }}" method="POST" id="formtambahmarhun">
@csrf
<div class="row justify-content-center">
<div class="col-md-8">
<div class="form-group row">
<input type="hidden" name="tambahmarhun" id="tambahmarhun">
<div class="col-md-4">No Rujukan</div>
<div class="col-md-8"><input class="form-control" type="text"
name="norujukan_marhuntambahan" id="norujukan_marhuntambahan"
value="{{ $lelongbid->norujukan }}" readonly></div>
<div class="col-md-4">Marhun</div>
<div class="col-md-8">
<select class="form-control" name="marhuntambahan" id="selectmarhuntambahan">
<option disabled selected value> -- Pilih Jenis Marhun -- </option>
@foreach ($emasall as $emas)
<option value="{{ $emas->marhun }}"> {{ $emas->descpt }}</option>
@endforeach
</select>
</div>
<div class="col-md-4">Karat</div>
<div class="col-md-8">
<select class="form-control" name="karattambahan" id="selectkarattambahan"
data-karatalltambahan="{{ $lelkarat }}"
onchange="calc_tambahan(this,'karattambahan')">
<option disabled selected value> -- Pilih Karat -- </option>
@foreach ($karatall as $karat)
<option value="{{ $karat->karat }}">{{ $karat->keterangan }}</option>
@endforeach
</select>
</div>
<div class="col-md-4">Berat</div>
<div class="col-md-8"><input class="form-control" type="text"
name="berat_emastambahan" id="berat_emastambahan"
oninput="calc_tambahan(this,'berattambahan')" value="0"></div>
<div class="col-md-4">Harga</div>
<div class="col-md-8"><input class="form-control .hargatambahan" type="text"
name="hargatambahan" id="hargatambahan" readonly></div>
<div class="col-md-4">Nilai Marhun</div>
<div class="col-md-8"><input class="form-control" type="text"
name="nilai_marhuntambahan" id="nilai_marhuntambahan" readonly></div>
<div class="col-md-4">Harga Asas</div>
<div class="col-md-8"><input class="form-control" type="text"
name="harga_asastambahan" id="harga_asastambahan" readonly></div>
<div class="col-md-4">Nota</div>
<div class="col-md-8"><input class="form-control" type="text"
name="notatambahan" id="notatambahan"></div>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
@if ($lelongbid->status_semak == 0)
<button type="button" class="btn btn-secondary" style="width:15%;"
data-dismiss="modal">Kembali</button>
<button type="button" class="btn btn-primary" style="width:15%;"
onclick="tambahanmarhun()">Simpan</button>
@elseif($lelongbid->status_semak == 1)
<p class="text-danger font-italic">Marhun telah disemak. Tidak dibenarkan untuk tambah.</p>
@endif
</div>
</div>
</div>
</div>
<div class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" id="modaloverallphoto">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Keseluruhan Marhun</h5>
<button type="button" class="close" onclick="clearData()" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form id="form1" action="{{ route('marhun.addphotomarhun') }}" method="POST"
enctype="multipart/form-data">
@csrf
<input type="hidden" name="lelongbid_id" value="{{ $lelongbid['id'] }}">
<input type="hidden" name="lelong_id" value="{{ $lelongbid['lelong_id'] }}">
<input type="hidden" name="photo_type" value="1">
<div class="modal-body justify-content-center">
@if (!isset($lelongbid->filemarhun_filename))
<div class="row justify-content-center">
<div class="col-8">
<input type="file" accept="image/*;capture=camera" name="gambarMarhun"
id="inputGroupFile04" /><br>
</div>
</div>
@else
<div class="row mt-5 justify-content-center">
@php
$imageLink = route('marhun.showphotomarhun', ['norujukan_sag' => $lelongbid['norujukan'], 'filemarhun_id' => $lelongbid['filemarhun_id']]);
@endphp
<a href="{{ $imageLink }}" target="_blank" class="btn m-2 btn-warning btn-view-overall-marhun-photo">Lihat gambar</a>
<button data-dismiss="modal" onclick="updatePhoto(1)" type="button"
data-target="#modalupdatephoto" data-toggle="modal" class="btn m-2 btn-warning action-invalid-after-semak">Muat naik gambar baru</button>
<button data-dismiss="modal"
onclick="modalOverallPhotoCaptureUpdate.initiateTakeMarhunPhoto()" type="button"
class="btn m-2 btn-warning action-invalid-after-semak">Ambil Gambar Baru</button>
<button data-dismiss="modal" onclick="confirmDeletePhoto()"
class="btn m-2 btn-danger action-invalid-after-semak">Padam Gambar</button>
</div>
@endif
</div>
<div class="modal-footer">
@if ($lelongbid->status_semak == 0)
<button type="button" class="btn btn-secondary" style="width:15%;"
onclick="clearData()" data-dismiss="modal">Kembali</button>
<button type="submit" class="btn btn-primary" style="width:15%;">Simpan</button>
@elseif($lelongbid->status_semak == 1)
<p class="text-danger font-italic">Marhun telah disemak. Tidak dibenarkan untuk kemaskini.
</p>
@endif
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" id="modaleachphoto">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="titleHeader" value="titleHeader"></h5>
<button type="button" onclick="clearData()" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form id="form1" action="{{ route('marhun.addphotomarhun') }}" method="POST"
enctype="multipart/form-data">
@csrf
<input type="hidden" name="lelongbid_id" value="{{ $lelongbid['id'] }}">
<input type="hidden" name="lelong_id" value="{{ $lelongbid['lelong_id'] }}">
<input type="hidden" name="photo_type" value="2">
<input type="hidden" name="lelongbidmarhun_id" id="marhun_id" value="">
<div class="modal-body justify-content-center">
<div id="createPhoto" hidden class="row justify-content-center">
<input type='file' accept="image/*;capture=camera" name="gambarMarhun"
id="inputGroupFile04" /><br>
</div>
<div id="updateDeletePhoto" hidden class="row mt-5 justify-content-center">
<a href="" target="_blank" class="btn m-2 btn-warning viewPhotoEachMarhunLink">Lihat gambar</a>
<button data-dismiss="modal" onclick="updatePhoto(2)" type="button"
data-target="#modalupdatephoto" data-toggle="modal" class="btn m-2 btn-warning action-invalid-after-semak">Muat naik gambar baru</button>
<button data-dismiss="modal"
onclick="modalOverallPhotoCapturePerMarhunUpdate.initiateTakeMarhunPhoto()"
type="button" data-toggle="modal" class="btn m-2 btn-warning action-invalid-after-semak">Ambil Gambar
Baru</button>
<button data-dismiss="modal" onclick="confirmDeletePhoto()"
class="btn m-2 btn-danger action-invalid-after-semak">Padam Gambar</button>
</div>
</div>
<div class="modal-footer">
@if ($lelongbid->status_semak == 0)
<button type="button" class="btn btn-secondary" onclick="clearData()" tyle="width:15%;"
data-dismiss="modal">Kembali</button>
<button type="submit" class="btn btn-primary" style="width:15%;">Simpan</button>
@elseif($lelongbid->status_semak == 1)
<p class="text-danger font-italic">Marhun telah disemak. Tidak dibenarkan untuk kemaskini.
</p>
@endif
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" id="modalupdatephoto">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Tukar Gambar</h5>
<button type="button" onclick="clearData()" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form action="{{ route('marhun.updatephotomarhun') }}" method="POST" enctype="multipart/form-data">
@csrf
<input type="hidden" id="val1" name="lelongbid_id" value="">
<input type="hidden" id="val2" name="lelongbidmarhun_id" value="">
<input type="hidden" id="val3" name="filemarhun_id" value="">
<input type="hidden" id="val4" name="lelong_id" value="">
<input type="hidden" id="photo_type" name="photo_type" value="">
<div class="modal-body justify-content-center">
<div class="row justify-content-center">
<input type='file' accept="image/*;capture=camera" name="gambarMarhun"
id="inputGroupFile04" /><br>
</div>
</div>
<div class="modal-footer">
@if ($lelongbid->status_semak == 0)
<button type="button" class="btn btn-secondary" onclick="clearData()" tyle="width:15%;"
data-dismiss="modal">Kembali</button>
<button type="submit" class="btn btn-primary" style="width:15%;">Simpan</button>
@elseif($lelongbid->status_semak == 1)
<p class="text-danger font-italic">Marhun telah disemak. Tidak dibenarkan untuk kemaskini.
</p>
@endif
</div>
</form>
</div>
</div>
</div>
</div>
<script>
marhunPhotoCapturerReloadHttps.reload();
function clearData() {
document.getElementById('inputGroupFile04').value = '';
document.getElementById('marhun_id').value = '';
document.getElementById('filemarhun_id').value = '';
}
function eachMarhunData(value) {
lelongId = $(value).data('lelongid');
marhunId = $(value).data('marhunid');
lelongBidId = $(value).data('lelongbidid');
marhun = $(value).data('marhun');
loop = $(value).data('loop');
fileId = $(value).data('fileid');
fileName = $(value).data('filename');
let modalTitle = "Bil:" + loop + ", Id Marhun:" + marhunId + ", Marhun:" + marhun;
lelongBidStatusSemak = $(value).data('lelongbid_status_semak');
isAlreadyStatusSemak = lelongBidStatusSemak === 1;
if(isAlreadyStatusSemak){
const modalOverallPhoto = document.querySelector('#modaleachphoto');
modalOverallPhoto.querySelectorAll('button.action-invalid-after-semak')
.forEach(button => button.style.display = 'none');
}
prepareModalUpdateCaptureEachMarhun(modalTitle, marhunId, fileId);
prepareModalUpdateUploadEachMarhun(modalTitle, marhunId, fileId, fileName);
prepareModalViewPhotoEachMarhun(fileName);
}
function prepareModalViewPhotoEachMarhun(fileName)
{
let modal = document.querySelector('#modaleachphoto');
modal.querySelector('a.viewPhotoEachMarhunLink').href = fileName;
}
function prepareModalUpdateCaptureEachMarhun(modalTitle, marhunId, fileId) {
let modal = document.querySelector('#modalpermarhunphoto-capture-update');
modal.querySelector('#marhun_id').value = marhunId;
modal.querySelector('input[name="filemarhun_id"]').value = fileId;
modal.querySelector("h5.modal-title").innerHTML = modalTitle;
}
function prepareModalUpdateUploadEachMarhun(modalTitle, marhunId, fileId, fileName) {
if (fileName == '') {
$("#createPhoto").attr("hidden", false);
$("#updateDeletePhoto").attr("hidden", true);
} else if (fileName != '') {
$("#createPhoto").attr("hidden", true);
$("#updateDeletePhoto").attr("hidden", false);
}
let modal = document.querySelector('#modaleachphoto');
modal.querySelector('input[name="lelongbidmarhun_id"]').value = marhunId;
document.getElementById('marhun_id').value = marhunId;
document.getElementById('filemarhun_id').value = fileId;
document.getElementById("titleHeader").innerHTML = modalTitle;
}
function eachMarhunDataCapturePhoto(value) {
let lelongId = $(value).data('lelongid');
let marhunId = $(value).data('marhunid');
let lelongBidId = $(value).data('lelongbidid');
let marhun = $(value).data('marhun');
let loop = $(value).data('loop');
let fileId = $(value).data('fileid');
let fileName = $(value).data('filename');
let modal = document.querySelector('#modalpermarhunphoto-capture');
modal.querySelector('#marhun_id').value = marhunId;
modal.querySelector('h5.modal-title').innerHTML = "Bil:" + loop + ", Id Marhun:" + marhunId + ", Marhun:" +
marhun;
modalOverallPhotoCapturePerMarhun.initiateTakeMarhunPhoto();
}
function kesulurahanMarhunData(value) {
lelongBidId = $(value).data('lelongbidid');
marhunId = '';
fileId = $(value).data('fileid');
lelongId = $(value).data('lelongid');
document.getElementById('filemarhun_id').value = fileId;
lelongBidStatusSemak = $(value).data('lelongbid_status_semak');
isAlreadyStatusSemak = lelongBidStatusSemak === 1;
if(isAlreadyStatusSemak){
const modalOverallPhoto = document.querySelector('#modaloverallphoto');
modalOverallPhoto.querySelectorAll('button.action-invalid-after-semak')
.forEach(button => button.style.display = 'none');
}
}
function confirmDeletePhoto() {
$.confirm({
title: 'Perhatian!',
content: 'Padam gambar? Tindakan ini tidak dapat dikembalikan.',
type: 'red',
typeAnimated: true,
buttons: {
Batal: {
btnClass: 'btn-default',
action: function() {}
},
Sahkan: {
btnClass: 'btn-danger',
action: function() {
$("#deletePhoto").submit();
}
}
}
});
}
function updatePhoto(type) {
document.getElementById('val1').value = lelongBidId;
document.getElementById('val2').value = marhunId;
document.getElementById('val3').value = fileId;
document.getElementById('val4').value = lelongId;
document.getElementById('photo_type').value = type;
}
function validateOverallMarhunPhotoTook(){
const button_confirm = document.querySelector('button.button-confirm-marhun');
const is_overall_marhun_photo_uploaded = button_confirm.dataset.is_overall_marhun_photo_uploaded;
if(! is_overall_marhun_photo_uploaded){
return false;
}
return true;
}
function showOverallMarhunPhotoErrorAlert(){
$.alert({
title: 'Perhatian!',
content: 'Sila pastikan gambar keseluruhan marhun lengkap',
type: 'red',
buttons: {
OK: {
btnClass: 'btn-default',
action: function() {
setTimeout(() => {
button_take_marhun_photo = document.querySelector('div.card-overall-marhun');
button_take_marhun_photo.scrollIntoView({ behavior: 'smooth', block: 'start'});
}, 500);
}
},
}
});
}
function confirm() {
const is_pass_validation = validateOverallMarhunPhotoTook();
if (! is_pass_validation) {
showOverallMarhunPhotoErrorAlert();
return;
}
$.confirm({
title: 'Perhatian!',
content: 'Anda pasti telah membuat semakan untuk kesemua marhun?',
type: 'green',
typeAnimated: true,
buttons: {
Batal: {
btnClass: 'btn-default',
action: function() {}
},
Sahkan: {
btnClass: 'btn-success',
action: function() {
$("#formsemak").submit();
}
}
}
});
}
//Enable tooltips everywhere
$(function() {
$('[data-toggle="tooltip"]').tooltip()
})
$('a.confirmdel').confirm({
title: 'Confirmation',
content: 'Anda pasti?',
type: 'orange',
typeAnimated: true,
buttons: {
Delete: {
btnClass: 'btn-warning',
action: function(e) {
// location.href = this.$target.attr('href');
let lelongbidmarhun = $(this)[0].$target[0].dataset.lelongbidmarhun;
let lelongbid = $(this)[0].$target[0].dataset.lelongbid;
$('#lelongbid_id').val(lelongbid);
$('#lelongbidmarhun_id').val(lelongbidmarhun);
$("#formdelete").submit();
}
},
Batal: {
btnClass: 'btn-default',
action: function() {}
}
}
});
var tablemarhun = $('#marhun').DataTable({
"orderFixed": [0, 'asc'],
"info": false,
"lengthChange": false,
"pageLength": 15,
dom: 'Bfrtip',
buttons: [{
className: 'btn btn-outline-success pl-4 pr-4 addsim',
text: 'Tambah Marhun <i class="fas fa-plus" id="test"></i>',
action: function(e, dt, node, config) {
$('#modaltambahmarhun').modal("show");
}
}]
});
$('.addsim').tooltip();
$('.export').tooltip();
// $( '.dt-buttons').addClass('btn-group');
$('.addsim').removeClass('dt-button');
$('.export').removeClass('dt-button');
function selectall(cb) {
tablemarhun.rows().nodes().to$().find('input[type="checkbox"]').each(function() {
$(this).prop('checked', cb.checked);
})
}
function tambahanmarhun(e) {
$("#formtambahmarhun").submit();
}
function calc_tambahan(e, type) {
if (type == 'karattambahan') {
var karatalltambahan = $(e).data('karatalltambahan');
karatalltambahan.forEach((item) => {
if (item.karat == $(e).val()) {
console.log(item);
var beratemas = $('#berat_emastambahan').val();
var total_tambahan = item.harga2 * parseFloat(beratemas);
var harga_asastambahan = Math.round(total_tambahan);
$('#hargatambahan').val(parseFloat(item.harga2).toFixed(2));
$('#nilai_marhuntambahan').val(parseFloat(total_tambahan).toFixed(2));
$('#harga_asastambahan').val(parseFloat(harga_asastambahan).toFixed(2));
}
});
} else {
var total_tambahan = $('#hargatambahan').val() * $('#berat_emastambahan').val();
var harga_asastambahan = Math.round(total_tambahan);
$('#nilai_marhuntambahan').val(parseFloat(total_tambahan).toFixed(2));
$('#harga_asastambahan').val(parseFloat(harga_asastambahan).toFixed(2));
}
}
function kemaskini(e) {
$('#modalkemaskini').modal("show");
$('#modalkemaskini').on('shown.bs.modal', function() {
$('#rolename').trigger('focus')
})
let idmarhun = $(e).data('idmarhun');
let marhun = $(e).data('marhun');
let karat = $(e).data('karat');
let berat = $(e).data('berat');
let harga = $(e).data('harga');
let nmarhun = $(e).data('nmarhun');
let hargaasas = $(e).data('hargaasas');
let nota = $(e).data('nota');
$('#idmarhun').val(idmarhun);
$('#selectmarhun').val(marhun);
$('#selectkarat').val(karat);
$('#berat_emas').val(berat);
$('#harga').val(harga);
$('#nilai_marhun').val(nmarhun);
$('#harga_asas').val(hargaasas);
$('#nota').val(nota);
}
function calc(e, type) {
if (type == 'karat') {
var karatall = $(e).data('karatall');
karatall.forEach((item) => {
if (item.karat == $(e).val()) {
var total = item.harga2 * $('#berat_emas').val();
var hargaasas = Math.round(total);
$('#harga').val(parseFloat(item.harga2).toFixed(2));
$('#nilai_marhun').val(parseFloat(total).toFixed(2));
$('#harga_asas').val(parseFloat(hargaasas).toFixed(2));
}
});
} else {
var total = $('#harga').val() * $('#berat_emas').val();
var hargaasas = Math.round(total);
$('#nilai_marhun').val(parseFloat(total).toFixed(2));
$('#harga_asas').val(parseFloat(hargaasas).toFixed(2));
}
}
function updateform() {
$("#formkemaskini").submit();
}
marhunPhotoViewerOverall.attachPhotoViewer();
marhunPhotoViewerPerMarhun.attachPhotoViewer();
</script>
@endsection