add claim tab to all users
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user