Skip to content

Commit

Permalink
Improve Pembayaran
Browse files Browse the repository at this point in the history
  • Loading branch information
andes2912 committed Jul 29, 2022
1 parent 5373baa commit 64e590a
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 55 deletions.
29 changes: 20 additions & 9 deletions Modules/Murid/Http/Controllers/PembayaranController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Modules\Murid\Http\Controllers;

use App\Models\Bank;
use App\Models\User;
use Carbon\Carbon;
use ErrorException;
use Illuminate\Contracts\Support\Renderable;
Expand All @@ -10,6 +12,7 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session;
use Modules\Murid\Http\Requests\ConfirmPaymentRequest;
use Modules\SPP\Entities\DetailPaymentSpp;

class PembayaranController extends Controller
Expand Down Expand Up @@ -61,11 +64,14 @@ public function show($id)
public function edit($id)
{
$payment = DetailPaymentSpp::with('user.muridDetail')->where('user_id', Auth::id())->findOrFail($id);
$accountbanks = User::with('banks')->first();
$bank = Bank::all();

if ($payment->status == 'paid') {
Session::flash('error','Pembayaran Sudah Diterima.');
return redirect('murid/pembayaran');
}
return view('murid::pembayaran.edit', compact('payment'));
return view('murid::pembayaran.edit', compact('payment','accountbanks','bank'));
}

/**
Expand All @@ -74,20 +80,25 @@ public function edit($id)
* @param int $id
* @return Renderable
*/
public function update(Request $request, $id)
public function update(ConfirmPaymentRequest $request, $id)
{
try {
DB::beginTransaction();

$file = $request->file('file');
$file_payment = 'payment-'.time().Auth::id().".".$file->getClientOriginalExtension();
// isi dengan nama folder tempat kemana file diupload
$tujuan_upload = 'public/images/bukti_payment';
$file->storeAs($tujuan_upload,$file_payment);
if ($request->file) {
$file = $request->file('file');
$file_payment = 'payment-'.time().Auth::id().".".$file->getClientOriginalExtension();
// isi dengan nama folder tempat kemana file diupload
$tujuan_upload = 'public/images/bukti_payment';
$file->storeAs($tujuan_upload,$file_payment);
}

$payment = DetailPaymentSpp::where('user_id', Auth::id())->findOrFail($id);
$payment->file = $file_payment;
$payment->date_file = Carbon::now();
$payment->file = $file_payment ?? $payment->file;
$payment->date_file = $request->date_file;
$payment->sender = $request->sender;
$payment->bank_sender = $request->bank_sender;
$payment->destination_bank = $request->destination_bank;
$payment->update();

DB::commit();
Expand Down
46 changes: 46 additions & 0 deletions Modules/Murid/Http/Requests/ConfirmPaymentRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Modules\Murid\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ConfirmPaymentRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'file' => 'required_if:file,null|mimes:jpg,jpeg,png',
'sender' => 'required',
'bank_sender' => 'required',
'destination_bank' => 'required',
'date_file' => 'required'
];
}

public function messages()
{
return [
'file.required' => 'File Bukti Pembayaran tidak boleh kosong.',
'file.mimes' => 'File Bukti Pembayaran tidak valid.',
'sender.required' => 'Nama Pengirim tidak boleh kosong.',
'bank_sender.required' => 'Bank Pengirim tidak boleh kosong.',
'destination_bank' => 'Bank Tujuan tidak boleh kosong.',
'date_file.required' => 'Tanggal Transfer tidak boleh kosong.'
];
}

