fix employee data export
This commit is contained in:
@@ -27,6 +27,8 @@ use Modules\Internal\Services\MemberEnrollmentService;
|
||||
|
||||
class CorporateMemberController extends Controller
|
||||
{
|
||||
public $memberEnrollmentService;
|
||||
|
||||
public function __construct(public CorporateMemberService $corporateMemberService, MemberEnrollmentService $memberEnrollmentService)
|
||||
{
|
||||
$this->memberEnrollmentService = $memberEnrollmentService;
|
||||
@@ -63,13 +65,13 @@ class CorporateMemberController extends Controller
|
||||
public function show($corporate_id, $person_id)
|
||||
{
|
||||
$data = Member::with(['claims', 'person', 'employeds', 'currentPlan.benefits', 'person.currentAddress'])
|
||||
->where('person_id', $person_id)
|
||||
->whereHas('employeds', function ($query) use ($corporate_id) {
|
||||
$query->where('corporate_id', $corporate_id);
|
||||
})
|
||||
->first();
|
||||
->where('person_id', $person_id)
|
||||
->whereHas('employeds', function ($query) use ($corporate_id) {
|
||||
$query->where('corporate_id', $corporate_id);
|
||||
})
|
||||
->first();
|
||||
|
||||
|
||||
|
||||
$totalClaims = $data->claims->sum('total_claim');
|
||||
$data->total_claims = $totalClaims;
|
||||
|
||||
@@ -107,119 +109,120 @@ class CorporateMemberController extends Controller
|
||||
$data->claim_history = $data_claim_history;
|
||||
|
||||
return response()->json(DataMemberResource::make($data));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function generateMemberList($corporate_id){
|
||||
public function generateMemberList($corporate_id)
|
||||
{
|
||||
// Mendapatkan data yang akan diekspor (misalnya, dari database)
|
||||
$data = Member::with(['currentPlan', 'currentCorporate', 'division', 'employeds', 'currentPolicy'])
|
||||
// ->filter($request->all())
|
||||
// ->where('corporate_id', $corporate_id)
|
||||
->whereHas('employeds', function ($employeds) use ($corporate_id) {
|
||||
$employeds->where('corporate_id', $corporate_id);
|
||||
})->get()->toArray();
|
||||
// Membuat penulis entitas Spout
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$data = Member::with(['currentPlan', 'currentCorporate', 'division', 'employeds', 'currentPolicy'])
|
||||
// ->filter($request->all())
|
||||
// ->where('corporate_id', $corporate_id)
|
||||
->whereHas('employeds', function ($employeds) use ($corporate_id) {
|
||||
$employeds->where('corporate_id', $corporate_id);
|
||||
})->get()->toArray();
|
||||
// Membuat penulis entitas Spout
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
|
||||
// Membuka penulis untuk menulis ke file
|
||||
$writer->openToFile(public_path('files/CorporateMembershipList.xlsx'));
|
||||
// Menulis header kolom
|
||||
$headers_map_to_table_fields = $this->memberEnrollmentService->listing_doc_headers;
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($headers_map_to_table_fields);
|
||||
// Membuka penulis untuk menulis ke file
|
||||
$writer->openToFile(public_path('files/CorporateMembershipList.xlsx'));
|
||||
// Menulis header kolom
|
||||
$headers_map_to_table_fields = $this->memberEnrollmentService->listing_doc_headers;
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($headers_map_to_table_fields);
|
||||
|
||||
$writer->addRow($headerRow);
|
||||
// dd('test');
|
||||
// Menulis data
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $item) {
|
||||
$rowData = [ $item['record_mode'], // Recode Mode
|
||||
$item['record_type'], // Recode Type
|
||||
$item['payor_id'], // Payor ID
|
||||
$item['member_id'], // Member ID
|
||||
$item['principal_id'], // Mapping ID
|
||||
NULL, // Link Medis Member ID
|
||||
$item['current_corporate']['code'] ?? null, // Corporate ID
|
||||
$item['employeds'][0]['nik'] ?? null, // NIK
|
||||
$item['division']['code'] ?? null, // Devision
|
||||
$item['employeds'][0]['branch_code'] ?? null, // Branch Code
|
||||
$item['bank_info'], // Bank Info
|
||||
$item['language'], // Language
|
||||
null, // Type of Work
|
||||
$item['race'], // Race
|
||||
$item['current_policy']['code'] ?? null, // Policy Number
|
||||
$item['marital_status'], // Marital Status
|
||||
$item['relation_with_principal'], // Relationship
|
||||
str_replace('-', '',$item['members_effective_date']), // Member effective date
|
||||
str_replace('-', '',$item['members_expire_date']), // Member expiry date
|
||||
NULL, // Faskes FKTP (First Level Provider) or Individual preferred provider
|
||||
NULL, // Faskes FKRTL (Next Level Provider) or Individual group preferred provider
|
||||
$item['bpjs_class'], // The Right Classes Room of BPJS Participants
|
||||
NULL, // Name of Faskes
|
||||
NULL, // Rule BPJSK
|
||||
NULL, // Internal Use
|
||||
$item['full_name'], // Member Name
|
||||
$item['address1'], // Address1
|
||||
$item['address2'], // Address2
|
||||
$item['address3'], // Address3
|
||||
$item['address4'], // Address4
|
||||
$item['city'], // City
|
||||
NULL, // State
|
||||
$item['postal_code'], // Post Code
|
||||
NULL, // Telephone - Mobile
|
||||
NULL, // Telephone - Res
|
||||
NULL, // Telephone - Office
|
||||
$item['nric'], // NRIC
|
||||
$item['passport_no'], // Passport No
|
||||
$item['passport_country'], // Passport Country
|
||||
$item['email'], // Email
|
||||
$item['identification_code'], // Identification Code
|
||||
$item['birth_date'], // Date of Birth
|
||||
$item['gender_code'], // Sex
|
||||
NULL, // Internal Use
|
||||
$item['current_plan']['code'] ?? null, // Plan-ID
|
||||
NULL, // Employment-Status
|
||||
NULL, // Internal Use
|
||||
NULL, // Internal Use
|
||||
NULL,// Internal Use
|
||||
str_replace('-', '',$item['terminated_date']), // Date Terminated
|
||||
$item['pre_existing'], // Pre Existing
|
||||
$item['bpjs_id'], // BPJS ID
|
||||
$item['endorsement_date'], // Endorsement Date
|
||||
$item['remarks'], // Remarks
|
||||
NULL, // Internal Use
|
||||
NULL,// Member Since
|
||||
NULL,// Internal Use
|
||||
$item['policy_in_force'], // Policy Inforce
|
||||
NULL, // Member Suspended
|
||||
str_replace('-', '',$item['activation_date']), // Activation Date
|
||||
NULL, // Internal Use
|
||||
$item['start_no_claim'], // StartNoClaim
|
||||
$item['end_no_claim'], // EndNoClaim
|
||||
NULL, // Option Mode
|
||||
];
|
||||
$row = WriterEntityFactory::createRowFromArray($rowData);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
}
|
||||
$writer->addRow($headerRow);
|
||||
|
||||
// Menutup penulis
|
||||
$writer->close();
|
||||
// dd('test');
|
||||
// Mengembalikan response untuk mengunduh file
|
||||
$filePath = public_path('files/CorporateMembershipList.xlsx');
|
||||
// dd($filePath);
|
||||
// Mengembalikan response untuk mengunduh file
|
||||
return Helper::responseJson([
|
||||
'file_name' => "Corporate Plan & Benefit List " . date('Y-m-d h:i:s'),
|
||||
"file_url" => url('files/CorporateMembershipList.xlsx')
|
||||
]);
|
||||
}
|
||||
// Menulis data
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $item) {
|
||||
$rowData = [
|
||||
$item['record_mode'], // Recode Mode
|
||||
$item['record_type'], // Recode Type
|
||||
$item['payor_id'], // Payor ID
|
||||
$item['member_id'], // Member ID
|
||||
$item['principal_id'], // Mapping ID
|
||||
NULL, // Link Medis Member ID
|
||||
$item['current_corporate']['code'] ?? null, // Corporate ID
|
||||
$item['employeds'][0]['nik'] ?? null, // NIK
|
||||
$item['division']['code'] ?? null, // Devision
|
||||
$item['employeds'][0]['branch_code'] ?? null, // Branch Code
|
||||
$item['bank_info'], // Bank Info
|
||||
$item['language'], // Language
|
||||
null, // Type of Work
|
||||
$item['race'], // Race
|
||||
$item['current_policy']['code'] ?? null, // Policy Number
|
||||
$item['marital_status'], // Marital Status
|
||||
$item['relation_with_principal'], // Relationship
|
||||
str_replace('-', '', $item['members_effective_date']), // Member effective date
|
||||
str_replace('-', '', $item['members_expire_date']), // Member expiry date
|
||||
NULL, // Faskes FKTP (First Level Provider) or Individual preferred provider
|
||||
NULL, // Faskes FKRTL (Next Level Provider) or Individual group preferred provider
|
||||
$item['bpjs_class'], // The Right Classes Room of BPJS Participants
|
||||
NULL, // Name of Faskes
|
||||
NULL, // Rule BPJSK
|
||||
NULL, // Internal Use
|
||||
$item['full_name'], // Member Name
|
||||
$item['address1'], // Address1
|
||||
$item['address2'], // Address2
|
||||
$item['address3'], // Address3
|
||||
$item['address4'], // Address4
|
||||
$item['city'], // City
|
||||
NULL, // State
|
||||
$item['postal_code'], // Post Code
|
||||
NULL, // Telephone - Mobile
|
||||
NULL, // Telephone - Res
|
||||
NULL, // Telephone - Office
|
||||
$item['nric'], // NRIC
|
||||
$item['passport_no'], // Passport No
|
||||
$item['passport_country'], // Passport Country
|
||||
$item['email'], // Email
|
||||
$item['identification_code'], // Identification Code
|
||||
$item['birth_date'], // Date of Birth
|
||||
$item['gender_code'], // Sex
|
||||
NULL, // Internal Use
|
||||
$item['current_plan']['code'] ?? null, // Plan-ID
|
||||
NULL, // Employment-Status
|
||||
NULL, // Internal Use
|
||||
NULL, // Internal Use
|
||||
NULL, // Internal Use
|
||||
str_replace('-', '', $item['terminated_date']), // Date Terminated
|
||||
$item['pre_existing'], // Pre Existing
|
||||
$item['bpjs_id'], // BPJS ID
|
||||
$item['endorsement_date'], // Endorsement Date
|
||||
$item['remarks'], // Remarks
|
||||
NULL, // Internal Use
|
||||
NULL, // Member Since
|
||||
NULL, // Internal Use
|
||||
$item['policy_in_force'], // Policy Inforce
|
||||
NULL, // Member Suspended
|
||||
str_replace('-', '', $item['activation_date']), // Activation Date
|
||||
NULL, // Internal Use
|
||||
$item['start_no_claim'], // StartNoClaim
|
||||
$item['end_no_claim'], // EndNoClaim
|
||||
NULL, // Option Mode
|
||||
];
|
||||
$row = WriterEntityFactory::createRowFromArray($rowData);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
}
|
||||
|
||||
public function showPerMember($corporate_id, $member_id){
|
||||
// Menutup penulis
|
||||
$writer->close();
|
||||
// dd('test');
|
||||
// Mengembalikan response untuk mengunduh file
|
||||
$filePath = public_path('files/CorporateMembershipList.xlsx');
|
||||
// dd($filePath);
|
||||
// Mengembalikan response untuk mengunduh file
|
||||
return Helper::responseJson([
|
||||
'file_name' => "Corporate Plan & Benefit List " . date('Y-m-d h:i:s'),
|
||||
"file_url" => url('files/CorporateMembershipList.xlsx')
|
||||
]);
|
||||
}
|
||||
|
||||
public function showPerMember($corporate_id, $member_id)
|
||||
{
|
||||
$data = ClaimRequest::where(['member_id' => $member_id])
|
||||
->whereNotNull('claim_id')
|
||||
->paginate(10);
|
||||
->whereNotNull('claim_id')
|
||||
->paginate(10);
|
||||
return response()->json(Helper::paginateResources(DataListClaimMemberResource::collection($data)));
|
||||
}
|
||||
|
||||
@@ -228,7 +231,4 @@ class CorporateMemberController extends Controller
|
||||
$data = Claim::where('id', $claim_id)->first();
|
||||
return Helper::responseJson(DataServiceMonitoring::make($data));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
2254
composer.lock
generated
2254
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -288,11 +288,7 @@ export default function Table<T>({
|
||||
{exportReport && exportReport.useExport ? (
|
||||
<Grid item xs={12} lg={2} xl={2}>
|
||||
<FormControl fullWidth>
|
||||
<Button
|
||||
variant="contained"
|
||||
sx={{ p: 2 }}
|
||||
onClick={() => exportReport.handleExportReport}
|
||||
>
|
||||
<Button variant="contained" sx={{ p: 2 }} onClick={exportReport.handleExportReport}>
|
||||
<Download />
|
||||
<Typography variant="inherit" sx={{ marginLeft: 1 }}>
|
||||
Export
|
||||
|
||||
@@ -280,58 +280,56 @@ export default function Index() {
|
||||
});
|
||||
setDivisionData(corporateDivision.data);
|
||||
setMemberData(
|
||||
corporateMembers.data.data.map((obj: any) => {
|
||||
return {
|
||||
...obj,
|
||||
// limit: (
|
||||
// <Stack>
|
||||
// <BorderLinearProgress
|
||||
// variant="determinate"
|
||||
// value={obj.limit.percentage}
|
||||
// sx={{ mb: 1 }}
|
||||
// />
|
||||
// <Typography sx={{ typography: 'caption', color: '#637381' }}>
|
||||
// {fSplit(obj.limit.current)} / {fSplit(obj.limit.total)}
|
||||
// </Typography>
|
||||
// </Stack>
|
||||
// ),
|
||||
status:
|
||||
obj.status === 1 ? (
|
||||
<Button
|
||||
sx={{
|
||||
backgroundColor: 'rgba(84, 214, 44, 0.16)',
|
||||
color: palette.dark.success.dark,
|
||||
paddingY: 0,
|
||||
'&:hover': {
|
||||
backgroundColor: 'rgba(84, 214, 44, 0.32)',
|
||||
color: palette.dark.success.darker,
|
||||
},
|
||||
}}
|
||||
>
|
||||
Active
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
sx={{
|
||||
backgroundColor: 'rgba(255, 72, 66, 0.16)',
|
||||
color: palette.dark.error.dark,
|
||||
paddingY: 0,
|
||||
'&:hover': {
|
||||
backgroundColor: 'rgba(255, 72, 66, 0.32)',
|
||||
color: palette.dark.error.darker,
|
||||
},
|
||||
}}
|
||||
>
|
||||
Inactive
|
||||
</Button>
|
||||
),
|
||||
/* action: (
|
||||
corporateMembers.data.data.map((obj: any) => ({
|
||||
...obj,
|
||||
// limit: (
|
||||
// <Stack>
|
||||
// <BorderLinearProgress
|
||||
// variant="determinate"
|
||||
// value={obj.limit.percentage}
|
||||
// sx={{ mb: 1 }}
|
||||
// />
|
||||
// <Typography sx={{ typography: 'caption', color: '#637381' }}>
|
||||
// {fSplit(obj.limit.current)} / {fSplit(obj.limit.total)}
|
||||
// </Typography>
|
||||
// </Stack>
|
||||
// ),
|
||||
status:
|
||||
obj.status === 1 ? (
|
||||
<Button
|
||||
sx={{
|
||||
backgroundColor: 'rgba(84, 214, 44, 0.16)',
|
||||
color: palette.dark.success.dark,
|
||||
paddingY: 0,
|
||||
'&:hover': {
|
||||
backgroundColor: 'rgba(84, 214, 44, 0.32)',
|
||||
color: palette.dark.success.darker,
|
||||
},
|
||||
}}
|
||||
>
|
||||
Active
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
sx={{
|
||||
backgroundColor: 'rgba(255, 72, 66, 0.16)',
|
||||
color: palette.dark.error.dark,
|
||||
paddingY: 0,
|
||||
'&:hover': {
|
||||
backgroundColor: 'rgba(255, 72, 66, 0.32)',
|
||||
color: palette.dark.error.darker,
|
||||
},
|
||||
}}
|
||||
>
|
||||
Inactive
|
||||
</Button>
|
||||
),
|
||||
/* action: (
|
||||
<IconButton onClick={handleAction}>
|
||||
<MoreVertIcon />
|
||||
</IconButton>
|
||||
), */
|
||||
};
|
||||
})
|
||||
}))
|
||||
);
|
||||
setPaginationTable(corporateMembers.data);
|
||||
setRowsPerPage(corporateMembers.data.per_page);
|
||||
@@ -351,7 +349,7 @@ export default function Index() {
|
||||
anchorOrigin: { horizontal: 'right', vertical: 'bottom' },
|
||||
});
|
||||
})();
|
||||
}, [appliedParams, searchParams, order, orderBy, setSearchParams, corporateValue]);
|
||||
}, [appliedParams, searchParams, order, orderBy, pathname, setSearchParams, corporateValue]);
|
||||
|
||||
return (
|
||||
<Page title="Dashboard">
|
||||
|
||||
@@ -108,27 +108,23 @@ export default function List() {
|
||||
setSearchText: setSearchText,
|
||||
handleSearchSubmit: handleSearchSubmit,
|
||||
};
|
||||
const [startDateValue, setStartDateValue] = useState('');
|
||||
const [endDateValue, setEndDateValue] = useState('');
|
||||
const [statusValue, setStatusValue] = useState('all');
|
||||
|
||||
const handleExportReport = async (appliedFilter = null) => {
|
||||
axios.get(corporateValue + '/export-members/list').then((response) => {
|
||||
const handleExportReport = async () => {
|
||||
axios.get(corporateValue + '/export-members/list').then((response) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = response.data.data.file_url;
|
||||
link.setAttribute('download', response.data.data.file_name);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
// handleClose();
|
||||
});
|
||||
}
|
||||
};
|
||||
const exportReport = {
|
||||
useExport: true,
|
||||
startDate: startDateValue,
|
||||
endDate: endDateValue,
|
||||
status: statusValue,
|
||||
handleExportReport: handleExportReport
|
||||
}
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
status: 'all',
|
||||
handleExportReport: handleExportReport,
|
||||
};
|
||||
|
||||
/* -------------------------------- headCell -------------------------------- */
|
||||
const headCells: HeadCell<never>[] = [
|
||||
|
||||
Reference in New Issue
Block a user