Update
This commit is contained in:
@@ -197,6 +197,29 @@ class ApotekController extends Controller
|
|||||||
'tx_prescription_orders.sDeliveryStatus'
|
'tx_prescription_orders.sDeliveryStatus'
|
||||||
)
|
)
|
||||||
->paginate($limit);
|
->paginate($limit);
|
||||||
|
|
||||||
|
// Secret key for generating the token
|
||||||
|
$secret_key = env('SECRET_KEY_LMS');
|
||||||
|
|
||||||
|
// Transform the results to include the download link
|
||||||
|
$results->getCollection()->transform(function ($item) use ($secret_key) {
|
||||||
|
// Generate the token with the timestamp
|
||||||
|
$expiry_time = time() + 86400; // Token expiry time (1 day)
|
||||||
|
$token = hash_hmac('sha256', $item->id . $expiry_time, $secret_key);
|
||||||
|
|
||||||
|
// Construct the download link
|
||||||
|
$path = 'prescription/barcode-print-pdf/' . $item->id . '?token=' . urlencode($token) . '&expiry=' . $expiry_time;
|
||||||
|
$host = $_SERVER['HTTP_HOST']; // This will give you the host like 'linksehat.dev' or 'linksehat.com'
|
||||||
|
$base_url = "https://m.linksehat.dev/";
|
||||||
|
// Check if the host contains '.dev'
|
||||||
|
if (strpos($host, '.com') !== false) {
|
||||||
|
$base_url = "https://m.linksehat.com/";
|
||||||
|
}
|
||||||
|
$item->link_download = $base_url.$path;
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
|
|
||||||
$apotekIds = $results->pluck(value: 'nIDApotek')->unique()->filter();
|
$apotekIds = $results->pluck(value: 'nIDApotek')->unique()->filter();
|
||||||
$organizations = DB::connection('mysql')->table('organizations')
|
$organizations = DB::connection('mysql')->table('organizations')
|
||||||
->whereIn('id', $apotekIds)
|
->whereIn('id', $apotekIds)
|
||||||
|
|||||||
@@ -37,24 +37,9 @@ export default function TableList() {
|
|||||||
|
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
|
|
||||||
// Download LOG
|
// Download Resep
|
||||||
async function handleDownloadLog(claimRequest:any) {
|
async function handleDownloadPrescription(link_download:any) {
|
||||||
return axios
|
window.open(link_download, '_blank');
|
||||||
.get(`claim-requests/${claimRequest}/log`, {
|
|
||||||
responseType: 'blob',
|
|
||||||
})
|
|
||||||
.then((response) => {
|
|
||||||
window.open(URL.createObjectURL(response.data));
|
|
||||||
// setLoadingLog(false);
|
|
||||||
})
|
|
||||||
// .then((blobFile) => {
|
|
||||||
// new File([blobFile], 'asdads.pdf', { type: blobFile.type })
|
|
||||||
// setLoadingLog(false);
|
|
||||||
// })
|
|
||||||
.catch((response) => {
|
|
||||||
enqueueSnackbar(response.message, { variant: 'error' });
|
|
||||||
// setLoadingLog(false);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
@@ -390,10 +375,10 @@ export default function TableList() {
|
|||||||
<Iconify icon="eva:eye-fill" />
|
<Iconify icon="eva:eye-fill" />
|
||||||
{localeData.txtPrescriptionDetail}
|
{localeData.txtPrescriptionDetail}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{/* <MenuItem onClick={() => handleDownloadLog(obj.id, obj.service_code, obj.no_polis, obj.full_name, obj.provider, obj.approved_at)}>
|
<MenuItem onClick={() => handleDownloadPrescription(obj.link_download)}>
|
||||||
<Iconify icon="eva:download-fill" />
|
<Iconify icon="eva:download-fill" />
|
||||||
{localeData.txtPrescriptionDownload}
|
{localeData.txtPrescriptionDownload}
|
||||||
</MenuItem> */}
|
</MenuItem>
|
||||||
</>
|
</>
|
||||||
} />
|
} />
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user