|
@@ -478,67 +478,103 @@ OFFSET {$offset} LIMIT {$perPage}
|
|
|
public function bills(Request $request, $filter = '')
|
|
|
{
|
|
|
$proID = $this->performer()->pro->id;
|
|
|
- $query = Bill::where('is_cancelled', false)->where('bill_service_type', '<>', 'CARE_MONTH');
|
|
|
+ $isAdmin = $this->performer()->pro->pro_type === 'ADMIN';
|
|
|
+ $query = Bill::where('is_cancelled', false)->where('bill_service_type', 'NOTE');
|
|
|
switch ($filter) {
|
|
|
case 'not-yet-signed':
|
|
|
$query = $query
|
|
|
- ->where(function ($q) use ($proID) {
|
|
|
- $q->where(function ($q2) use ($proID) {
|
|
|
- $q2->where('hcp_pro_id', $proID)->where('is_signed_by_hcp', false);
|
|
|
+ ->where(function ($q) use ($proID, $isAdmin) {
|
|
|
+ $q->where(function ($q2) use ($proID, $isAdmin) {
|
|
|
+ $q2->where('is_signed_by_hcp', false);
|
|
|
+ if(!$isAdmin) {
|
|
|
+ $q2->where('hcp_pro_id', $proID);
|
|
|
+ }
|
|
|
+ })/*
|
|
|
+ ->orWhere(function ($q2) use ($proID, $isAdmin) {
|
|
|
+ $q2->where('is_signed_by_cm', false);
|
|
|
+ if(!$isAdmin) {
|
|
|
+ $q2->where('cm_pro_id', $proID);
|
|
|
+ }
|
|
|
})
|
|
|
- ->orWhere(function ($q2) use ($proID) {
|
|
|
- $q2->where('cm_pro_id', $proID)->where('is_signed_by_cm', false);
|
|
|
- })
|
|
|
- ->orWhere(function ($q2) use ($proID) {
|
|
|
- $q2->where('rme_pro_id', $proID)->where('is_signed_by_rme', false);
|
|
|
- })
|
|
|
- ->orWhere(function ($q2) use ($proID) {
|
|
|
- $q2->where('rmm_pro_id', $proID)->where('is_signed_by_rmm', false);
|
|
|
- })
|
|
|
- ->orWhere(function ($q2) use ($proID) {
|
|
|
- $q2->where('generic_pro_id', $proID)->where('is_signed_by_generic_pro', false);
|
|
|
- });
|
|
|
+ ->orWhere(function ($q2) use ($proID, $isAdmin) {
|
|
|
+ $q2->where('is_signed_by_rme', false);
|
|
|
+ if(!$isAdmin) {
|
|
|
+ $q2->where('rme_pro_id', $proID);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->orWhere(function ($q2) use ($proID, $isAdmin) {
|
|
|
+ $q2->where('is_signed_by_rmm', false);
|
|
|
+ if(!$isAdmin) {
|
|
|
+ $q2->where('rmm_pro_id', $proID);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->orWhere(function ($q2) use ($proID, $isAdmin) {
|
|
|
+ $q2->where('is_signed_by_generic_pro', false);
|
|
|
+ if(!$isAdmin) {
|
|
|
+ $q2->where('generic_pro_id', $proID);
|
|
|
+ }
|
|
|
+ })*/;
|
|
|
});
|
|
|
break;
|
|
|
|
|
|
case 'previous':
|
|
|
$query = $query
|
|
|
- ->where(function ($q) use ($proID) {
|
|
|
- $q->where(function ($q2) use ($proID) {
|
|
|
- $q2->where('hcp_pro_id', $proID)->where('is_signed_by_hcp', true);
|
|
|
- })
|
|
|
- ->orWhere(function ($q2) use ($proID) {
|
|
|
- $q2->where('cm_pro_id', $proID)->where('is_signed_by_cm', true);
|
|
|
+ ->where(function ($q) use ($proID, $isAdmin) {
|
|
|
+ $q->where(function ($q2) use ($proID, $isAdmin) {
|
|
|
+ $q2->where('is_signed_by_hcp', true);
|
|
|
+ if(!$isAdmin) {
|
|
|
+ $q2->where('hcp_pro_id', $proID);
|
|
|
+ }
|
|
|
+ })/*
|
|
|
+ ->orWhere(function ($q2) use ($proID, $isAdmin) {
|
|
|
+ $q2->where('is_signed_by_cm', true);
|
|
|
+ if(!$isAdmin) {
|
|
|
+ $q2->where('cm_pro_id', $proID);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->orWhere(function ($q2) use ($proID, $isAdmin) {
|
|
|
+ $q2->where('is_signed_by_rme', true);
|
|
|
+ if(!$isAdmin) {
|
|
|
+ $q2->where('rme_pro_id', $proID);
|
|
|
+ }
|
|
|
})
|
|
|
- ->orWhere(function ($q2) use ($proID) {
|
|
|
- $q2->where('rme_pro_id', $proID)->where('is_signed_by_rme', true);
|
|
|
+ ->orWhere(function ($q2) use ($proID, $isAdmin) {
|
|
|
+ $q2->where('is_signed_by_rmm', true);
|
|
|
+ if(!$isAdmin) {
|
|
|
+ $q2->where('rmm_pro_id', $proID);
|
|
|
+ }
|
|
|
})
|
|
|
- ->orWhere(function ($q2) use ($proID) {
|
|
|
- $q2->where('rmm_pro_id', $proID)->where('is_signed_by_rmm', true);
|
|
|
- });
|
|
|
+ ->orWhere(function ($q2) use ($proID, $isAdmin) {
|
|
|
+ $q2->where('is_signed_by_generic_pro', true);
|
|
|
+ if(!$isAdmin) {
|
|
|
+ $q2->where('generic_pro_id', $proID);
|
|
|
+ }
|
|
|
+ })*/;
|
|
|
});
|
|
|
break;
|
|
|
|
|
|
// more cases can be added as needed
|
|
|
default:
|
|
|
- $query = $query
|
|
|
- ->where(function ($q) use ($proID) {
|
|
|
- $q->where(function ($q2) use ($proID) {
|
|
|
- $q2->where('hcp_pro_id', $proID);
|
|
|
- })
|
|
|
- ->orWhere(function ($q2) use ($proID) {
|
|
|
- $q2->where('cm_pro_id', $proID);
|
|
|
- })
|
|
|
- ->orWhere(function ($q2) use ($proID) {
|
|
|
- $q2->where('rme_pro_id', $proID);
|
|
|
- })
|
|
|
- ->orWhere(function ($q2) use ($proID) {
|
|
|
- $q2->where('rmm_pro_id', $proID);
|
|
|
- });
|
|
|
- });
|
|
|
+ if(!$isAdmin) {
|
|
|
+ $query = $query
|
|
|
+ ->where(function ($q) use ($proID) {
|
|
|
+ $q->where(function ($q2) use ($proID) {
|
|
|
+ $q2->where('hcp_pro_id', $proID);
|
|
|
+ })/*
|
|
|
+ ->orWhere(function ($q2) use ($proID) {
|
|
|
+ $q2->where('cm_pro_id', $proID);
|
|
|
+ })
|
|
|
+ ->orWhere(function ($q2) use ($proID) {
|
|
|
+ $q2->where('rme_pro_id', $proID);
|
|
|
+ })
|
|
|
+ ->orWhere(function ($q2) use ($proID) {
|
|
|
+ $q2->where('rmm_pro_id', $proID);
|
|
|
+ })*/;
|
|
|
+ });
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
- $bills = $query->orderBy('created_at', 'desc')->get();
|
|
|
+ $bills = $query->orderBy('created_at', 'desc')->paginate(50);
|
|
|
return view('app.practice-management.bills', compact('bills', 'filter'));
|
|
|
}
|
|
|
|