Update Export Members dan Hide client portal
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user