Update Export Members dan Hide client portal

This commit is contained in:
ivan-sim
2024-01-03 16:57:22 +07:00
parent a157c41462
commit b5afefd71d
4 changed files with 156 additions and 21 deletions

View File

@@ -21,10 +21,15 @@ use Modules\Client\Transformers\Dashboard\MemberEmployeeDataResources as Dashboa
use Modules\Client\Transformers\DataMemberResource;
use Illuminate\Support\Facades\DB;
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
use Modules\Internal\Services\MemberEnrollmentService;
class CorporateMemberController extends Controller
{
public function __construct(public CorporateMemberService $corporateMemberService)
public function __construct(public CorporateMemberService $corporateMemberService, MemberEnrollmentService $memberEnrollmentService)
{
$this->memberEnrollmentService = $memberEnrollmentService;
}
/**
@@ -106,6 +111,111 @@ class CorporateMemberController extends Controller
}
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();
// 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);
}
}
// 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')

View File

@@ -48,6 +48,7 @@ Route::prefix('client')->group(function () {
Route::get('division', [CorporateDivisionController::class, 'index']);
Route::get('members', [CorporateMemberController::class, 'index']);
Route::get('members/{id}', [CorporateMemberController::class, 'show']);
Route::get('export-members/list', [CorporateMemberController::class, 'generateMemberList']);
Route::get('alarm-center-members/{id}', [CorporateMemberController::class, 'showPerMember']);
Route::get('service-monitoring/{id}', [CorporateMemberController::class, 'serviceMonitoring']);
Route::get('claims/status', [ClaimController::class, 'status']);

View File

@@ -235,12 +235,12 @@ export default function Index() {
label: 'Divisi',
isSort: true,
},
{
id: 'limit',
align: 'center',
label: 'Limit',
isSort: false,
},
// {
// id: 'limit',
// align: 'center',
// label: 'Limit',
// isSort: false,
// },
{
id: 'status',
align: 'center',
@@ -292,18 +292,18 @@ export default function Index() {
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>
),
// 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
@@ -369,12 +369,12 @@ export default function Index() {
</Stack>
<Grid container spacing={2}>
<Grid item xs={12} lg={6} md={12}>
{/* <Grid item xs={12} lg={6} md={12}>
<CardNotification data={itemList} />
</Grid>
<Grid item xs={12} lg={6} md={12}>
<CardPolicy data={policyData} />
</Grid>
</Grid> */}
<Grid item xs={12} lg={12} md={12}>
<Table
headCells={headCells}

View File

@@ -40,6 +40,7 @@ import TableMoreMenu from '../../components/table/TableMoreMenu';
import EditOutlinedIcon from '@mui/icons-material/EditOutlined';
import VisibilityOutlinedIcon from '@mui/icons-material/VisibilityOutlined';
import Label from '../../components/Label';
import { enqueueSnackbar } from 'notistack';
/* ---------------------------------- types --------------------------------- */
@@ -229,10 +230,32 @@ export default function List() {
};
const searchs = {
useSearchs: true,
searchText: searchText,
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 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
}
/* -------------------------------- headCell -------------------------------- */
const headCells: HeadCell<never>[] = [
@@ -375,6 +398,7 @@ export default function List() {
params={params}
searchs={searchs}
// filters={filters}
exportReport={exportReport}
/>
</Stack>
);