/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
}
161 changes: 117 additions & 44 deletions Modules/Murid/Resources/views/pembayaran/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,53 +34,126 @@
</div>
<div class="content-body">
<div class="row">
<div class="col-12">
<section>
<div class="card">
<div class="card-header border-bottom">
<h4 class="card-title">Silahkan Upload Bukti Pembayaran</h4>
</div>
<div class="card-body">
<form action=" {{route('pembayaran.update', $payment->id)}} " method="post" enctype="multipart/form-data">
@csrf
@method('PUT')
<div class="row">
<div class="col-6">
<div class="form-group">
<label for="basicInput">NISN</label>
<input type="text" class="form-control" value="{{$payment->user->muridDetail->nisn}}" readonly/>
</div>
</div>
<div class="col-6">
<div class="form-group">
<label for="basicInput">Nama</label>
<input type="text" class="form-control" value="{{$payment->user->name}}" readonly/>
</div>
</div>
<div class="col-6">
<div class="form-group">
<label for="basicInput">Jumlah</label>
<input type="text" class="form-control" value="Rp {{number_format($payment->amount)}}" readonly/>
</div>
</div>
<div class="col-6">
<div class="form-group">
<label for="basicInput">Bukti Bayar</label> <span class="text-danger">*</span>
<input type="file" name="file" class="form-control @error('file') is-invalid @enderror" required/>
@error('file')
<div class="invalid-feedback">
<strong>{{ $message }}</strong>
</div>
@enderror
</div>
<div class="col-md-6">
<div class="card shadow">
<div class="card-body">
<h4 class="font-weight-bold">Lakukan Konfirmasi Pembayaran</h4>
<h6>Silahkan lakukan konfirmasi ketika Anda sudah melakukan transfer.</h6>
<hr>
<form action="{{route('pembayaran.update', $payment->id)}}" method="post" enctype="multipart/form-data">
@csrf
@method('PUT')
<div class="form-group">
<label for="Atas Nama">Nama Pengirim</label>
<input type="text" name="sender" class="form-control @error('sender') is-invalid @enderror" value="{{$payment->sender}}" placeholder="Atas Nama" autocomplete="off">
@error('sender')
<div class="invalid-feedback">
<strong>{{ $message }}</strong>
</div>
@enderror
</div>

<div class="form-group">
<label for="Bank Kamu">Bank Pengirim</label>
<select name="bank_sender" class="select2 form-control @error('bank_sender') is-invalid @enderror">
<option value="">-- Pilih Bank --</option>
@foreach ($bank as $banks)
<option value="{{$banks->nama_bank}}" {{$payment->bank_sender == $banks->nama_bank ? 'selected' : ''}}>{{$banks->nama_bank}}</option>
@endforeach
</select>
@error('bank_sender')
<div class="invalid-feedback">
<strong>{{ $message }}</strong>
</div>
</div>
<button class="btn btn-primary" type="submit">{{$payment->file != null ? 'Update Pembayaran' : 'Bayar'}}</button>
<a href="{{route('pembayaran.index')}}" class="btn btn-warning">Batal</a>
</form>
@enderror
</div>

<div class="form-group">
<label for="Bank Tujuan">Bank Tujuan</label>
<select name="destination_bank" class="form-control select2 @error('destination_bank') is-invalid @enderror">
<option value="">-- Pilih Bank --</option>
@foreach ($accountbanks->banks as $banks)
<option value="{{$banks->bank_name}}" {{$payment->destination_bank == $banks->bank_name ? 'selected' : ''}}>{{$banks->bank_name}}</option>
@endforeach
</select>
@error('destination_bank')
<div class="invalid-feedback">
<strong>{{ $message }}</strong>
</div>
@enderror
</div>

<div class="form-group">
<label for="Tanggal Transfer">Tanggal Transfer</label>
<input type="text" name="date_file" class="form-control flatpickr-basic @error('date_file') is-invalid @enderror" value="{{$payment->date_file}}" placeholder="Tanggal Transfer">
@error('date_file')
<div class="invalid-feedback">
<strong>{{ $message }}</strong>
</div>
@enderror
</div>

<div class="form-group">
<label for="Jumlah">Jumlah</label>
<input type="text" value="Rp {{number_format($payment->amount)}}" class="form-control" placeholder="Jumlah" readonly disabled>
</div>
</section>

<div class="form-group">
<label for="Jumlah">File Bukti Transfer</label>
<input type="file" class="form-control @error('file') is-invalid @enderror" name="file">
@error('file')
<div class="invalid-feedback">
<strong>{{ $message }}</strong>
</div>
@enderror
</div>

