update Hide Approve dan Persetujuan
This commit is contained in:
@@ -10,6 +10,9 @@ use Illuminate\Routing\Controller;
|
|||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Modules\HospitalPortal\Helpers\ApiResponse;
|
use Modules\HospitalPortal\Helpers\ApiResponse;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use App\Models\CorporateBenefit;
|
||||||
|
use App\Models\MemberPlan;
|
||||||
|
use App\Models\Plan;
|
||||||
|
|
||||||
class MemberController extends Controller
|
class MemberController extends Controller
|
||||||
{
|
{
|
||||||
@@ -134,16 +137,20 @@ class MemberController extends Controller
|
|||||||
|
|
||||||
$res_data['companies'] = $companies;
|
$res_data['companies'] = $companies;
|
||||||
|
|
||||||
$corporateEmployeePremi = DB::table('corporate_employees')
|
$corporateEmployee = DB::table('corporate_employees')
|
||||||
->leftJoin('corporates', 'corporates.id', '=', 'corporate_employees.corporate_id')
|
->leftJoin('corporates', 'corporates.id', '=', 'corporate_employees.corporate_id')
|
||||||
->leftJoin('corporate_policies', 'corporate_policies.corporate_id', '=', 'corporates.id')
|
->leftJoin('corporate_policies', 'corporate_policies.corporate_id', '=', 'corporates.id')
|
||||||
->where('corporate_employees.status', 'ACTIVE')
|
// ->where('corporate_employees.status', 'ACTIVE')
|
||||||
->where('corporates.active', 1)
|
->where('corporates.active', 1)
|
||||||
->where('corporate_policies.active', 1)
|
->where('corporate_policies.active', 1)
|
||||||
->where('corporate_employees.member_id', $members->id)
|
->where('corporate_employees.member_id', $members->id)
|
||||||
->value('corporate_policies.total_premi');
|
->select(
|
||||||
|
'corporate_policies.total_premi',
|
||||||
|
'corporate_employees.corporate_id'
|
||||||
|
)
|
||||||
|
->first();
|
||||||
|
|
||||||
$res_data['total_premi'] = $corporateEmployeePremi ?? 0;
|
$res_data['total_premi'] = $corporateEmployee ?? 0;
|
||||||
|
|
||||||
$limitRules = DB::table('member_plans')
|
$limitRules = DB::table('member_plans')
|
||||||
->leftJoin('plans', 'plans.id', '=', 'member_plans.plan_id')
|
->leftJoin('plans', 'plans.id', '=', 'member_plans.plan_id')
|
||||||
@@ -154,6 +161,50 @@ class MemberController extends Controller
|
|||||||
|
|
||||||
$res_data['limit_rules'] = $limitRules ?? 0;
|
$res_data['limit_rules'] = $limitRules ?? 0;
|
||||||
|
|
||||||
|
$planMember = MemberPlan::where('member_id', $members->id)->get('plan_id');
|
||||||
|
|
||||||
|
$planId = Plan::whereIn('id', $planMember)->where('service_code', 'OP')->first();
|
||||||
|
$benefit = CorporateBenefit::with(['benefit', 'plan'])->where('plan_id', $planId->id)->get()->toArray();
|
||||||
|
$benefitData = [];
|
||||||
|
if (count($benefit)){
|
||||||
|
foreach($benefit as $data){
|
||||||
|
$data['benefit']['plan_id'] = $data['plan_id'];
|
||||||
|
$data['benefit']['limit_amount'] = $data['limit_amount'];
|
||||||
|
$data['benefit']['family_plan'] = $planId->family_plan;
|
||||||
|
$data['benefit']['max_frequency_period'] = $data['max_frequency_period'];
|
||||||
|
$data['benefit']['limit_amount_plan'] = $data['plan']['limit_rules'];
|
||||||
|
$data['benefit']['family_plan_plans'] = $data['plan']['family_plan'];
|
||||||
|
array_push($benefitData, $data['benefit']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$memberUsage = Helper::getUsageMember($corporateEmployee->corporate_id, $members->id, $benefitData);;
|
||||||
|
|
||||||
|
$res_data['used_limit'] = json_decode($memberUsage);
|
||||||
|
|
||||||
|
$usedLimit = json_decode($memberUsage, true); // jadi array
|
||||||
|
|
||||||
|
$totalUsed = 0;
|
||||||
|
|
||||||
|
if (is_array($usedLimit)) {
|
||||||
|
foreach ($usedLimit as $value) {
|
||||||
|
$totalUsed += (int) $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$limitRules = (int) $limitRules;
|
||||||
|
|
||||||
|
// hitung sisa
|
||||||
|
$remainingLimit = $limitRules - $totalUsed;
|
||||||
|
|
||||||
|
// biar gak minus
|
||||||
|
if ($remainingLimit < 0) {
|
||||||
|
$remainingLimit = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set ke response
|
||||||
|
$res_data['remaining_limit'] = $remainingLimit;
|
||||||
|
$res_data['total_used_limit'] = $totalUsed;
|
||||||
|
|
||||||
// specialities
|
// specialities
|
||||||
$specialities = DB::table('specialities')
|
$specialities = DB::table('specialities')
|
||||||
->select(
|
->select(
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ export default function DialogBenefit({requestLog, setOpenDialog, openDialog, cl
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={width}>
|
<Grid item xs={width} style={{display: "none"}}>
|
||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Typography variant="subtitle1" component="div">
|
<Typography variant="subtitle1" component="div">
|
||||||
@@ -440,7 +440,7 @@ export default function DialogBenefit({requestLog, setOpenDialog, openDialog, cl
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={width}>
|
<Grid item xs={width} style={{display: "none"}}>
|
||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Typography variant="subtitle1" component="div">
|
<Typography variant="subtitle1" component="div">
|
||||||
@@ -464,7 +464,7 @@ export default function DialogBenefit({requestLog, setOpenDialog, openDialog, cl
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={width}>
|
<Grid item xs={width} style={{display: "none"}}>
|
||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Typography variant="subtitle1" component="div">
|
<Typography variant="subtitle1" component="div">
|
||||||
@@ -484,7 +484,7 @@ export default function DialogBenefit({requestLog, setOpenDialog, openDialog, cl
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={2}>
|
<Grid item xs={2} style={{display: "none"}}>
|
||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Typography variant="subtitle1" component="div">
|
<Typography variant="subtitle1" component="div">
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ export default function DialogEditBenefit({id, data, setOpenDialog, openDialog,
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={2}>
|
<Grid item xs={2} style={{display: "none"}}>
|
||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Typography variant="subtitle1" component="div">
|
<Typography variant="subtitle1" component="div">
|
||||||
@@ -252,7 +252,7 @@ export default function DialogEditBenefit({id, data, setOpenDialog, openDialog,
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={2}>
|
<Grid item xs={2} style={{display: "none"}}>
|
||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Typography variant="subtitle1" component="div">
|
<Typography variant="subtitle1" component="div">
|
||||||
@@ -276,7 +276,7 @@ export default function DialogEditBenefit({id, data, setOpenDialog, openDialog,
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={2}>
|
<Grid item xs={2} style={{display: "none"}}>
|
||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Typography variant="subtitle1" component="div">
|
<Typography variant="subtitle1" component="div">
|
||||||
@@ -296,7 +296,7 @@ export default function DialogEditBenefit({id, data, setOpenDialog, openDialog,
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid item xs={2}>
|
<Grid item xs={2} style={{display: "none"}}>
|
||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Typography variant="subtitle1" component="div">
|
<Typography variant="subtitle1" component="div">
|
||||||
|
|||||||
@@ -120,6 +120,14 @@ export default function DialogMember(member:any, handleSubmitSuccess:() => void)
|
|||||||
<Typography sx={{width:'50%'}} variant="body2">Limit Peserta</Typography>
|
<Typography sx={{width:'50%'}} variant="body2">Limit Peserta</Typography>
|
||||||
<Typography sx={{width:'50%', fontWeight: 'bold'}} variant="body2">{ member?.limit_rules ? fCurrency(member?.limit_rules) : '-'}</Typography>
|
<Typography sx={{width:'50%', fontWeight: 'bold'}} variant="body2">{ member?.limit_rules ? fCurrency(member?.limit_rules) : '-'}</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
<Stack direction="row" justifyContent="space-between">
|
||||||
|
<Typography sx={{width:'50%'}} variant="body2">Limit Terpakai</Typography>
|
||||||
|
<Typography sx={{width:'50%', fontWeight: 'bold'}} variant="body2">{ member?.total_used_limit ? fCurrency(member?.total_used_limit) : '-'}</Typography>
|
||||||
|
</Stack>
|
||||||
|
<Stack direction="row" justifyContent="space-between">
|
||||||
|
<Typography sx={{width:'50%'}} variant="body2">Sisa Limit</Typography>
|
||||||
|
<Typography sx={{width:'50%', fontWeight: 'bold'}} variant="body2">{ member?.remaining_limit ? fCurrency(member?.remaining_limit) : '-'}</Typography>
|
||||||
|
</Stack>
|
||||||
<Stack direction="row" justifyContent="space-between">
|
<Stack direction="row" justifyContent="space-between">
|
||||||
<Typography sx={{width:'50%'}} variant="body2">NRIC</Typography>
|
<Typography sx={{width:'50%'}} variant="body2">NRIC</Typography>
|
||||||
<Typography sx={{width:'50%', fontWeight: 'bold'}} variant="body2">{member?.members.nik ?? '-'}</Typography>
|
<Typography sx={{width:'50%', fontWeight: 'bold'}} variant="body2">{member?.members.nik ?? '-'}</Typography>
|
||||||
|
|||||||
Reference in New Issue
Block a user