Merge remote-tracking branch 'origin/staging' into origin/production

This commit is contained in:
Linksehat Staging Server
2024-02-01 09:52:37 +07:00
7 changed files with 86 additions and 9 deletions

View File

@@ -53,6 +53,7 @@ class OrganizationController extends Controller
'type' => 'hospital', 'type' => 'hospital',
'status' => $request->active == 1 ? 'active' : 'inactive', 'status' => $request->active == 1 ? 'active' : 'inactive',
'description' => $request->description, 'description' => $request->description,
'corporate_id_partner' => $request->corporate_id_partner
]; ];
$create_organization = Organization::create($organization); $create_organization = Organization::create($organization);

View File

@@ -167,7 +167,8 @@ class ReportLogController extends Controller
'Duration GL', 'Duration GL',
'Duration FGL', 'Duration FGL',
'Status GL', 'Status GL',
'Status Final GL' 'Status Final GL',
'Import By Excel'
]; ];
// Sheet 1 // Sheet 1
$writer->getCurrentSheet()->setName('Data'); $writer->getCurrentSheet()->setName('Data');
@@ -209,6 +210,15 @@ class ReportLogController extends Controller
$durationGl = 0; $durationGl = 0;
} }
$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 = [ $rowData = [
$row['code'], // code $row['code'], // code
@@ -218,7 +228,7 @@ class ReportLogController extends Controller
$row['approved_by'] ? Helper::userName($row['approved_by']) : '-', // created by $row['approved_by'] ? Helper::userName($row['approved_by']) : '-', // created by
$created_final_at ? $created_final_at : "-", // fgl create time $created_final_at ? $created_final_at : "-", // fgl create time
$row['approved_final_log_at'] ? $row['approved_final_log_at'] : "", // fgl submit 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 $serviceName, // service
$provider ? $provider->name : '-', // provider $provider ? $provider->name : '-', // provider
count($documentQty), // dokument qty count($documentQty), // dokument qty
@@ -226,6 +236,7 @@ class ReportLogController extends Controller
$row['final_log'] == 1 ? $durationFinalGl : '-', // duration fgl $row['final_log'] == 1 ? $durationFinalGl : '-', // duration fgl
$row['status'] ?? '-', // status gl $row['status'] ?? '-', // status gl
$row['status_final_log'] ?? '-', // status fgl $row['status_final_log'] ?? '-', // status fgl
$row['import_system'] == 1 ? 'True' : 'False', // status fgl
]; ];
$row = WriterEntityFactory::createRowFromArray($rowData); $row = WriterEntityFactory::createRowFromArray($rowData);
$writer->addRow($row); $writer->addRow($row);

View File

@@ -31,6 +31,7 @@ class OrganizationResource extends JsonResource
'district_id' => $this->currentAddress->district_id ?? null, 'district_id' => $this->currentAddress->district_id ?? null,
'village_id' => $this->currentAddress->village_id ?? null, 'village_id' => $this->currentAddress->village_id ?? null,
'postal_code' => $this->currentAddress->postal_code ?? null, 'postal_code' => $this->currentAddress->postal_code ?? null,
'corporate_id_partner' => $this->corporate_id_partner ?? null,
'active' => $this->status == 'active' ? 1 : 0, 'active' => $this->status == 'active' ? 1 : 0,
]; ];

View File

@@ -40,13 +40,16 @@ class ReportLogResource extends JsonResource
$created_final_at = null; $created_final_at = null;
} }
if ($this->approved_at){ $durationGl = Helper::differenceTime($formattedDateTime, $this->submission_date);
$durationGl = Helper::differenceTime($formattedDateTime, $this->approved_at); $approveByFgl = '-';
if ($this->import_system) {
$approveByFgl = 'Import By Excel';
} else if ($this->final_log == 1 && $this->status_final_log == 'requested'){
$approveByFgl = '-';
} else { } else {
$durationGl = 0; $approveByFgl = Helper::userName($this->approved_final_log_by);
} }
$data = [ $data = [
'id' => $this->id, 'id' => $this->id,
'code' => $this->code, 'code' => $this->code,
@@ -55,7 +58,7 @@ class ReportLogResource extends JsonResource
'submission_date' => $this->approved_at ? $this->approved_at : null, 'submission_date' => $this->approved_at ? $this->approved_at : null,
'approved_by' => Helper::userName($this->approved_by), 'approved_by' => Helper::userName($this->approved_by),
'approved_final_log_at' => $this->approved_final_log_at, 'approved_final_log_at' => $this->approved_final_log_at,
'approved_final_log_by' => $this->final_log == 1 ? Helper::userName($this->approved_final_log_by) : '-', 'approved_final_log_by' => $approveByFgl,
'service_name' => $this->service ? $this->service->name : '', 'service_name' => $this->service ? $this->service->name : '',
'provider' => $provider ? $provider->name : '-', 'provider' => $provider ? $provider->name : '-',
'document_qty' => count($documentQty), 'document_qty' => count($documentQty),

View File

@@ -18,6 +18,7 @@ class Organization extends Model
'description', 'description',
'part_of', 'part_of',
'main_address_id', 'main_address_id',
'corporate_id_partner',
]; ];
// public $with = [ // public $with = [

