From 8cb80adf9af84a48bb899fc926348ef330fc42e3 Mon Sep 17 00:00:00 2001 From: mikael-zakaria Date: Tue, 11 Feb 2025 14:48:20 +0700 Subject: [PATCH] Update Copy element Access# dan Reff# pada Dashboard --- app/Views/admin/dashboard.php | 35 +++++++++++++++++++++++++++++++- app/Views/fo/dashboard.php | 35 +++++++++++++++++++++++++++++++- app/Views/sampling/dashboard.php | 35 +++++++++++++++++++++++++++++++- app/Views/user/dashboard.php | 35 +++++++++++++++++++++++++++++++- 4 files changed, 136 insertions(+), 4 deletions(-) diff --git a/app/Views/admin/dashboard.php b/app/Views/admin/dashboard.php index 9bfc6c8..b61089c 100644 --- a/app/Views/admin/dashboard.php +++ b/app/Views/admin/dashboard.php @@ -156,7 +156,7 @@ function index() { stattext = 'Validated'; } let datarow = "" + - "" + colldate + '
'+ colltime +' ' + patnumber + ' ' + patname.trim() + " " + accessnumber + ' ' + hon + ' ' + tests + '' + + "" + colldate + '
'+ colltime +' ' + patnumber + ' ' + patname.trim() + " " + accessnumber + "
" +" " + hon + "
" + tests + '' + ""+stattext+"" + "

" +''; $("#table-body").append(datarow); @@ -218,5 +218,38 @@ function resultPdfAccess(access, event) { let url = 'printResult/'+access; window.open(url, '_blank'); } +function copyToClipboard(element) { + let text = element.innerText.trim(); // Ambil teks dari elemen + text = text.replace("Teks sudah disalin", "").trim(); // Hilangkan teks notifikasi sebelumnya + + if (navigator.clipboard) { + navigator.clipboard.writeText(text).then(() => { + showCopyMessage(element); + }).catch(err => { + console.error("Gagal menyalin teks: ", err); + }); + } else { + // Alternatif jika Clipboard API tidak didukung + let tempInput = document.createElement("textarea"); + tempInput.value = text; + document.body.appendChild(tempInput); + tempInput.select(); + document.execCommand("copy"); + document.body.removeChild(tempInput); + + showCopyMessage(element); + } +} +function showCopyMessage(element) { + let message = element.querySelector(".copy-message"); + if (message) { + message.style.display = "inline"; // Tampilkan teks notifikasi + + // Sembunyikan kembali setelah 2 detik + setTimeout(() => { + message.style.display = "none"; + }, 500); + } +} endSection() ?> \ No newline at end of file diff --git a/app/Views/fo/dashboard.php b/app/Views/fo/dashboard.php index 256bc30..74916b7 100644 --- a/app/Views/fo/dashboard.php +++ b/app/Views/fo/dashboard.php @@ -156,7 +156,7 @@ function index() { stattext = 'Validated'; } let datarow = "" + - "" + colldate + '
'+ colltime +' ' + patnumber + ' ' + patname.trim() + " " + accessnumber + ' ' + hon + ' ' + tests + '' + + "" + colldate + '
'+ colltime +' ' + patnumber + ' ' + patname.trim() + " " + accessnumber + "
" +" " + hon + "
" + tests + '' + ""+stattext+"" + "

