Postingan lainnya
cara menampilkan qrcode pada modal laravel
saya sedang membuat qrcode dan berhasil tapi saya ingin memunculkan qrcode tersebut langsung ketika melihat detail tidak mengklik button kembali di modalnya bagaimana ya caranya ?
image.png yang dimaksudkan qrcode ingin menampil langsung di bagian table QRCode tidak menglik buuton generate terlebih dahulu.
image.png gambaran kalo button generate di klik seperti ini.
web.php
//qrcode
Route::get('/qrcode/{id}', 'QrCodeController@generate')->name('generate');
Route::get('/qrcodeView/{id}', 'QrCodeController@generateView')->name('generateView');
blade.php
<!--GET a QUOTE MODAL Detail -->
<div class="modal fade" id="quoteFormDetail" tabindex="-1" role="dialog" aria-labelledby="quoteForm" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content p-md-3">
<div class="modal-header">
<h4 class="modal-title">Detail Asset</span></h4>
<button class="close" type="button" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<form id="formDetail" enctype="multipart/form-data" method="POST"
action="{{ route ('detaillistasset') }}">
{{ csrf_field() }}
<div class="row">
<!-- <center><img class="card-img-top img-fluid" id="foto_aset" src="{{ $item->foto_aset}}" responsive></center> -->
<center><img class="card-img-top img-fluid" id="foto_aset" responsive></center>
<br><br>
<input class="form-control" id="id_list_aset" name="id_list_aset" type="text" placeholder="ID"
required="" hidden="true" />
<div class="table-responsive col-6">
<table class="table table-bordered mb-0 ">
<thead>
<tr>
<th colspan="3">Informasi Aset</th>
</tr>
</thead>
<tbody>
<tr>
<td>Kode Aset</td>
<td>:</td>
<td id="kode_aset"></td>
</tr>
<tr>
<td>Departement</td>
<td>:</td>
<td id="id_departement"></td>
</tr>
<tr>
<td>Nama Aset</td>
<td>:</td>
<td id="nama_aset"></td>
</tr>
<tr>
<td>PIC</td>
<td>:</td>
<td id="id_karyawan"></td>
</tr>
<tr>
<td>Group Asset</td>
<td>:</td>
<td id="id_grup"></td>
</tr>
<tr>
<td>Supplier</td>
<td>:</td>
<td id="id_supplier"></td>
</tr>
<tr>
<td>Tanggal Beli</td>
<td>:</td>
<td id="beli"></td>
</tr>
<tr>
<td>No Faktur Beli</td>
<td>:</td>
<td id="no_faktur"></td>
</tr>
</tbody>
</table>
</div>
<div class="table-responsive col-6">
<table class="table table-bordered mb-0">
<thead>
<tr>
<th>Informasi Aset</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tanggal Pakai</td>
<td>:</td>
<td id="pakai"></td>
</tr>
<tr>
<td>Umur(bulan)</td>
<td>:</td>
<td id="umur"></td>
</tr>
<tr>
<td>Lokasi</td>
<td>:</td>
<td id="id_lokasi"></td>
</tr>
<tr>
<td>Tarif</td>
<td>:</td>
<td id="tarif"></td>
</tr>
<tr>
<td>Harga Perolehan</td>
<td>:</td>
<td id="harga_perolehan"></td>
</tr>
<tr>
<td>Keterangan</td>
<td>:</td>
<td id="keterangan"></td>
</tr>
<tr>
<td>Satuan Asset</td>
<td>:</td>
<td id="id_satuan"></td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- <div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="kode_aset">Kode Aset<span class="text-primary ml-1">*</span></label>
<input class="form-control" id="kode_aset" name="kode_aset" type="text" placeholder="Kode Aset" required="" />
@error('kode_aset')
<small class="text-danger">{{ $message }}</small>
@enderror
</div>
<div class="form-department col-lg-6">
<label class="font-weight-bold text-small" for="departement">Departement<span class="text-primary ml-1">*</span></label>
<select name="id_departement" id="departement_idDetail" data-live-search="true" class="form-select @error('departement') is-invalid @enderror">
<option value="">- Pilih -</option>
@foreach($departement as $row)
<option value="{{$row->id_departement}}" {{ old('departement')==$row->id_departement?'selected' :null}}>{{$row->nama_departement}}</option>
@endforeach
</select>
</div>
<div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="nama_aset">Nama Aset<span class="text-primary ml-1">*</span></label>
<input class="form-control" id="nama_aset" name="nama_aset" type="text" placeholder="Nama Aset" required="" />
@error('nama_aset')
<small class="text-danger">{{ $message }}</small>
@enderror
</div>
<div class="form-pic col-lg-6">
<label class="font-weight-bold text-small" for="pic">PIC<span class="text-primary ml-1">*</span></label>
<select name="id_karyawan" id="karyawan_idDetail" data-live-search="true" class="form-select @error('datakaryawan') is-invalid @enderror">
<option value="">- Pilih -</option>
@foreach($datakaryawan as $row)
<option value="{{$row->id_karyawan}}" {{ old('datakaryawan')==$row->id_karyawan?'selected' :null}}>{{$row->nama_karyawan}}</option>
@endforeach
</select>
</div>
<div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="group_aset">Group Aset<span class="text-primary ml-1">*</span></label>
<select name="id_grup" id="grup_idDetail" data-live-search="true" class="form-select @error('groupasset') is-invalid @enderror">
<option value="">- Pilih -</option>
@foreach($groupasset as $row)
<option value="{{$row->id_grup}}" {{ old('groupasset')==$row->id_grup?'selected' :null}}>{{$row->nama_grup_aset}}</option>
@endforeach
</select>
</div>
<div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="supplier">Supplier<span class="text-primary ml-1">*</span></label>
<select name="id_supplier" id="supplier_idDetail" data-live-search="true" class="form-select @error('supplier') is-invalid @enderror">
<option value="">- Pilih -</option>
@foreach($supplier as $row)
<option value="{{$row->id_supplier}}" {{ old('supplier')==$row->id_supplier?'selected' :null}}>{{$row->nama_supplier}}</option>
@endforeach
</select>
</div>
<div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="tgl_beli">Tgl Beli<span class="text-primary ml-1">*</span></label>
<input class="form-control" id="tgl_beli" name="tgl_beli" type="date" placeholder="Tanggal Beli" required="" />
@error('tgl_beli')
<small class="text-danger">{{ $message }}</small>
@enderror
</div>
<div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="no_faktur">No Faktur Beli<span class="text-primary ml-1">*</span></label>
<input class="form-control" id="no_faktur" name="no_faktur" type="text" placeholder="No Faktur Beli" required="" />
</div>
<div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="tgl_pakai">Tgl Pakai<span class="text-primary ml-1">*</span></label>
<input class="form-control" id="tgl_pakai" name="tgl_pakai" type="date" placeholder="Tanggal Pakai" required="" />
@error('tgl_pakai')
<small class="text-danger">{{ $message }}</small>
@enderror
</div>
<div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="umur">Umur (bulan)<span class="text-primary ml-1">*</span></label>
<input class="form-control" id="umur" name="umur" type="text" placeholder="Umur (bulan)" />
</div>
<div class="form-lokasi col-lg-6">
<label class="font-weight-bold text-small" for="lokasi">Lokasi<span class="text-primary ml-1">*</span></label>
<select name="lokasi" id="lokasiDetail" class="form-select" data-live-search="true">
<option value="">- Pilih -</option>
<option value="Lantai 1">Lantai 1</option>
<option value="Lantai 2">Lantai 2</option>
<option value="Lantai 3">Lantai 3</option>
</select>
</div>
<div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="tarif">Tarif<span class="text-primary ml-1">*</span></label>
<input class="form-control" id="tarif" name="tarif" type="text" placeholder="Tarif" disabled />
</div>
<div class="form-harga_perolehan col-lg-6">
<label class="font-weight-bold text-small" for="harga_perolehan">Harga Perolehan<span class="text-primary ml-1">*</span></label>
<input class="form-control" id="harga_perolehan" name="harga_perolehan" type="text" placeholder="Harga Perolehan" />
</div>
<div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="keterangan">Keterangan<span class="text-primary ml-1">*</span></label>
<input class="form-control" id="keterangan" name="keterangan" type="text" placeholder="Keterangan" />
</div>
<div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="satuan">Satuan Asset<span class="text-primary ml-1">*</span></label>
<select name="id_satuan" id="satuan_idDetail" data-live-search="true" class="form-select @error('satuan') is-invalid @enderror">
<option value="">- Pilih -</option>
@foreach($satuan as $row)
<option value="{{$row->id_satuan}}" {{ old('satuan')==$row->id_satuan?'selected' :null}}>{{$row->nama_satuan}}</option>
@endforeach
</select>
</div>-->
<!-- <div class="form-group col-lg-6">
<label class="font-weight-bold text-small" for="foto_aset">Foto Asset Terbaru<span class="text-primary ml-1">*</span></label>
<input type="file" id="foto_aset" class="form-control" name="foto_aset">
@error('foto_aset')
<small class="text-danger">{{ $message }}</small>
@enderror
</div> -->
<!-- <div class="card-body">
<div class="dataTable-wrapper dataTable-loading no-footer sortable searchable fixed-columns">
<div class="dataTable-container">
<table class="table table-striped table-hover dataTable-table" id="table1">
<thead>
<tr>
<th>Foto Asset terbaru</th>
<th>Tanggal Upload</th>
</tr>
</thead>
<tbody id="dataFoto">
</tbody>
</table>
</div>
</div>
</div> -->
<br> <div class="table-responsive col-6">
<table class="table table-bordered mb-0 ">
<thead>
<tr>
<th colspan="3">QRCode</th>
</tr>
</thead>
<tbody>
</tbody>
</table></div><br>
<div class="form-group col-lg-6">
<div class="form-group col-lg-4">
<a id="qrcode" target="_blank" class="btn btn-primary" >Generate QrCode<i class="fa fa-qrcode"></i></a>
</div>
<div class="form-group col-lg-4">
<button class="btn btn-danger" type="submit">
<i class="fa fa-print"></i>
Cetak PDF
</button>
</div>
<!-- <div class="form-group col-lg-6">
<button class="btn btn-success" type="submit">
<i class="fa fa-save"></i>
Save
</button>
</div> -->
</form>
</div>
</div>
</div>
</div>
</div>
2 Jawaban:
<div>Gunakan AJAX.<br>Pada saat modal di klik, jalankan /generate otomatis di balik layar<br>dan respon gambarnya kamu tampilkan di modal</div>
Tanggapan
yang ke buttin generate tuh sudah pek ajax kaya gini $("#qrcode").attr("href", $(e.relatedTarget).data('url')) nah kalo langsung ke generate di modal table ajax nya gimana kalo diganti href jadi src ga muncul
<div>Pake js kalo mw langsung.<br>Kalo g mw langsung y y waktu create data aja generate dan save sebagai gambar.</div>