add claim tab to all users

This commit is contained in:
2025-09-19 21:04:43 +07:00
parent db4c586535
commit 45f79e7027
7 changed files with 12686 additions and 104 deletions

View File

@@ -1085,15 +1085,6 @@ class TransactionController extends Controller
*/
public function getClaimTransactions(Request $request)
{
// Only allow mechanics to access this endpoint
if (Auth::user()->role_id != 3) {
return response()->json([
'draw' => intval($request->input('draw')),
'recordsTotal' => 0,
'recordsFiltered' => 0,
'data' => []
]);
}
$request->validate([
'dealer_id' => 'required|exists:dealers,id'
@@ -1290,25 +1281,21 @@ class TransactionController extends Controller
<i class="fas fa-trash"></i> Hapus
</button>';
// Only show claim buttons for mechanics
if (Auth::user()->role_id == 3) {
// Claim button - show only if not claimed yet
if (empty($transaction->claimed_at) && empty($transaction->claimed_by)) {
$buttons .= '<button class="btn btn-sm btn-success mr-1" onclick="claimTransaction(' . $transaction->id . ')" title="Klaim Pekerjaan" style="font-size: 11px; padding: 4px 8px;">';
$buttons .= '<i class="fas fa-hand-paper"></i> Klaim';
$buttons .= '</button>';
} else {
if ($transaction->claimed_by == Auth::user()->id) {
$precheck = Precheck::where('transaction_id', $transaction->id)->first();
$postcheck = Postcheck::where('transaction_id', $transaction->id)->first();
// Claim button - show only if not claimed yet
if (empty($transaction->claimed_at) && empty($transaction->claimed_by)) {
$buttons .= '<button class="btn btn-sm btn-success mr-1" onclick="claimTransaction(' . $transaction->id . ')" title="Klaim Pekerjaan" style="font-size: 11px; padding: 4px 8px;">';
$buttons .= '<i class="fas fa-hand-paper"></i> Klaim';
$buttons .= '</button>';
} else {
if ($transaction->claimed_by == Auth::user()->id) {
$precheck = Precheck::where('transaction_id', $transaction->id)->first();
$postcheck = Postcheck::where('transaction_id', $transaction->id)->first();
if ($precheck && $postcheck) {
$buttons .= '<span class="badge badge-success" style="font-size: 10px;"><i class="fas fa-check"></i> Selesai</span>';
}
if ($precheck && $postcheck) {
$buttons .= '<span class="badge badge-success" style="font-size: 10px;"><i class="fas fa-check"></i> Selesai</span>';
}
$buttons .= '<span class="badge badge-info" style="font-size: 10px;"><i class="fas fa-check-circle"></i> Sudah Diklaim</span>';
}
$buttons .= '<span class="badge badge-info" style="font-size: 10px;"><i class="fas fa-check-circle"></i> Sudah Diklaim</span>';
}
return $buttons;
@@ -1318,27 +1305,25 @@ class TransactionController extends Controller
{
$buttons = '';
if (Auth::user()->role_id == 3) {
$precheck = Precheck::where('transaction_id', $transaction->id)->first();
$precheck = Precheck::where('transaction_id', $transaction->id)->first();
if ($precheck) {
$buttons .= '<a href="' . route('prechecks.edit', [$transaction->id, $precheck->id]) . '"
class="btn btn-sm btn-warning mr-1" title="Edit Precheck" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-edit"></i> Edit
if ($precheck) {
$buttons .= '<a href="' . route('prechecks.edit', [$transaction->id, $precheck->id]) . '"
class="btn btn-sm btn-warning mr-1" title="Edit Precheck" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-edit"></i> Edit
</a>';
$buttons .= '<a href="' . route('prechecks.print', $transaction->id) . '"
class="btn btn-sm btn-primary mr-1" title="Lihat Precheck" target="_blank" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-eye"></i> Lihat
</a>';
} else {
if (empty($transaction->claimed_at) && empty($transaction->claimed_by)) {
$buttons .= '<span class="badge badge-danger" style="font-size: 10px;">Transaksi Belum Diklaim</span>';
}else{
$buttons .= '<a href="' . route('prechecks.create', $transaction->id) . '"
class="btn btn-sm btn-success mr-1" title="Tambah Precheck" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-plus"></i> Tambah
</a>';
$buttons .= '<a href="' . route('prechecks.print', $transaction->id) . '"
class="btn btn-sm btn-primary mr-1" title="Lihat Precheck" target="_blank" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-eye"></i> Lihat
</a>';
} else {
if (empty($transaction->claimed_at) && empty($transaction->claimed_by)) {
$buttons .= '<span class="badge badge-danger" style="font-size: 10px;">Transaksi Belum Diklaim</span>';
}else{
$buttons .= '<a href="' . route('prechecks.create', $transaction->id) . '"
class="btn btn-sm btn-success mr-1" title="Tambah Precheck" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-plus"></i> Tambah
</a>';
}
}
}
@@ -1348,30 +1333,27 @@ class TransactionController extends Controller
private function getActionButtonsPostcheck($transaction)
{
$buttons = '';
$postcheck = Postcheck::where('transaction_id', $transaction->id)->first();
$precheck = Precheck::where('transaction_id', $transaction->id)->first();
if (Auth::user()->role_id == 3) {
$postcheck = Postcheck::where('transaction_id', $transaction->id)->first();
$precheck = Precheck::where('transaction_id', $transaction->id)->first();
if($precheck){
if ($postcheck) {
$buttons .= '<a href="' . route('postchecks.edit', [$transaction->id, $postcheck->id]) . '"
class="btn btn-sm btn-warning mr-1" title="Edit Postcheck" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-edit"></i> Edit
</a>';
$buttons .= '<a href="' . route('postchecks.print', $transaction->id) . '"
class="btn btn-sm btn-primary mr-1" title="Lihat Postcheck" target="_blank" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-eye"></i> Lihat
</a>';
} else {
$buttons .= '<a href="' . route('postchecks.create', $transaction->id) . '"
class="btn btn-sm btn-success mr-1" title="Tambah Postcheck" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-plus"></i> Tambah
</a>';
}
}else{
$buttons .= '<span class="badge badge-danger" style="font-size: 10px;">Precheck Belum Disimpan</span>';
if($precheck){
if ($postcheck) {
$buttons .= '<a href="' . route('postchecks.edit', [$transaction->id, $postcheck->id]) . '"
class="btn btn-sm btn-warning mr-1" title="Edit Postcheck" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-edit"></i> Edit
</a>';
$buttons .= '<a href="' . route('postchecks.print', $transaction->id) . '"
class="btn btn-sm btn-primary mr-1" title="Lihat Postcheck" target="_blank" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-eye"></i> Lihat
</a>';
} else {
$buttons .= '<a href="' . route('postchecks.create', $transaction->id) . '"
class="btn btn-sm btn-success mr-1" title="Tambah Postcheck" style="font-size: 11px; padding: 4px 8px;">
<i class="fas fa-plus"></i> Tambah
</a>';
}
}else{
$buttons .= '<span class="badge badge-danger" style="font-size: 10px;">Precheck Belum Disimpan</span>';
}
return $buttons;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -820,11 +820,9 @@ use Illuminate\Support\Facades\Auth;
<li class="nav-item">
<a class="nav-link @if(old('form') == 'wash') active @endif" href="#form-cuci">Form Cuci</a>
</li>
@if(Auth::user()->role_id == 3)
<li class="nav-item">
<a class="nav-link @if(old('form') == 'claim') active @endif" href="#form-claim">Klaim</a>
</li>
@endif
</ul>
<div class="tab-content mt-3">
@@ -1128,7 +1126,6 @@ use Illuminate\Support\Facades\Auth;
</div>
<!-- Form Klaim - Hanya untuk Mekanik -->
@if(Auth::user()->role_id == 3)
<div class="tab-pane @if(old('form') == 'claim') active @endif" id="form-claim" role="tabpanel">
<div class="mt-3">
<h6 class="mb-3">Daftar Pekerjaan yang Dapat Diklaim</h6>
@@ -1154,7 +1151,6 @@ use Illuminate\Support\Facades\Auth;
</div>
</div>
</div>
@endif
</div>
</div>
</div>

View File

@@ -112,7 +112,7 @@
<b class="font-weight-bold text-dark">x{{ $transaction->qty }}</b>
</div>
</div>
<div class="kt-portlet__foot text-right mt-4" style="background: none !important; padding-right: 0 !important; padding-left: 0 !important; padding-bottom: 0; margin-bottom: 0;">
{{-- <div class="kt-portlet__foot text-right mt-4" style="background: none !important; padding-right: 0 !important; padding-left: 0 !important; padding-bottom: 0; margin-bottom: 0;">
@if ($transaction->status == 1)
<span class="badge badge-success">Closed</span>
@else
@@ -128,7 +128,7 @@
@method('DELETE')
</form>
@endif
</div>
</div> --}}
</div>
</div>
</div>

View File

@@ -171,35 +171,35 @@ Route::group(['middleware' => 'auth'], function() {
// Stock Management Routes
Route::post('/transaction/check-stock', [TransactionController::class, 'checkStockAvailability'])->name('transaction.check-stock');
Route::get('/transaction/stock-prediction', [TransactionController::class, 'getStockPrediction'])->name('transaction.stock-prediction');
// Claim Transactions Route
Route::get('/transaction/get-claim-transactions', [TransactionController::class, 'getClaimTransactions'])->name('transaction.get-claim-transactions');
Route::post('/transaction/claim/{id}', [TransactionController::class, 'claim'])->name('transaction.claim');
Route::prefix('transaction/{transaction}')->group(function () {
// Prechecks
Route::prefix('prechecks')->name('prechecks.')->group(function () {
Route::get('create', [PrechecksController::class, 'create'])->name('create');
Route::post('store', [PrechecksController::class, 'store'])->name('store');
Route::get('{precheck}/edit', [PrechecksController::class, 'edit'])->name('edit');
Route::put('{precheck}', [PrechecksController::class, 'update'])->name('update');
Route::get('print', [PrechecksController::class, 'print'])->name('print');
});
// Postchecks
Route::prefix('postchecks')->name('postchecks.')->group(function () {
Route::get('create', [PostchecksController::class, 'create'])->name('create');
Route::post('store', [PostchecksController::class, 'store'])->name('store');
Route::get('{postcheck}/edit', [PostchecksController::class, 'edit'])->name('edit');
Route::put('{postcheck}', [PostchecksController::class, 'update'])->name('update');
Route::get('print', [PostchecksController::class, 'print'])->name('print');
});
});
});
// KPI Data Route - accessible to all authenticated users
Route::get('/transaction/get-kpi-data', [TransactionController::class, 'getKpiData'])->name('transaction.get-kpi-data');
// Claim Transactions Route
Route::get('/transaction/get-claim-transactions', [TransactionController::class, 'getClaimTransactions'])->name('transaction.get-claim-transactions');
Route::post('/transaction/claim/{id}', [TransactionController::class, 'claim'])->name('transaction.claim');
Route::prefix('transaction/{transaction}')->group(function () {
// Prechecks
Route::prefix('prechecks')->name('prechecks.')->group(function () {
Route::get('create', [PrechecksController::class, 'create'])->name('create');
Route::post('store', [PrechecksController::class, 'store'])->name('store');
Route::get('{precheck}/edit', [PrechecksController::class, 'edit'])->name('edit');
Route::put('{precheck}', [PrechecksController::class, 'update'])->name('update');
Route::get('print', [PrechecksController::class, 'print'])->name('print');
});
// Postchecks
Route::prefix('postchecks')->name('postchecks.')->group(function () {
Route::get('create', [PostchecksController::class, 'create'])->name('create');
Route::post('store', [PostchecksController::class, 'store'])->name('store');
Route::get('{postcheck}/edit', [PostchecksController::class, 'edit'])->name('edit');
Route::put('{postcheck}', [PostchecksController::class, 'update'])->name('update');
Route::get('print', [PostchecksController::class, 'print'])->name('print');
});
});
Route::group(['prefix' => 'admin', 'middleware' => 'adminRole'], function() {
Route::get('/dashboard2', [AdminController::class, 'dashboard2'])->name('dashboard2');
Route::post('/dealer_work_trx', [AdminController::class, 'dealer_work_trx'])->name('dealer_work_trx');