Merge branch 'faiqahzaman'

This commit is contained in:
Azfar Arsyad
2022-03-10 16:49:47 +08:00
4 changed files with 185 additions and 44 deletions
+48
View File
@@ -167,6 +167,34 @@ class MarhunController extends Controller
->with('success','Semakan Marhun Berjaya');
}
public function tambahmarhun(Request $request)
{
// dd($request->all());
//get request from form and create lelongbidmarhun
$lelongbid = LelongBid::where('norujukan', $request->norujukan_marhuntambahan)->first();
$lelongbidmarhun = new LelongBidMarhun;
$lelongbidmarhun->lelongbid_id = $lelongbid->id;
$lelongbidmarhun->bil = 1;
$lelongbidmarhun->marhun = $request->marhuntambahan;
$lelongbidmarhun->nota = $request->notatambahan;
$lelongbidmarhun->karat = $request->karattambahan;
$lelongbidmarhun->berat = $request->berat_emastambahan;
$lelongbidmarhun->harga = $request->hargatambahan;
$lelongbidmarhun->n_marhun = $request->nilai_marhuntambahan;
$lelongbidmarhun->hargaasas = $request->harga_asastambahan;
$lelongbidmarhun->status_semak = 0;
$lelongbidmarhun->save();
$lelongbid->marhun = $lelongbid->marhun ."1 " . $request->marhuntambahan . "," ;
$lelongbid->berat = $lelongbid->berat + $request->berat_emastambahan;
$lelongbid->hargaasas = $lelongbid->hargaasas + $request->harga_asastambahan;
$lelongbid->save();
return redirect()->route('marhun.show',$lelongbid->id)
->with('success','Marhun Berjaya Ditambah');
}
//Operasi
@@ -320,6 +348,26 @@ class MarhunController extends Controller
return redirect()->route('pengesahan.perubahanmutumarhun')->with('success','Pengesahan Mutu Marhun Berjaya');
}
public function delete($id){
// dd($id);
$lelongbidmarhun = LelongBidMarhun::where('id', $id)->first();
$lelongbid = LelongBid::where('id', $lelongbidmarhun->lelongbid_id)->first();
// dd($lelongbid);
$txtmarhun = ",1 " . $lelongbidmarhun->marhun ;
$lelongbid->marhun = str_replace( $txtmarhun,"",$lelongbid->marhun);
// $lelongbid->marhun = $lelongbid->marhun ."1 " . $request->marhuntambahan . "," ;
$lelongbid->berat = $lelongbid->berat - $lelongbidmarhun->berat_emastambahan;
$lelongbid->hargaasas = $lelongbid->hargaasas - $lelongbidmarhun->harga_asastambahan;
$lelongbid->save();
$lelongbidmarhun->delete();
return redirect()->route('marhun.show',$lelongbid->id)
->with('success','Marhun Berjaya Dipadam');
}
}
@@ -93,13 +93,13 @@ class CreateLelongsTable extends Migration
$table->unsignedBigInteger('lelongbid_id')->unsigned();
$table->decimal('bil', $precision = 3, $scale = 0);
$table->string('marhun');
$table->string('nota');
$table->string('nota')->nullable();
$table->string('karat');
$table->decimal('berat', $precision = 7, $scale = 2);
$table->decimal('harga', $precision = 5, $scale = 2);
$table->decimal('n_marhun', $precision = 9, $scale = 2);
$table->decimal('hargaasas', $precision = 11, $scale = 2);
$table->integer('status_semak')->default(0);
$table->integer('status_semak')->default(0)->nullable();
$table->timestamps();
$table->foreign('lelongbid_id')
+134 -42
View File
@@ -53,8 +53,8 @@
</table>
</form>
<div class="modal-footer" style="margin-top:2%;">
<a href="{{ route('marhun.senarailelongmarhun') }}" class="btn btn-primary">Kembali</a>
<a href="{{ route('marhun.semak', $lelongbid) }}" class="btn btn-success">Semak</a>
<a href="{{ route('marhun.senarailelongmarhun') }}" style="width:7%;" class="btn btn-primary">Kembali</a>
<a href="{{ route('marhun.semak', $lelongbid) }}" style="width:7%;" class="btn btn-success">Semak</a>
</div>
</div>
@@ -111,12 +111,72 @@
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
<button type="button" class="btn btn-primary" onclick="updateform()">Simpan</button>
<button type="button" class="btn btn-secondary" style="width:15%;" data-dismiss="modal">Tutup</button>
<button type="button" class="btn btn-primary" style="width:15%;" onclick="updateform()">Simpan</button>
</div>
</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">
<button type="button" class="btn btn-secondary" style="width:15%;" data-dismiss="modal">Tutup</button>
<button type="button" class="btn btn-primary" style="width:15%;" onclick="tambahanmarhun()">Simpan</button>
</div>
</div>
</div>
</div>
</div>
<script>
//Enable tooltips everywhere
@@ -143,42 +203,42 @@
}
});
var tablemarhun = $('#marhun').DataTable( {
"columnDefs": [
{
"targets": 0,
"orderable": false
},
{
"targets": 9,
"orderable": false
var tablemarhun = $('#marhun').DataTable( {
"columnDefs": [
{
"targets": 0,
"orderable": false
},
{
"targets": 9,
"orderable": false
}
],
order: [[1, 'asc']],
// "ordering": false,
"info": false,
"lengthChange": false,
"pageLength": 15,
dom: 'Bfrtip',
buttons: [
// 'copy', 'excel', 'pdf'
// { text: 'copy', className: 'btn btn-primary' },
{
className: 'btn btn-outline-success pl-4 pr-4 btn-sm addsim',
text: '<i class="fas fa-plus" id="test"></i>',
titleAttr: 'Tambah Marhun',
action: function ( e, dt, node, config ) {
$('#modaltambahmarhun').modal("show");
}
],
order: [[1, 'asc']],
// "ordering": false,
"info": false,
"lengthChange": false,
"pageLength": 15,
dom: 'Bfrtip',
buttons: [
// 'copy', 'excel', 'pdf'
// { text: 'copy', className: 'btn btn-primary' },
{
className: 'btn btn-outline-success pl-4 pr-4 btn-sm addsim',
text: '<i class="fas fa-plus" id="test"></i>',
titleAttr: 'Tambah Marhun',
action: function ( e, dt, node, config ) {
alert( 'Button activated' );
}
}
]
});
}
]
});
$('.addsim').tooltip();
$('.export').tooltip();
// $( '.dt-buttons').addClass('btn-group');
$( '.addsim').removeClass('dt-button');
$( '.export').removeClass('dt-button');
$('.addsim').tooltip();
$('.export').tooltip();
// $( '.dt-buttons').addClass('btn-group');
$( '.addsim').removeClass('dt-button');
$( '.export').removeClass('dt-button');
function selectall(cb) {
@@ -187,7 +247,41 @@
})
}
function kemaskini(e) {
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.harga * parseFloat(beratemas);
var harga_asastambahan = Math.round(total_tambahan);
$('#hargatambahan').val(parseFloat(item.harga).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')
@@ -236,8 +330,6 @@
$('#nilai_marhun').val(parseFloat(total).toFixed(2));
$('#harga_asas').val(parseFloat(hargaasas).toFixed(2));
}
}
function updateform()
+1
View File
@@ -126,6 +126,7 @@ Route::group(['middleware' => ['permission:semakanmarhun','permission:kemaskinim
Route::post('/kemaskini',['as'=>'marhun.kemaskini','uses'=>'MarhunController@kemaskini']);
Route::get('/semakan',['as'=>'marhun.semakan','uses'=>'MarhunController@semakan']);
Route::get('/semak/{id}',['as'=>'marhun.semak','uses'=>'MarhunController@semak']);
Route::post('/tambahmarhun',['as'=>'marhun.tambahmarhun','uses'=>'MarhunController@tambahmarhun']);
Route::get('/exportmarhundetails/{lelong_id}',['as'=>'marhun.exportmarhundetails','uses'=>'MarhunController@exportmarhundetails']);