From 135c0987abe805044d4f4801f155972a01d63a91 Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Thu, 1 Feb 2024 09:07:54 +0700 Subject: [PATCH 1/2] Update tambah field rekanan di hospital --- .../Api/OrganizationController.php | 1 + .../Transformers/OrganizationResource.php | 1 + app/Models/Organization.php | 1 + .../dashboard/src/@types/organization.tsx | 1 + .../src/pages/Master/Hospitals/Form.tsx | 63 ++++++++++++++++++- 5 files changed, 65 insertions(+), 2 deletions(-) diff --git a/Modules/Internal/Http/Controllers/Api/OrganizationController.php b/Modules/Internal/Http/Controllers/Api/OrganizationController.php index 852ee18c..487a8258 100644 --- a/Modules/Internal/Http/Controllers/Api/OrganizationController.php +++ b/Modules/Internal/Http/Controllers/Api/OrganizationController.php @@ -53,6 +53,7 @@ class OrganizationController extends Controller 'type' => 'hospital', 'status' => $request->active == 1 ? 'active' : 'inactive', 'description' => $request->description, + 'corporate_id_partner' => $request->corporate_id_partner ]; $create_organization = Organization::create($organization); diff --git a/Modules/Internal/Transformers/OrganizationResource.php b/Modules/Internal/Transformers/OrganizationResource.php index 283fd9c9..5b045a6f 100644 --- a/Modules/Internal/Transformers/OrganizationResource.php +++ b/Modules/Internal/Transformers/OrganizationResource.php @@ -31,6 +31,7 @@ class OrganizationResource extends JsonResource 'district_id' => $this->currentAddress->district_id ?? null, 'village_id' => $this->currentAddress->village_id ?? null, 'postal_code' => $this->currentAddress->postal_code ?? null, + 'corporate_id_partner' => $this->corporate_id_partner ?? null, 'active' => $this->status == 'active' ? 1 : 0, ]; diff --git a/app/Models/Organization.php b/app/Models/Organization.php index 9b15406d..7a705843 100644 --- a/app/Models/Organization.php +++ b/app/Models/Organization.php @@ -18,6 +18,7 @@ class Organization extends Model 'description', 'part_of', 'main_address_id', + 'corporate_id_partner', ]; // public $with = [ diff --git a/frontend/dashboard/src/@types/organization.tsx b/frontend/dashboard/src/@types/organization.tsx index d5348677..af5175a4 100644 --- a/frontend/dashboard/src/@types/organization.tsx +++ b/frontend/dashboard/src/@types/organization.tsx @@ -21,6 +21,7 @@ export type Organizations = { merchant_key: string; image_url: string; region_groups: string; + corporate_id_partner: string; }; export type Provinces = { diff --git a/frontend/dashboard/src/pages/Master/Hospitals/Form.tsx b/frontend/dashboard/src/pages/Master/Hospitals/Form.tsx index 1574953c..09acecf8 100644 --- a/frontend/dashboard/src/pages/Master/Hospitals/Form.tsx +++ b/frontend/dashboard/src/pages/Master/Hospitals/Form.tsx @@ -127,13 +127,12 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop village_id: currentOrganizations?.village_id || '', postal_code: currentOrganizations?.postal_code || '', description: currentOrganizations?.description || '', + corporate_id_partner: currentOrganizations?.corporate_id_partner || [], }), // eslint-disable-next-line react-hooks/exhaustive-deps [currentOrganizations] ); - console.log('defaultValues', defaultValues); - function StatusLabel({ value }: { value: boolean }) { return ( ([]); const [village, setVillage] = useState([]); + const [corporate_id_partner, setCorporateIdPartner] = useState([]); + const [selectedCorporatID, setSelectedCorporateID] = useState([]); + + const handleSelectChange = (event, selectedOptions:any) => { + const selectedValues = selectedOptions.map(option => option.value); + setSelectedCorporateID(selectedValues); + setValue('corporate_id_partner', selectedCorporatID) + }; + useEffect(() => { axios.get('/province').then((res) => { setProvince(res.data.data.map((item: any) => ({ value: item.id, label: item.name }))); @@ -304,6 +314,27 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop } }, [values.province_id, values.city_id, values.district_id, values.village_id]); + useEffect(() => { + axios.get('/corporates').then((res) => { + setCorporateIdPartner(res.data.data.map((item: any) => ({ value: item.id, label: item.name }))); + }); + + const loadCorporateIdPartner = async () => { + if (values.corporate_id_partner == currentOrganizations?.corporate_id_partner){ + const res = await axios.get('/corporates'); + setCorporateIdPartner(res.data.data.map((item: any) => ({ value: item.id, label: item.name }))); + } + } + + if (values.corporate_id_partner) { + loadCorporateIdPartner(); + } + + console.log(corporate_id_partner, 'test'); + + }, [values.corporate_id_partner]) + + const findValueProvince = province.find( (item: any) => item.value === currentOrganizations?.province_id ); @@ -315,6 +346,10 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop (item: any) => item.value === currentOrganizations?.village_id ); + const findValueCorporate = selectedCorporatID.find( + (item: any) => item.value === currentOrganizations?.corporate_id_partner + ); + return ( @@ -450,6 +485,8 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop )} /> + + Kode Pos @@ -462,6 +499,28 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop Longitude + + + Rekanan + ( + option.label} + value={corporate_id_partner.filter(option => selectedCorporatID.includes(option.value))} + onChange={handleSelectChange} + multiple // Enable multiple selections + renderInput={(params) => ( + + )} + /> + )} + /> + + Deskripsi From 53763674fd91cd5ad5b89173b6a65040424f7da0 Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Thu, 1 Feb 2024 09:42:43 +0700 Subject: [PATCH 2/2] add kolom import system --- .../Http/Controllers/Api/ReportLogController.php | 16 +++++++++++++--- .../Internal/Transformers/ReportLogResource.php | 9 ++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Modules/Internal/Http/Controllers/Api/ReportLogController.php b/Modules/Internal/Http/Controllers/Api/ReportLogController.php index 829c61fe..3c20bc72 100644 --- a/Modules/Internal/Http/Controllers/Api/ReportLogController.php +++ b/Modules/Internal/Http/Controllers/Api/ReportLogController.php @@ -167,7 +167,8 @@ class ReportLogController extends Controller 'Duration GL', 'Duration FGL', 'Status GL', - 'Status Final GL' + 'Status Final GL', + 'Import By Excel' ]; // Sheet 1 $writer->getCurrentSheet()->setName('Data'); @@ -204,7 +205,15 @@ class ReportLogController extends Controller } $durationGl = Helper::differenceTime($formattedDateTime, $row['submission_date']); - + + $approveByFgl = '-'; + if ($row['import_system']) { + $approveByFgl = 'Import By Excel'; + } else if ($row['final_log'] == 1 && $row['status_final_log'] == 'requested'){ + $approveByFgl = '-'; + } else { + $approveByFgl = Helper::userName($row['approved_final_log_by']); + } $rowData = [ $row['code'], // code @@ -214,7 +223,7 @@ class ReportLogController extends Controller Helper::userName($row['approved_by']), // created by $created_final_at ? $created_final_at : "-", // fgl create time $row['approved_final_log_at'] ? $row['approved_final_log_at'] : "", // fgl submit time - $row['final_log'] == 1 ? Helper::userName($row['approved_final_log_by']) : '-', // fgl create by + $approveByFgl, // fgl create by $serviceName, // service $provider ? $provider->name : '-', // provider count($documentQty), // dokument qty @@ -222,6 +231,7 @@ class ReportLogController extends Controller $row['final_log'] == 1 ? $durationFinalGl : '-', // duration fgl $row['status'] ?? '-', // status gl $row['status_final_log'] ?? '-', // status fgl + $row['import_system'] == 1 ? 'True' : 'False', // status fgl ]; $row = WriterEntityFactory::createRowFromArray($rowData); $writer->addRow($row); diff --git a/Modules/Internal/Transformers/ReportLogResource.php b/Modules/Internal/Transformers/ReportLogResource.php index 4b245ae9..e20a7e49 100644 --- a/Modules/Internal/Transformers/ReportLogResource.php +++ b/Modules/Internal/Transformers/ReportLogResource.php @@ -40,7 +40,14 @@ class ReportLogResource extends JsonResource } $durationGl = Helper::differenceTime($formattedDateTime, $this->submission_date); - + $approveByFgl = '-'; + if ($this->import_system) { + $approveByFgl = 'Import By Excel'; + } else if ($this->final_log == 1 && $this->status_final_log == 'requested'){ + $approveByFgl = '-'; + } else { + $approveByFgl = Helper::userName($this->approved_final_log_by); + } $data = [ 'id' => $this->id,