<div class="form-group">
<button class="btn btn-primary" type="submit">{{$payment->file != null ? 'Update Pembayaran' : 'Konfirmasi'}}</button>
<a href="{{route('pembayaran.index')}}" class="btn btn-warning">Batal</a>
</div>
</form>
</div>
</div>
</div>

<div class="col-md-6">
<div class="card shadow">
<div class="card-body">
<h6>Mohon untuk mentransfer sesuai dengan jumlah yang ditentukan.</h6>
</div>
</div>
<div class="card shadow">
<div class="card-body">
<div class="d-flex justify-content-between">
<span>
Jumlah :
<span style="font-weight: bold">Rp {{number_format($payment->amount)}}</span>
</span>
<span style="font-size: 21px">
<i class="feather icon-credit-card"></i>
</span>
</div>
<hr>
<div class="d-flex justify-content-between">
<span>
@foreach ($accountbanks->banks as $bank)
<ul>
<li style="color:cadetblue; font-weight:bold">{{$bank->bank_name}}</li>
<li>{{$bank->account_name}}</li>
<li>{{$bank->account_number}}</li>
</ul>
@endforeach
</span>
</div>
<hr>
<div class="d-flex justify-content-between">
<span>
Pembayaran SPP bulan {{$payment->month}}
</span>
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddColumnInDetailPaymentSppsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('detail_payment_spps', function (Blueprint $table) {
$table->string('sender')->after('user_id')->nullable();
$table->string('bank_sender')->after('sender')->nullable();
$table->string('destination_bank')->after('bank_sender')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('detail_payment_spps', function (Blueprint $table) {

});
}
}
14 changes: 13 additions & 1 deletion Modules/SPP/Resources/views/murid/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
data-nisn="{{$detail->user->muridDetail->nisn}}"
data-month="{{$detail->month}}"
data-amount="Rp {{number_format($detail->amount)}}"
data-sender="{{$detail->sender}}"
data-banksender="{{$detail->bank_sender}}"
data-datefile="{{$detail->date_file}}"
data-destinationbank="{{$detail->destination_bank}}"
>Proses</a>
<a href="{{$detail->url_file}}" target="_blank" class="btn btn-info btn-sm">Bukti Bayar</a>
@elseif($detail->status == 'paid')
Expand Down Expand Up @@ -104,11 +108,19 @@
var name = $(this).attr('data-name');
var month = $(this).attr('data-month');
var amount = $(this).attr('data-amount');
var sender = $(this).attr('data-sender');
var banksender = $(this).attr('data-banksender');
var datefile = $(this).attr('data-datefile');
var destinationbank = $(this).attr('data-destinationbank');
$("#id_payment").val(id)
$("#nisn").val(nisn)
$("#name").val(name)
$("#month").val(month)
$("#amount").val(amount)
$("#sender").val(sender)
$("#banksender").val(banksender)
$("#datefile").val(datefile)
$("#destinationbank").val(destinationbank)
});
// Proses Update Data Peminjam
Expand All @@ -120,4 +132,4 @@
});
});
</script>
@endsection
@endsection
30 changes: 29 additions & 1 deletion Modules/SPP/Resources/views/murid/update.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,34 @@
<input type="text" class="form-control" id="amount" readonly>
</div>
</div>

<div class="col-12">
<h5>Detail Pembayaran</h5>
</div>
<div div class="col-6">
<div class="form-group">
<label for="basicInput">Nama Pengirim</label>
<input type="text" class="form-control" id="sender" readonly>
</div>
</div>
<div div class="col-6">
<div class="form-group">
<label for="basicInput">Bank Pengirim</label>
<input type="text" class="form-control" id="banksender" readonly>
</div>
</div>
<div div class="col-6">
<div class="form-group">
<label for="basicInput">Tanggal Transfer</label>
<input type="text" class="form-control" id="datefile" readonly>
</div>
</div>
<div div class="col-6">
<div class="form-group">
<label for="basicInput">Bank Tujuan</label>
<input type="text" class="form-control" id="destinationbank" readonly>
</div>
</div>
</div>
</div>
<div class="modal-footer">
Expand All @@ -46,4 +74,4 @@
</div>
</div>
</div>
</div>
</div>

0 comments on commit 64e590a

Please sign in to comment.