Merge branch 'staging' of https://dev.sismedika.online/febio/aso into staging
This commit is contained in:
@@ -205,6 +205,7 @@ class RequestLogController extends Controller
|
||||
'members.name as full_name',
|
||||
'members.member_id as no_polis',
|
||||
'members.birth_date',
|
||||
'request_logs.service_code',
|
||||
DB::raw('
|
||||
CASE
|
||||
WHEN request_logs.status = "requested" THEN "requested"
|
||||
|
||||
@@ -38,19 +38,38 @@ export default function TableListFinalLog() {
|
||||
const [data, setData] = useState([]);
|
||||
|
||||
// Download LOG
|
||||
async function handleDownloadLog(request_log_id:any) {
|
||||
async function handleDownloadLog(request_log_id: any, service_code:any, no_polis:any, full_name:any) {
|
||||
return axios
|
||||
.get(`download-final-log/${request_log_id}`, {
|
||||
responseType: 'blob',
|
||||
})
|
||||
.then((response) => {
|
||||
window.open(URL.createObjectURL(response.data), '_blank');
|
||||
console.log(response);
|
||||
// GL Akhir-010124-OP-00001234 Ratih-LinkSehat
|
||||
const namaFile = 'GL Akhir-'+getFormattedToday()+'-'+service_code+'-'+no_polis+'-'+full_name+'-LinkSehat.pdf';
|
||||
const url = URL.createObjectURL(response.data);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', namaFile);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
})
|
||||
.catch((response) => {
|
||||
enqueueSnackbar(response.message, { variant: 'error' });
|
||||
.catch((error) => {
|
||||
enqueueSnackbar(error.message, { variant: 'error' });
|
||||
});
|
||||
}
|
||||
|
||||
function getFormattedToday() {
|
||||
const today = new Date();
|
||||
|
||||
const day = String(today.getDate()).padStart(2, '0');
|
||||
const month = String(today.getMonth() + 1).padStart(2, '0'); // Bulan dimulai dari 0 (Januari = 0)
|
||||
const year = String(today.getFullYear()).substring(2, 4);
|
||||
|
||||
return `${day}${month}${year}`;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* setting up for the table */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -350,7 +369,7 @@ export default function TableListFinalLog() {
|
||||
View
|
||||
</MenuItem>
|
||||
{obj.status === 'approved' ? (
|
||||
<MenuItem onClick={() => handleDownloadLog(obj.id)}>
|
||||
<MenuItem onClick={() => handleDownloadLog(obj.id, obj.service_code, obj.no_polis, obj.full_name)}>
|
||||
<Iconify icon="eva:download-fill" />
|
||||
Download Final LOG
|
||||
</MenuItem>
|
||||
|
||||
@@ -42,19 +42,38 @@ export default function TableList() {
|
||||
const [data, setData] = useState([]);
|
||||
|
||||
// Download LOG
|
||||
async function handleDownloadLog(request_log_id:any) {
|
||||
async function handleDownloadLog(request_log_id: any, service_code:any, no_polis:any, full_name:any) {
|
||||
return axios
|
||||
.get(`download-log/${request_log_id}`, {
|
||||
responseType: 'blob',
|
||||
})
|
||||
.then((response) => {
|
||||
window.open(URL.createObjectURL(response.data), '_blank');
|
||||
console.log(response);
|
||||
// GL Awal-010124-OP-00001234 Ratih-LinkSehat
|
||||
const namaFile = 'GL Awal-'+getFormattedToday()+'-'+service_code+'-'+no_polis+'-'+full_name+'-LinkSehat.pdf';
|
||||
const url = URL.createObjectURL(response.data);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', namaFile);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
})
|
||||
.catch((response) => {
|
||||
enqueueSnackbar(response.message, { variant: 'error' });
|
||||
.catch((error) => {
|
||||
enqueueSnackbar(error.message, { variant: 'error' });
|
||||
});
|
||||
}
|
||||
|
||||
function getFormattedToday() {
|
||||
const today = new Date();
|
||||
|
||||
const day = String(today.getDate()).padStart(2, '0');
|
||||
const month = String(today.getMonth() + 1).padStart(2, '0'); // Bulan dimulai dari 0 (Januari = 0)
|
||||
const year = String(today.getFullYear()).substring(2, 4);
|
||||
|
||||
return `${day}${month}${year}`;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* setting up for the table */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -349,7 +368,7 @@ export default function TableList() {
|
||||
View
|
||||
</MenuItem>
|
||||
{obj.status === 'approved' ? (
|
||||
<MenuItem onClick={() => handleDownloadLog(obj.id)}>
|
||||
<MenuItem onClick={() => handleDownloadLog(obj.id, obj.service_code, obj.no_polis, obj.full_name)}>
|
||||
<Iconify icon="eva:download-fill" />
|
||||
Download LOG
|
||||
</MenuItem>
|
||||
|
||||
Reference in New Issue
Block a user