View File

@@ -21,6 +21,7 @@ export type Organizations = {
merchant_key: string; merchant_key: string;
image_url: string; image_url: string;
region_groups: string; region_groups: string;
corporate_id_partner: string;
}; };
export type Provinces = { export type Provinces = {

View File

@@ -127,13 +127,12 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
village_id: currentOrganizations?.village_id || '', village_id: currentOrganizations?.village_id || '',
postal_code: currentOrganizations?.postal_code || '', postal_code: currentOrganizations?.postal_code || '',
description: currentOrganizations?.description || '', description: currentOrganizations?.description || '',
corporate_id_partner: currentOrganizations?.corporate_id_partner || [],
}), }),
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
[currentOrganizations] [currentOrganizations]
); );
console.log('defaultValues', defaultValues);
function StatusLabel({ value }: { value: boolean }) { function StatusLabel({ value }: { value: boolean }) {
return ( return (
<Chip <Chip
@@ -217,6 +216,8 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
formData.append('postal_code', data.postal_code); formData.append('postal_code', data.postal_code);
formData.append('description', data.description); formData.append('description', data.description);
formData.append('corporate_id_partner', data.corporate_id_partner);
if (!isEdit) { if (!isEdit) {
console.log('formData', formData); console.log('formData', formData);
const response = await axios.post('/organizations', formData); const response = await axios.post('/organizations', formData);
@@ -256,6 +257,15 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
const [district, setDistrict] = useState<any>([]); const [district, setDistrict] = useState<any>([]);
const [village, setVillage] = useState<any>([]); const [village, setVillage] = useState<any>([]);
const [corporate_id_partner, setCorporateIdPartner] = useState<any>([]);
const [selectedCorporatID, setSelectedCorporateID] = useState<any>([]);
const handleSelectChange = (event, selectedOptions:any) => {
const selectedValues = selectedOptions.map(option => option.value);
setSelectedCorporateID(selectedValues);
setValue('corporate_id_partner', selectedCorporatID)
};
useEffect(() => { useEffect(() => {
axios.get('/province').then((res) => { axios.get('/province').then((res) => {
setProvince(res.data.data.map((item: any) => ({ value: item.id, label: item.name }))); 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]); }, [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( const findValueProvince = province.find(
(item: any) => item.value === currentOrganizations?.province_id (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 (item: any) => item.value === currentOrganizations?.village_id
); );
const findValueCorporate = selectedCorporatID.find(
(item: any) => item.value === currentOrganizations?.corporate_id_partner
);
return ( return (
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}> <FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
<Stack spacing={3}> <Stack spacing={3}>
@@ -450,6 +485,8 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
)} )}
/> />
</Grid> </Grid>
<Grid item xs={12} md={4}> <Grid item xs={12} md={4}>
<LabelStyle>Kode Pos</LabelStyle> <LabelStyle>Kode Pos</LabelStyle>
<RHFTextField name="postal_code" placeholder="Tuliskan Kode Pos" /> <RHFTextField name="postal_code" placeholder="Tuliskan Kode Pos" />
@@ -462,6 +499,28 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
<LabelStyle>Longitude</LabelStyle> <LabelStyle>Longitude</LabelStyle>
<RHFTextField name="lng" placeholder="Tuliskan Longitude" /> <RHFTextField name="lng" placeholder="Tuliskan Longitude" />
</Grid> </Grid>
<Grid item xs={12}>
<LabelStyle>Rekanan</LabelStyle>
<Controller
name="corporate_id_partner"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
id="combo-box-demo"
options={corporate_id_partner}
getOptionLabel={(option) => option.label}
value={corporate_id_partner.filter(option => selectedCorporatID.includes(option.value))}
onChange={handleSelectChange}
multiple // Enable multiple selections
renderInput={(params) => (
<TextField {...params} label="Corporate" variant="outlined" fullWidth />
)}
/>
)}
/>
</Grid>
<Grid item xs={12}> <Grid item xs={12}>
<LabelStyle>Deskripsi</LabelStyle> <LabelStyle>Deskripsi</LabelStyle>
<RHFEditor name="description" placeholder="Tuliskan Deskripsi" /> <RHFEditor name="description" placeholder="Tuliskan Deskripsi" />