" +''; $("#table-body").append(datarow); @@ -218,5 +218,38 @@ function resultPdfAccess(access, event) { let url = 'printResult/'+access; window.open(url, '_blank'); } +function copyToClipboard(element) { + let text = element.innerText.trim(); // Ambil teks dari elemen + text = text.replace("Teks sudah disalin", "").trim(); // Hilangkan teks notifikasi sebelumnya + + if (navigator.clipboard) { + navigator.clipboard.writeText(text).then(() => { + showCopyMessage(element); + }).catch(err => { + console.error("Gagal menyalin teks: ", err); + }); + } else { + // Alternatif jika Clipboard API tidak didukung + let tempInput = document.createElement("textarea"); + tempInput.value = text; + document.body.appendChild(tempInput); + tempInput.select(); + document.execCommand("copy"); + document.body.removeChild(tempInput); + + showCopyMessage(element); + } +} +function showCopyMessage(element) { + let message = element.querySelector(".copy-message"); + if (message) { + message.style.display = "inline"; // Tampilkan teks notifikasi + + // Sembunyikan kembali setelah 2 detik + setTimeout(() => { + message.style.display = "none"; + }, 500); + } +} endSection() ?> \ No newline at end of file diff --git a/app/Views/sampling/dashboard.php b/app/Views/sampling/dashboard.php index f26e616..f374a63 100644 --- a/app/Views/sampling/dashboard.php +++ b/app/Views/sampling/dashboard.php @@ -156,7 +156,7 @@ function index() { stattext = 'Validated'; } let datarow = "" + - "" + colldate + '
'+ colltime +' ' + patnumber + ' ' + patname.trim() + " " + accessnumber + ' ' + hon + ' ' + tests + '' + + "" + colldate + '
'+ colltime +' ' + patnumber + ' ' + patname.trim() + " " + accessnumber + "
" +" " + hon + "
" + tests + '' + ""+stattext+"" + "

" +''; $("#table-body").append(datarow); @@ -218,5 +218,38 @@ function resultPdfAccess(access, event) { let url = 'printResult/'+access; window.open(url, '_blank'); } +function copyToClipboard(element) { + let text = element.innerText.trim(); // Ambil teks dari elemen + text = text.replace("Teks sudah disalin", "").trim(); // Hilangkan teks notifikasi sebelumnya + + if (navigator.clipboard) { + navigator.clipboard.writeText(text).then(() => { + showCopyMessage(element); + }).catch(err => { + console.error("Gagal menyalin teks: ", err); + }); + } else { + // Alternatif jika Clipboard API tidak didukung + let tempInput = document.createElement("textarea"); + tempInput.value = text; + document.body.appendChild(tempInput); + tempInput.select(); + document.execCommand("copy"); + document.body.removeChild(tempInput); + + showCopyMessage(element); + } +} +function showCopyMessage(element) { + let message = element.querySelector(".copy-message"); + if (message) { + message.style.display = "inline"; // Tampilkan teks notifikasi + + // Sembunyikan kembali setelah 2 detik + setTimeout(() => { + message.style.display = "none"; + }, 500); + } +} endSection() ?> \ No newline at end of file diff --git a/app/Views/user/dashboard.php b/app/Views/user/dashboard.php index 2580f51..7478c5b 100644 --- a/app/Views/user/dashboard.php +++ b/app/Views/user/dashboard.php @@ -156,7 +156,7 @@ function index() { stattext = 'Validated'; } let datarow = "" + - "" + colldate + '
'+ colltime +' ' + patnumber + ' ' + patname.trim() + " " + accessnumber + ' ' + hon + ' ' + tests + '' + + "" + colldate + '
'+ colltime +' ' + patnumber + ' ' + patname.trim() + " " + accessnumber + "
" +" " + hon + "
" + tests + '' + ""+stattext+"" + "

" +''; $("#table-body").append(datarow); @@ -218,5 +218,38 @@ function resultPdfAccess(access, event) { let url = 'printResult/'+access; window.open(url, '_blank'); } +function copyToClipboard(element) { + let text = element.innerText.trim(); // Ambil teks dari elemen + text = text.replace("Teks sudah disalin", "").trim(); // Hilangkan teks notifikasi sebelumnya + + if (navigator.clipboard) { + navigator.clipboard.writeText(text).then(() => { + showCopyMessage(element); + }).catch(err => { + console.error("Gagal menyalin teks: ", err); + }); + } else { + // Alternatif jika Clipboard API tidak didukung + let tempInput = document.createElement("textarea"); + tempInput.value = text; + document.body.appendChild(tempInput); + tempInput.select(); + document.execCommand("copy"); + document.body.removeChild(tempInput); + + showCopyMessage(element); + } +} +function showCopyMessage(element) { + let message = element.querySelector(".copy-message"); + if (message) { + message.style.display = "inline"; // Tampilkan teks notifikasi + + // Sembunyikan kembali setelah 2 detik + setTimeout(() => { + message.style.display = "none"; + }, 500); + } +} endSection() ?> \ No newline at end of file