revised form meeting seminar
This commit is contained in:
@@ -65,6 +65,18 @@ class FormMeetingSeminarController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.country.view']);
|
||||
|
||||
$form = FormMeetingSeminar::with('user')->findOrFail($id);
|
||||
$form->bukti_allowance = $form->bukti_allowance ? NextCloudHelper::getFileUrl($form->bukti_allowance) : null;
|
||||
$form->bukti_transport_ankot = $form->bukti_transport_ankot ? NextCloudHelper::getFileUrl($form->bukti_transport_ankot) : null;
|
||||
$form->bukti_hotel = $form->bukti_hotel ? NextCloudHelper::getFileUrl($form->bukti_hotel) : null;
|
||||
|
||||
return response()->json($form);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.meeting.create']);
|
||||
@@ -77,12 +89,12 @@ class FormMeetingSeminarController extends Controller
|
||||
$this->checkAuthorization(auth()->user(), ['forms.meeting.create']);
|
||||
|
||||
$request->validate([
|
||||
'allowance' => 'required',
|
||||
'transport_ankot' => 'required',
|
||||
'hotel' => 'required',
|
||||
'bukti1' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti2' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'allowance' => 'nullable|numeric',
|
||||
'transport_ankot' => 'nullable|numeric',
|
||||
'hotel' => 'nullable|numeric',
|
||||
'bukti_allowance' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti_transport_ankot' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti_hotel' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
||||
@@ -92,40 +104,40 @@ class FormMeetingSeminarController extends Controller
|
||||
$filePaths = [];
|
||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/meeting';
|
||||
|
||||
if ($request->hasFile('bukti1')) {
|
||||
$bukti1 = $request->file('bukti1');
|
||||
$filename = Str::uuid() . '.' . $bukti1->extension();
|
||||
if ($request->hasFile('bukti_allowance')) {
|
||||
$bukti_allowance = $request->file('bukti_allowance');
|
||||
$filename = Str::uuid() . '.' . $bukti_allowance->extension();
|
||||
|
||||
$filePaths['bukti1'] = $folderPath . '/' . $filename;
|
||||
$filePaths['bukti_allowance'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti1->getContent(),
|
||||
$bukti_allowance->getContent(),
|
||||
$filename
|
||||
);
|
||||
|
||||
}
|
||||
if ($request->hasFile('bukti2')) {
|
||||
$bukti2 = $request->file('bukti2');
|
||||
$filename = Str::uuid() . '.' . $bukti2->extension();
|
||||
if ($request->hasFile('bukti_transport_ankot')) {
|
||||
$bukti_transport_ankot = $request->file('bukti_transport_ankot');
|
||||
$filename = Str::uuid() . '.' . $bukti_transport_ankot->extension();
|
||||
|
||||
$filePaths['bukti2'] = $folderPath . '/' . $filename;
|
||||
$filePaths['bukti_transport_ankot'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti2->getContent(),
|
||||
$bukti_transport_ankot->getContent(),
|
||||
$filename
|
||||
);
|
||||
}
|
||||
if ($request->hasFile('bukti3')) {
|
||||
$bukti3 = $request->file('bukti3');
|
||||
$filename = Str::uuid() . '.' . $bukti3->extension();
|
||||
if ($request->hasFile('bukti_hotel')) {
|
||||
$bukti_hotel = $request->file('bukti_hotel');
|
||||
$filename = Str::uuid() . '.' . $bukti_hotel->extension();
|
||||
|
||||
$filePaths['bukti3'] = $folderPath . '/' . $filename;
|
||||
$filePaths['bukti_hotel'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti3->getContent(),
|
||||
$bukti_hotel->getContent(),
|
||||
$filename
|
||||
);
|
||||
}
|
||||
@@ -135,17 +147,23 @@ class FormMeetingSeminarController extends Controller
|
||||
$formatted_sequence_number = str_pad($sequence_number, 4, '0', STR_PAD_LEFT);
|
||||
$expense_number = $region->code . '-' . $cabang->code . '-MTG-' . date('ym') . $formatted_sequence_number;
|
||||
|
||||
$data_nominal = [
|
||||
'allowance' => $request->allowance ?? 0,
|
||||
'transport_ankot' => $request->transport_ankot ?? 0,
|
||||
'hotel' => $request->hotel ?? 0,
|
||||
];
|
||||
|
||||
// Save the form data
|
||||
FormMeetingSeminar::create([
|
||||
'expense_number' => $expense_number,
|
||||
'user_id' => auth()->user()->id,
|
||||
'allowance' => $request->allowance,
|
||||
'transport_ankot' => $request->transport_ankot,
|
||||
'hotel' => $request->hotel,
|
||||
'total' => $request->allowance + $request->transport_ankot + $request->hotel,
|
||||
'bukti1' => $filePaths['bukti1'] ?? null,
|
||||
'bukti2' => $filePaths['bukti2'] ?? null,
|
||||
'bukti3' => $filePaths['bukti3'] ?? null,
|
||||
'allowance' => $data_nominal['allowance'],
|
||||
'transport_ankot' => $data_nominal['transport_ankot'],
|
||||
'hotel' => $data_nominal['hotel'],
|
||||
'total' => array_sum($data_nominal),
|
||||
'bukti_allowance' => $filePaths['bukti_allowance'] ?? null,
|
||||
'bukti_transport_ankot' => $filePaths['bukti_transport_ankot'] ?? null,
|
||||
'bukti_hotel' => $filePaths['bukti_hotel'] ?? null,
|
||||
'account_number' => $kategori->account_number,
|
||||
'status' => 'On Progress',
|
||||
]);
|
||||
@@ -175,12 +193,12 @@ class FormMeetingSeminarController extends Controller
|
||||
$this->checkAuthorization(auth()->user(), ['forms.meeting.edit']);
|
||||
|
||||
$request->validate([
|
||||
'allowance' => 'required',
|
||||
'transport_ankot' => 'required',
|
||||
'hotel' => 'required',
|
||||
'bukti1' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti2' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'allowance' => 'nullable|numeric',
|
||||
'transport_ankot' => 'nullable|numeric',
|
||||
'hotel' => 'nullable|numeric',
|
||||
'bukti_allowance' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti_transport_ankot' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti_hotel' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$form = FormMeetingSeminar::findOrfail($id);
|
||||
@@ -196,53 +214,59 @@ class FormMeetingSeminarController extends Controller
|
||||
$filePaths = [];
|
||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/meeting';
|
||||
|
||||
if ($request->hasFile('bukti1')) {
|
||||
$bukti1 = $request->file('bukti1');
|
||||
$filename = Str::uuid() . '.' . $bukti1->extension();
|
||||
if ($request->hasFile('bukti_allowance')) {
|
||||
$bukti_allowance = $request->file('bukti_allowance');
|
||||
$filename = Str::uuid() . '.' . $bukti_allowance->extension();
|
||||
|
||||
$filePaths['bukti1'] = $folderPath . '/' . $filename;
|
||||
$filePaths['bukti_allowance'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti1->getContent(),
|
||||
$bukti_allowance->getContent(),
|
||||
$filename
|
||||
);
|
||||
|
||||
}
|
||||
if ($request->hasFile('bukti2')) {
|
||||
$bukti2 = $request->file('bukti2');
|
||||
$filename = Str::uuid() . '.' . $bukti2->extension();
|
||||
if ($request->hasFile('bukti_transport_ankot')) {
|
||||
$bukti_transport_ankot = $request->file('bukti_transport_ankot');
|
||||
$filename = Str::uuid() . '.' . $bukti_transport_ankot->extension();
|
||||
|
||||
$filePaths['bukti2'] = $folderPath . '/' . $filename;
|
||||
$filePaths['bukti_transport_ankot'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti2->getContent(),
|
||||
$bukti_transport_ankot->getContent(),
|
||||
$filename
|
||||
);
|
||||
}
|
||||
if ($request->hasFile('bukti3')) {
|
||||
$bukti3 = $request->file('bukti3');
|
||||
$filename = Str::uuid() . '.' . $bukti3->extension();
|
||||
if ($request->hasFile('bukti_hotel')) {
|
||||
$bukti_hotel = $request->file('bukti_hotel');
|
||||
$filename = Str::uuid() . '.' . $bukti_hotel->extension();
|
||||
|
||||
$filePaths['bukti3'] = $folderPath . '/' . $filename;
|
||||
$filePaths['bukti_hotel'] = $folderPath . '/' . $filename;
|
||||
|
||||
NextCloudHelper::uploadFile(
|
||||
$folderPath,
|
||||
$bukti3->getContent(),
|
||||
$bukti_hotel->getContent(),
|
||||
$filename
|
||||
);
|
||||
}
|
||||
|
||||
$data_nominal = [
|
||||
'allowance' => $request->allowance ?? 0,
|
||||
'transport_ankot' => $request->transport_ankot ?? 0,
|
||||
'hotel' => $request->hotel ?? 0,
|
||||
];
|
||||
|
||||
// Save the form data
|
||||
$form->update([
|
||||
'allowance' => $request->allowance,
|
||||
'transport_ankot' => $request->transport_ankot,
|
||||
'hotel' => $request->hotel,
|
||||
'allowance' => $data_nominal['allowance'],
|
||||
'transport_ankot' => $data_nominal['transport_ankot'],
|
||||
'hotel' => $data_nominal['hotel'],
|
||||
'total' => $request->allowance + $request->transport_ankot + $request->hotel,
|
||||
'bukti1' => $filePaths['bukti1'] ?? $form->bukti1,
|
||||
'bukti2' => $filePaths['bukti2'] ?? $form->bukti2,
|
||||
'bukti3' => $filePaths['bukti3'] ?? $form->bukti3,
|
||||
'bukti_allowance' => $filePaths['bukti_allowance'] ?? $form->bukti_allowance,
|
||||
'bukti_transport_ankot' => $filePaths['bukti_transport_ankot'] ?? $form->bukti_transport_ankot,
|
||||
'bukti_hotel' => $filePaths['bukti_hotel'] ?? $form->bukti_hotel,
|
||||
'account_number' => $kategori->account_number,
|
||||
]);
|
||||
|
||||
@@ -251,21 +275,31 @@ class FormMeetingSeminarController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function approve($id)
|
||||
public function approve(Request $request, $id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
|
||||
$form = FormMeetingSeminar::findOrfail($id);
|
||||
$approved_data = [
|
||||
'allowance' => $request->allowance ? $form->allowance : 0,
|
||||
'transport_ankot' => $request->transport_ankot ? $form->transport_ankot : 0,
|
||||
'hotel' => $request->hotel ? $form->hotel : 0,
|
||||
];
|
||||
|
||||
$form->update([
|
||||
'approved_at' => now(),
|
||||
'approved_by' => auth()->user()->id,
|
||||
'status' => 'Approved'
|
||||
'status' => 'Approved',
|
||||
'approved_allowance' => $approved_data['allowance'],
|
||||
'approved_transport_ankot' => $approved_data['transport_ankot'],
|
||||
'approved_hotel' => $approved_data['hotel'],
|
||||
'approved_total' => array_sum($approved_data),
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
@@ -287,12 +321,12 @@ class FormMeetingSeminarController extends Controller
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total
|
||||
));
|
||||
// Mail::to($recipients)->send(new ExpenseApproved(
|
||||
// $name,
|
||||
// $expense_number,
|
||||
// $tanggal,
|
||||
// $total
|
||||
// ));
|
||||
|
||||
// Send bulk WhatsApp message
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number);
|
||||
@@ -321,7 +355,7 @@ class FormMeetingSeminarController extends Controller
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
@@ -343,12 +377,12 @@ class FormMeetingSeminarController extends Controller
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new FinalApprove(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total
|
||||
));
|
||||
// Mail::to($recipients)->send(new FinalApprove(
|
||||
// $name,
|
||||
// $expense_number,
|
||||
// $tanggal,
|
||||
// $total
|
||||
// ));
|
||||
|
||||
// send whatsapp message
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number);
|
||||
@@ -386,7 +420,7 @@ class FormMeetingSeminarController extends Controller
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
@@ -408,12 +442,12 @@ class FormMeetingSeminarController extends Controller
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseRejected(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total
|
||||
));
|
||||
// Mail::to($recipients)->send(new ExpenseRejected(
|
||||
// $name,
|
||||
// $expense_number,
|
||||
// $tanggal,
|
||||
// $total
|
||||
// ));
|
||||
|
||||
// Send bulk WhatsApp message
|
||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number);
|
||||
|
||||
@@ -21,9 +21,9 @@ class FormMeetingSeminar extends Model
|
||||
'approved_transport_ankot',
|
||||
'approved_hotel',
|
||||
'approved_total',
|
||||
'bukti1',
|
||||
'bukti2',
|
||||
'bukti3',
|
||||
'bukti_allowance',
|
||||
'bukti_transport_ankot',
|
||||
'bukti_hotel',
|
||||
'account_number',
|
||||
'status',
|
||||
'approved_at',
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('form_meeting_seminar', function (Blueprint $table) {
|
||||
$table->integer('allowance')->nullable()->change();
|
||||
$table->integer('transport_ankot')->nullable()->change();
|
||||
$table->integer('hotel')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('form_meeting_seminar', function (Blueprint $table) {
|
||||
$table->integer('allowance')->nullable(false)->change();
|
||||
$table->integer('transport_ankot')->nullable(false)->change();
|
||||
$table->integer('hotel')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('form_meeting_seminar', function (Blueprint $table) {
|
||||
$table->dropColumn('bukti1');
|
||||
$table->dropColumn('bukti2');
|
||||
$table->dropColumn('bukti3');
|
||||
|
||||
$table->string('bukti_allowance')->after('approved_total')->nullable();
|
||||
$table->string('bukti_transport_ankot')->after('bukti_allowance')->nullable();
|
||||
$table->string('bukti_hotel')->after('bukti_transport_ankot')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('form_meeting_seminar', function (Blueprint $table) {
|
||||
$table->dropColumn('bukti_allowance');
|
||||
$table->dropColumn('bukti_transport_ankot');
|
||||
$table->dropColumn('bukti_hotel');
|
||||
|
||||
$table->string('bukti1')->after('approved_total')->nullable()->change();
|
||||
$table->string('bukti2')->after('bukti1')->nullable()->change();
|
||||
$table->string('bukti3')->after('bukti2')->nullable()->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -33,30 +33,30 @@
|
||||
<div class="col-lg-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Allowance</label>
|
||||
<input type="text" class="form-control" name="allowance" id="allowance" required value="{{ old('allowance') }}">
|
||||
<input type="text" class="form-control" name="allowance" id="allowance" value="{{ old('allowance') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti Allowance</label>
|
||||
<input type="file" class="form-control" name="bukti_allowance" value="{{ old('bukti_allowance') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Transport Antar Kota</label>
|
||||
<input type="text" class="form-control" name="transport_ankot" id="transport_ankot" required value="{{ old('transport_ankot') }}">
|
||||
<input type="text" class="form-control" name="transport_ankot" id="transport_ankot" value="{{ old('transport_ankot') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Hotel</label>
|
||||
<input type="text" class="form-control" name="hotel" id="hotel" required value="{{ old('hotel') }}">
|
||||
<label class="form-label">Bukti Transport Antar Kota</label>
|
||||
<input type="file" class="form-control" name="bukti_transport_ankot" value="{{ old('bukti_transport_ankot') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti 1</label>
|
||||
<input type="file" class="form-control" name="bukti1" value="{{ old('bukti1') }}">
|
||||
<label class="form-label">Hotel</label>
|
||||
<input type="text" class="form-control" name="hotel" id="hotel" value="{{ old('hotel') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti 2</label>
|
||||
<input type="file" class="form-control" name="bukti2" value="{{ old('bukti2') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti 3</label>
|
||||
<input type="file" class="form-control" name="bukti3" value="{{ old('bukti3') }}">
|
||||
<label class="form-label">Bukti Hotel</label>
|
||||
<input type="file" class="form-control" name="bukti_hotel" value="{{ old('bukti_hotel') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -34,34 +34,34 @@
|
||||
<div class="col-lg-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Allowance</label>
|
||||
<input type="text" class="form-control" name="allowance" id="allowance" required value="{{ $form->allowance }}">
|
||||
<input type="text" class="form-control" name="allowance" id="allowance" value="{{ $form->allowance }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti Allowance</label>
|
||||
<input type="file" class="form-control" name="bukti_allowance" value="{{ old('bukti_allowance') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Transport Antar Kota</label>
|
||||
<input type="text" class="form-control" name="transport_ankot" id="transport_ankot" required value="{{ $form->transport_ankot }}">
|
||||
<input type="text" class="form-control" name="transport_ankot" id="transport_ankot" value="{{ $form->transport_ankot }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Hotel</label>
|
||||
<input type="text" class="form-control" name="hotel" id="hotel" required value="{{ $form->hotel }}">
|
||||
<label class="form-label">Bukti Transport Antar Kota</label>
|
||||
<input type="file" class="form-control" name="bukti_transport_ankot" value="{{ old('bukti_transport_ankot') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti 1</label>
|
||||
<input type="file" class="form-control" name="bukti1" value="{{ old('bukti1') }}">
|
||||
<label class="form-label">Hotel</label>
|
||||
<input type="text" class="form-control" name="hotel" id="hotel" value="{{ $form->hotel }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti 2</label>
|
||||
<input type="file" class="form-control" name="bukti2" value="{{ old('bukti2') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti 3</label>
|
||||
<input type="file" class="form-control" name="bukti3" value="{{ old('bukti3') }}">
|
||||
<label class="form-label">Bukti Hotel</label>
|
||||
<input type="file" class="form-control" name="bukti_hotel" value="{{ old('bukti_hotel') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
||||
<button type="submit" class="btn btn-primary ml-2">Update</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<div class="col-lg-4 col-6">
|
||||
<div class="small-box bg-success">
|
||||
<div class="inner">
|
||||
<h3>Rp {{ number_format($forms->whereIn('status', ['Approved', 'Closed'])->sum('total'), 0, ',', '.') }}</h3>
|
||||
<h3>Rp {{ number_format($forms->whereIn('status', ['Approved', 'Closed'])->sum('approved_total'), 0, ',', '.') }}</h3>
|
||||
<p>Approved Expenses</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
@@ -84,15 +84,14 @@
|
||||
<thead class="bg-light text-capitalize">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>No Expense</th>
|
||||
<th>Nama</th>
|
||||
<th>Tanggal</th>
|
||||
<th>Allowance</th>
|
||||
<th>Transport Ankot</th>
|
||||
<th>Hotel</th>
|
||||
<th>Total</th>
|
||||
<th>Bukti 1</th>
|
||||
<th>Bukti 2</th>
|
||||
<th>Bukti 3</th>
|
||||
<th>Total Approved</th>
|
||||
<th>Account Number</th>
|
||||
<th>Status</th>
|
||||
@if (auth()->user()->can('approval.approve'))
|
||||
@@ -111,39 +110,14 @@
|
||||
@foreach ($forms as $item)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $item->expense_number }}</td>
|
||||
<td>{{ $item->user->name }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($item->created_at)->locale('id')->isoFormat('D MMMM Y') }}</td>
|
||||
<td>{{ number_format($item->allowance, 0, ',', '.') }}</td>
|
||||
<td>{{ number_format($item->transport_ankot, 0, ',', '.') }}</td>
|
||||
<td>{{ number_format($item->hotel, 0, ',', '.') }}</td>
|
||||
<td>{{ number_format($item->total, 0, ',', '.') }}</td>
|
||||
<td>
|
||||
@if ($item->bukti1)
|
||||
<a href="{{ NextCloudHelper::getFileUrl($item->bukti1) }}" target="_blank">
|
||||
Download
|
||||
</a>
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
@if ($item->bukti2)
|
||||
<a href="{{ NextCloudHelper::getFileUrl($item->bukti2) }}" target="_blank">
|
||||
Download
|
||||
</a>
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
@if ($item->bukti3)
|
||||
<a href="{{ NextCloudHelper::getFileUrl($item->bukti3) }}" target="_blank">
|
||||
Download
|
||||
</a>
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ number_format($item->approved_total, 0, ',', '.') }}</td>
|
||||
<td>{{ $item->account_number }}</td>
|
||||
<td>
|
||||
@if ($item->status == 'On Progress')
|
||||
@@ -158,10 +132,10 @@
|
||||
<td>
|
||||
{{-- approve / reject button --}}
|
||||
@if ($item->status == 'On Progress')
|
||||
<form action="{{ route('forms.meeting.approve', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<button type="submit" class="btn btn-success btn-sm">
|
||||
<form action="javascript:void(0);" class="d-inline">
|
||||
<button type="button"
|
||||
class="btn btn-success btn-sm open-approve-modal"
|
||||
data-id="{{ route('forms.meeting.approve', $item->id) }}">
|
||||
Approve
|
||||
</button>
|
||||
</form>
|
||||
@@ -239,20 +213,191 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="modal fade" id="approveModal" tabindex="-1" role="dialog" aria-labelledby="approveModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<form id="approveForm" method="POST" action="">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="approveModalLabel">Approve Item</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Loading spinner -->
|
||||
<div id="loadingSpinner" class="d-flex justify-content-center align-items-center" style="height: 200px;">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal content (hidden initially) -->
|
||||
<div id="modalContent" class="d-none">
|
||||
<p>Please review the details below:</p>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<strong>Expense Number:</strong> <span id="expense_number"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>User:</strong> <span id="user"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tipe:</strong> Meeting & Seminar
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tanggal:</strong> <span id="tanggal"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Bukti Allowance:</strong> <span id="bukti_allowance"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Bukti Transport Antar Kota:</strong> <span id="bukti_transport_ankot"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Bukti Hotel:</strong> <span id="bukti_hotel"></span>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="mt-2">Please select the items you want to approve:</p>
|
||||
<ul class="list-group list-unstyled">
|
||||
<li>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="allowance" name="allowance">
|
||||
<label class="custom-control-label" for="allowance">Allowance (<span id="allowance_value"></span>)</label>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="transport_ankot" name="transport_ankot">
|
||||
<label class="custom-control-label" for="transport_ankot">Transport Ankot (<span id="transport_ankot_value"></span>)</label>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="hotel" name="hotel">
|
||||
<label class="custom-control-label" for="hotel">Hotel (<span id="hotel_value"></span>)</label>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="form-group">
|
||||
<label for="total">Total</label>
|
||||
<input type="text" class="form-control" id="total" name="total" value="0" readonly>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Approve</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
// Uncheck all checkboxes on page refresh
|
||||
$('.custom-control-input').prop('checked', false);
|
||||
|
||||
if ($('#dataTable').length) {
|
||||
$('#dataTable').DataTable({
|
||||
responsive: false,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
'excel', 'pdf', 'print'
|
||||
]
|
||||
buttons: ['excel', 'pdf', 'print']
|
||||
});
|
||||
}
|
||||
|
||||
// Handle Approve Button Click
|
||||
$('.open-approve-modal').on('click', function () {
|
||||
const approveUrl = $(this).data('id');
|
||||
|
||||
// Show spinner and hide content initially
|
||||
$('#loadingSpinner').show();
|
||||
$('#modalContent').addClass('d-none');
|
||||
|
||||
$('#approveForm').attr('action', approveUrl); // Set the form action
|
||||
$('#loadingSpinner').addClass('d-flex');
|
||||
$('#approveModal').modal('show'); // Show the modal
|
||||
|
||||
// Get detail from /forms/up-country/detail/{id}
|
||||
$.get(approveUrl.replace('approve', 'detail'), function (data) {
|
||||
const formatter = new Intl.NumberFormat('id-ID', {
|
||||
style: 'currency',
|
||||
currency: 'IDR',
|
||||
minimumFractionDigits: 0
|
||||
});
|
||||
|
||||
$('#allowance_value').text(formatter.format(data.allowance));
|
||||
$('#transport_ankot_value').text(formatter.format(data.transport_ankot));
|
||||
$('#hotel_value').text(formatter.format(data.hotel));
|
||||
|
||||
// Assign data values to checkboxes
|
||||
$('#allowance').data('value', data.allowance);
|
||||
$('#transport_ankot').data('value', data.transport_ankot);
|
||||
$('#hotel').data('value', data.hotel);
|
||||
|
||||
// Detail data
|
||||
$('#user').text(data.user.name);
|
||||
$('#expense_number').text(data.expense_number);
|
||||
$('#tanggal').text(new Date(data.created_at).toLocaleDateString('id-ID', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
}));
|
||||
|
||||
$('#bukti_allowance').html(data.bukti_allowance ? '<a href="' + data.bukti_allowance + '" target="_blank">Download</a>' : '-');
|
||||
$('#bukti_transport_ankot').html(data.bukti_transport_ankot ? '<a href="' + data.bukti_transport_ankot + '" target="_blank">Download</a>' : '-');
|
||||
$('#bukti_hotel').html(data.bukti_hotel ? '<a href="' + data.bukti_hotel + '" target="_blank">Download</a>' : '-');
|
||||
|
||||
// Hide spinner and show content
|
||||
$('#loadingSpinner').hide();
|
||||
$('#loadingSpinner').removeClass('d-flex');
|
||||
$('#loadingSpinner').addClass('d-none');
|
||||
$('#modalContent').removeClass('d-none');
|
||||
|
||||
// Reset the total to zero
|
||||
$('#total').val(0);
|
||||
});
|
||||
});
|
||||
|
||||
// Update total dynamically
|
||||
$('.custom-control-input').on('change', function () {
|
||||
let total = 0;
|
||||
|
||||
// Calculate the total based on checked checkboxes
|
||||
$('.custom-control-input:checked').each(function () {
|
||||
total += parseFloat($(this).data('value') || 0);
|
||||
});
|
||||
|
||||
// Update the total field with formatted value
|
||||
const formatter = new Intl.NumberFormat('id-ID', {
|
||||
style: 'currency',
|
||||
currency: 'IDR',
|
||||
minimumFractionDigits: 0
|
||||
});
|
||||
|
||||
$('#total').val(formatter.format(total));
|
||||
});
|
||||
|
||||
// Uncheck all checkboxes when the modal is closed
|
||||
$('#approveModal').on('hidden.bs.modal', function () {
|
||||
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
||||
$('#total').val('0'); // Reset total to 0
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
<thead class="bg-light text-capitalize">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>No Expense</th>
|
||||
<th>Nama</th>
|
||||
<th>Rayon</th>
|
||||
<th>Tanggal</th>
|
||||
@@ -109,6 +110,7 @@
|
||||
@foreach ($forms as $item)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $item->expense_number }}</td>
|
||||
<td>{{ $item->user->name }}</td>
|
||||
<td>{{ $item->rayon->code }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('D MMMM Y') }}</td>
|
||||
|
||||
@@ -113,6 +113,7 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
|
||||
|
||||
// Meeting & Seminar
|
||||
Route::get('/meeting-seminar', [FormMeetingSeminarController::class, 'index'])->name('forms.meeting');
|
||||
Route::get('/meeting-seminar/detail/{id}', [FormMeetingSeminarController::class, 'detail'])->name('forms.meeting.detail');
|
||||
Route::get('/meeting-seminar/create', [FormMeetingSeminarController::class, 'create'])->name('forms.meeting.create');
|
||||
Route::post('/meeting-seminar/store', [FormMeetingSeminarController::class, 'store'])->name('forms.meeting.store');
|
||||
Route::get('/meeting-seminar/edit/{id}', [FormMeetingSeminarController::class, 'edit'])->name('forms.meeting.edit');
|
||||
|
||||
Reference in New Issue
Block a user