Merge branch 'atie' into 'main'
add function pindah id lelong by sag See merge request online-sistem1/lelong!104
This commit is contained in:
@@ -2228,6 +2228,121 @@ class LelongController extends Controller
|
||||
return redirect()->route('lelong.tukartarikhlelong');
|
||||
}
|
||||
|
||||
public function listsagpindah($lelongid, $cawid){
|
||||
// $marhun = LelongBid::->get();
|
||||
|
||||
$keuntungan = 0;
|
||||
|
||||
|
||||
$marhuns = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id')
|
||||
->join('gadai','lelongbid.norujukan','=','gadai.norujukan')
|
||||
->where('lelong_id','=',$lelongid)->where('caw_id','=',$cawid)
|
||||
->select(
|
||||
'lelongbid.t_lelong',
|
||||
'lelongbid.kodcaw',
|
||||
'cawangan.caw_name',
|
||||
'lelongbid.norujukan',
|
||||
'lelongbid.pinjaman',
|
||||
'lelongbid.berat',
|
||||
'lelongbid.nilaimarhun',
|
||||
'lelongbid.hargaasas',
|
||||
'lelongbid.upahsimpan',
|
||||
'lelongbid.cajlelong',
|
||||
'lelongbid.baki',
|
||||
'lelongbid.bakiupah',
|
||||
'lelongbid.status_jual',
|
||||
'lelongbid.jbg',
|
||||
'gadai.bakipjm',
|
||||
'gadai.bakihargajualan',
|
||||
'gadai.upah12',
|
||||
'gadai.ansakhir',
|
||||
'gadai.tempoh',
|
||||
'gadai.tempohbayar',
|
||||
'gadai.kadarupah'
|
||||
)
|
||||
->get()->toArray();
|
||||
|
||||
foreach ($marhuns as $index1=> $cal) {
|
||||
|
||||
$keuntungan = $cal['bakipjm'] - ($cal['bakihargajualan'] - ($cal['upah12'] - $cal['ansakhir'])-(($cal['tempoh']-$cal['tempohbayar'])*$cal['kadarupah']/100*$cal['bakipjm']) );
|
||||
$marhuns[$index1]['keuntungan'] = bcdiv($keuntungan,1,1);
|
||||
|
||||
$simulasilel = Lelong::where('id',$lelongid)->get();
|
||||
$sumcajlelong = $cal['hargaasas'] * ($simulasilel[0]['cajlelong']/100);
|
||||
$totalbaki = $cal['hargaasas'] - $cal['pinjaman'] - bcdiv($keuntungan,1,1) - bcdiv($sumcajlelong,1,1);
|
||||
|
||||
$marhuns[$index1]['cajlelong'] = bcdiv($sumcajlelong,1,1);
|
||||
$marhuns[$index1]['baki'] = $totalbaki;
|
||||
}
|
||||
|
||||
$arrayinfo = [];
|
||||
|
||||
$lelong_id = Lelong::join('cawangan_lelong','lelong.id','=','cawangan_lelong.lelong_id')
|
||||
->where('cawangan_lelong.lelong_id','=',$lelongid)
|
||||
->select('lelong_id','tarikh_lelong')
|
||||
->groupBy('lelong_id')
|
||||
->get()->toArray();
|
||||
|
||||
|
||||
foreach($lelong_id as $laporan)
|
||||
{
|
||||
$details = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
||||
->where('lelong_id',$laporan['lelong_id'])
|
||||
->where('caw_id',$cawid)
|
||||
->get()
|
||||
->toArray();
|
||||
array_push($arrayinfo,['laporan' => $laporan,'details' => $details]);
|
||||
}
|
||||
|
||||
$datapindah = lelong::join('cawangan_lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
||||
->select("lelong.id","lelong.tarikh_lelong","lelong.kali","cawangan_lelong.caw_id")
|
||||
->where('sts_lelong', 0)
|
||||
->where('lelong.id','!=', $lelong_id)
|
||||
->where('cawangan_lelong.caw_id','=', $cawid)
|
||||
->get()->toArray();
|
||||
// dd($datapindah);
|
||||
foreach($datapindah as $row)
|
||||
{
|
||||
$id = $row['id'];
|
||||
$tarikh_lelong = date('d-m-Y', strtotime($row['tarikh_lelong']));;
|
||||
|
||||
}
|
||||
return view('lelong.listsagpindah',compact('datapindah','marhuns','lelongid','cawid','arrayinfo'));
|
||||
}
|
||||
|
||||
public function pindahlelongbysag(Request $request){
|
||||
// dd($request->checkboxdata);
|
||||
$data = $request->checkboxdata;
|
||||
$lelongidasal = $request->lelongid;
|
||||
$lelongidbaru = $request->lelongidbaru;
|
||||
// dd($lelongidbaru);
|
||||
foreach($data as $index=>$norujukan)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$currentdate = Carbon::now();
|
||||
$currentdate = $currentdate->toDateTimeString();
|
||||
// dd($lelongidasal);
|
||||
|
||||
|
||||
$pindahlelongsag = LelongBid::where('norujukan','=',$norujukan)->first();
|
||||
$pindahlelongsag->lelong_id = $lelongidbaru;
|
||||
$pindahlelongsag->update();
|
||||
|
||||
//insert loguser
|
||||
$loguser = new LogUser;
|
||||
$loguser->user_id = $user->id;
|
||||
$loguser->date = $currentdate;
|
||||
$loguser->username = $user->username;
|
||||
$loguser->nama_user = $user->name;
|
||||
$loguser->norujukan = $norujukan;
|
||||
$loguser->nota = 'Pindah Lelong '.$lelongidasal.'-'.$lelongidbaru;
|
||||
$loguser->save();
|
||||
}
|
||||
|
||||
return redirect()->route('lelong.listsagpindah',['lelongid'=>$request->lelongid,'cawid'=>$request->cawid])
|
||||
->with('success','Pindah ID Lelong Berjaya');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row ">
|
||||
<div class="col-md-11 mx-auto card p-4">
|
||||
<div class="nav nav-tabs" id="nav-tab" role="tablist">
|
||||
<button type="button" class="btn btn-light" ><a href="javascript:window.history.go(-1);"><h3><i class="fas fa-arrow-alt-circle-left"></i></h3></a></button>
|
||||
</div>
|
||||
<span class="pt-3" style="margin-left:1%; font-size:20px"><b>Senarai Lelong(Pindah ID Lelong)</b></span>
|
||||
@foreach ($arrayinfo as $laporan)
|
||||
|
||||
<span class="pt-3" style="margin-left:1%;"><b>ID Lelong : {{ $laporan['laporan']['lelong_id']}}</b></span>
|
||||
<span class="pt-3" style="margin-left:1%;"><b>Tarikh Lelong : @php
|
||||
$myDateTime = DateTime::createFromFormat('Y-m-d', $laporan['laporan']['tarikh_lelong'] );
|
||||
$datez = $myDateTime->format('d-m-Y');
|
||||
echo($datez);
|
||||
|
||||
@endphp</b></span>
|
||||
@foreach($laporan['details'] as $details)
|
||||
<span class="pt-3" style="margin-left:1%;"><b>Nama Cawangan : {{ $details['caw_name']}}</b></span>
|
||||
<span class="pt-3" style="margin-left:1%;"><b>Kod Cawangan : {{ $details['caw_code']}}</b></span>
|
||||
@endforeach
|
||||
|
||||
@endforeach
|
||||
|
||||
@if ($message = Session::get('success'))
|
||||
<div class="alert alert-success">
|
||||
<p>{{ $message }}</p>
|
||||
</div>
|
||||
@endif
|
||||
<form id="deletesag" action="{{route('lelong.pindahlelongbysag')}}" method="POST">
|
||||
@csrf
|
||||
<input type="hidden" name="lelongid" value="{{$lelongid}}">
|
||||
<input type="hidden" name="cawid" value="{{$cawid}}">
|
||||
<div> Pindah Ke-</div>
|
||||
<select class="js-states browser-default select2" name="lelongidbaru" required id="lelongidbaru">
|
||||
<option value="option_select" disabled selected>SILA PILIH ID LELONG</option>
|
||||
@foreach($datapindah as $data)
|
||||
<option value="{{ $data['id'] }}">ID Lelong:{{ $data['id']}} / Tarikh: {{ $data['tarikh_lelong']}} / Kali Ke-: {{ $data['kali']}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<button type="submit" class="btn btn-success">Pindah Lelong</button>
|
||||
<table class="table table-striped table-xl" id="marhun" style="width:100%">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th>Pilih</th>
|
||||
<th>No.</th>
|
||||
<th>No rujukan</th>
|
||||
<th>Tempoh</th>
|
||||
<th>Berat (gm)</th>
|
||||
<th>Nilai Marhun (RM)</th>
|
||||
<th>Harga Asas (RM)</th>
|
||||
<th>Pembiayaan (RM)</th>
|
||||
<th>Keuntungan (RM)</th>
|
||||
<th>Caj Lelong (%)</th>
|
||||
<th>Rugi Lelong (RM)</th>
|
||||
<th>Baki Lelong (RM)</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($marhuns as $index=> $marhun)
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<input type="checkbox" aria-label="Checkbox for following text input" onclick="btnDelete(this)" name="checkboxdata[]" value="{{ $marhun['norujukan'] }}">
|
||||
</td>
|
||||
<td>{{$loop->iteration}}</td>
|
||||
<td>{{ $marhun['norujukan']}}</td>
|
||||
<td>{{ $marhun['jbg']}}</td>
|
||||
<td>{{ $marhun['berat'] }}</td>
|
||||
<td>{{ number_format($marhun['nilaimarhun'], 2, '.', ',') }}</td>
|
||||
<td>{{ number_format($marhun['hargaasas'], 2, '.', ',') }}</td>
|
||||
<td>{{ number_format($marhun['pinjaman'] , 2, '.', ',') }}</td>
|
||||
<td>{{ number_format($marhun['bakiupah'], 2, '.', ',') }}</td>
|
||||
|
||||
{{-- <td>{{ $marhun['keuntungan'] }}</td> --}}
|
||||
<td>{{ number_format($marhun['cajlelong'], 2, '.', ',') }}</td>
|
||||
<?php
|
||||
$rugi = 0;
|
||||
$baki = 0;
|
||||
if(strpos($marhun['baki'], '-') !== false)
|
||||
{
|
||||
$rugi = $marhun['baki'];
|
||||
}
|
||||
else {
|
||||
$baki = $marhun['baki'];
|
||||
}
|
||||
?>
|
||||
<td>{{number_format($rugi, 2, '.', ',')}}</td>
|
||||
<td>{{number_format($baki, 2, '.', ',')}}</td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
<div class="text-right pt-4">
|
||||
<!-- <a href="{{ route('lelong.show',$lelongid) }}" class="btn btn-primary">Kembali</a>
|
||||
<button type="button" class="btn btn-danger" id="btndelete" onclick="confirm()">Padam</button> -->
|
||||
</div>
|
||||
{{-- <a href="{{url('lelong/senarailelong')}}" class="btn btn-primary">Kembali</a> --}}
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$("#btndelete").prop("disabled", true);
|
||||
function btnDelete(e) {
|
||||
var count = 0;
|
||||
tablemarhun.rows().nodes().to$().find('input[type="checkbox"]').each(function(){
|
||||
if($(this).prop('checked') === true)
|
||||
{
|
||||
count = count + 1;
|
||||
}
|
||||
// $(this).prop('checked', e.checked);
|
||||
})
|
||||
if(count != 0)
|
||||
{
|
||||
$("#btndelete").prop("disabled", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#btndelete").prop("disabled", true);
|
||||
}
|
||||
// let checkbox = $('#checkboxdata').val();
|
||||
// console.log(checkbox)
|
||||
// $("#btndelete").prop("disabled", checkboxdata.length === 0);
|
||||
}
|
||||
function confirm() {
|
||||
$.confirm({
|
||||
title: 'Confirmation',
|
||||
content: 'Anda pasti?',
|
||||
type: 'red',
|
||||
typeAnimated: true,
|
||||
buttons: {
|
||||
Delete: {
|
||||
btnClass: 'btn-danger',
|
||||
action: function () {
|
||||
$("#deletesag").submit();
|
||||
}
|
||||
},
|
||||
Batal: {
|
||||
btnClass: 'btn-default',
|
||||
action: function () {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var tablemarhun = $('#marhun').DataTable( {
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": 13,
|
||||
"orderable": false
|
||||
},
|
||||
// {
|
||||
// "targets": 4,
|
||||
// "orderable": false
|
||||
// }
|
||||
],
|
||||
// order: [[1, 'asc']],
|
||||
// "ordering": false,
|
||||
"info": false,
|
||||
"lengthChange": false,
|
||||
"pageLength": 999999,
|
||||
dom: 'Bfrtip',
|
||||
// buttons: [
|
||||
// // 'copy', 'excel', 'pdf'
|
||||
// // { text: 'copy', className: 'btn btn-primary' },
|
||||
// {
|
||||
// className: 'btn btn-outline-success pl-4 pr-4 btn-sm adduser',
|
||||
// text: '<i class="fas fa-plus" id="test"></i>',
|
||||
// titleAttr: 'Tambah Pengguna',
|
||||
// action: function ( e, dt, node, config ) {
|
||||
// alert( 'Button activated' );
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// className: 'btn btn-outline-secondary pl-4 pr-4 btn-sm export',
|
||||
// titleAttr: 'Export to CSV',
|
||||
// text: '<i class="fas fa-download"></i>',
|
||||
// action: function ( e, dt, node, config ) {
|
||||
// $("#exportform").submit();
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
});
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
@@ -43,7 +43,7 @@
|
||||
<tr>
|
||||
<td><input type="radio" aria-label="Checkbox for following text input" name="caw[]" id="caw" value = "{{ $caw['kodcaw'] }}" class="custom_name"></td>
|
||||
<td>{{$index+1}}</td>
|
||||
<td><a href=" {{ route('lelong.senaraimarhunsimulasi',['lelongid'=>$lelong_id,'cawid'=>$caw['id_cawangan']]) }} " target="blank" style="color:#3490dc">{{ $caw['cawangan'] }}</a></td>
|
||||
<td><a href=" {{ route('lelong.listsagpindah',['lelongid'=>$lelong_id,'cawid'=>$caw['id_cawangan']]) }} " target="blank" style="color:#3490dc">{{ $caw['cawangan'] }}</a></td>
|
||||
<td align = 'center'>{{ $caw['bil_marhun'] }}</td>
|
||||
<td align = 'right'>{{ number_format($caw['berat'], 2, '.', ',') }}</td>
|
||||
<td align = 'right'>{{ number_format($caw['n_marhun'], 2, '.', ',') }}</td>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<th>Nama</th>
|
||||
<th>Nama Pengguna</th>
|
||||
<th>Emel</th>
|
||||
<th>Cawangan</th>
|
||||
<th>Taraf</th>
|
||||
<th>Status</th>
|
||||
<th class="text-center">Action</th>
|
||||
@@ -42,6 +43,7 @@
|
||||
<td>{{ $user->name }}</td>
|
||||
<td>{{ $user->username }}</td>
|
||||
<td>{{ $user->email }}</td>
|
||||
<td>{{ $user->kodcaw }}</td>
|
||||
|
||||
<td>
|
||||
@foreach ($user->roles as $taraf)
|
||||
|
||||
@@ -115,6 +115,8 @@ Route::group(['prefix'=>'lelong'], function () {
|
||||
Route::get('/pindahsenarailelong',['as'=>'lelong.pindahsenarailelong','uses'=>'LelongController@pindahsenarailelong']);
|
||||
Route::get('/temppindahsenarailelong/{lelong_id}',['as'=>'lelong.temppindahsenarailelong','uses'=>'LelongController@temppindahsenarailelong']);
|
||||
Route::post('/pindahjanadata',['as'=>'lelong.pindahjanadata','uses'=>'LelongController@pindahjanadata']);
|
||||
Route::get('/listsagpindah/{lelongid}/{cawid}', ['as'=>'lelong.listsagpindah','uses'=>'LelongController@listsagpindah']);
|
||||
Route::post('/pindahlelongbysag', ['as'=>'lelong.pindahlelongbysag','uses'=>'LelongController@pindahlelongbysag']);
|
||||
//tukartarikhlelong
|
||||
Route::get('/tukartarikhlelong',['as'=>'lelong.tukartarikhlelong','uses'=>'LelongController@tukartarikhlelong']);
|
||||
Route::get('/temptukartarikhlelong/{lelong_id}',['as'=>'lelong.temptukartarikhlelong','uses'=>'LelongController@temptukartarikhlelong']);
|
||||
|
||||
Reference in New Issue
Block a user