Menambahkan fitur kirim email tender part 1
This commit is contained in:
105
resources/views/penawaran/layouts/scripts.blade.php
Normal file
105
resources/views/penawaran/layouts/scripts.blade.php
Normal file
@@ -0,0 +1,105 @@
|
||||
@push('styles')
|
||||
<style>
|
||||
input.input-custom:focus {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
input.input-custom {
|
||||
background: none;
|
||||
color: var(--tw-gray-600);
|
||||
}
|
||||
}
|
||||
|
||||
.status-custom {
|
||||
display: none
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@push('scripts')
|
||||
<script type="module">
|
||||
const element = document.querySelector('#kjpp-table');
|
||||
const apiUrl = element.getAttribute('data-api-url');
|
||||
const dataTableOptions = {
|
||||
apiEndpoint: apiUrl,
|
||||
pageSize: 5,
|
||||
columns: {
|
||||
no: {
|
||||
title: 'No',
|
||||
render: (item, data) => {
|
||||
return data.numbernya;
|
||||
}
|
||||
},
|
||||
nama_kjpp: {
|
||||
title: 'Nama KJPP',
|
||||
render: (item, data) => {
|
||||
return `${data.kjpp.name}`
|
||||
}
|
||||
},
|
||||
email_kantor: {
|
||||
title: 'Email Kantor',
|
||||
render: (item, data) => {
|
||||
let emails = [data.kjpp.email_kantor]; // Always include the main email
|
||||
|
||||
// Check if there's a detail_email_kantor and try to parse it
|
||||
if (data.kjpp.detail_email_kantor) {
|
||||
try {
|
||||
const detailEmails = JSON.parse(data.kjpp.detail_email_kantor);
|
||||
|
||||
// If the parsed result is an array, extract emails from each object and concatenate
|
||||
if (Array.isArray(detailEmails)) {
|
||||
detailEmails.forEach(item => {
|
||||
if (item.email_kantor) {
|
||||
emails.push(item
|
||||
.email_kantor); // Add the email from each object
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// If it's a single object (not an array), just add the email
|
||||
if (detailEmails.email_kantor) {
|
||||
emails.push(detailEmails.email_kantor);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to parse detail_email_kantor:', e);
|
||||
// Fallback to treating detail_email_kantor as a plain string
|
||||
emails.push(data.kjpp.detail_email_kantor);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function for basic email validation (regex pattern)
|
||||
const isValidEmail = (email) => {
|
||||
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
||||
return emailRegex.test(email);
|
||||
};
|
||||
|
||||
// Filter out invalid emails and join with line breaks
|
||||
return emails
|
||||
.filter(email => email && String(email).trim() && isValidEmail(email))
|
||||
.map(email => String(email)
|
||||
.trim()) // Ensure there are no accidental leading/trailing spaces
|
||||
.join('<br>'); // Join the emails with line breaks for rendering
|
||||
}
|
||||
},
|
||||
status: {
|
||||
title: 'Status',
|
||||
render: (item, data) => {
|
||||
return `${data.emailTenderLog?.status ?? '-'}`
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
title: 'Action',
|
||||
render: (item, data) => {
|
||||
return `<div class="flex justify-center items-center">
|
||||
<a href="tender/penawaran/${data.penawaran.nomor_registrasi}/suratTenderKJPP/${data.kjpp.id}" title="Show Surat Tender" class="btn btn-sm btn-icon btn-clear btn-warning"><i class="ki-outline ki-eye"></i></a>
|
||||
<a href="tender/penawaran/${data.penawaran.nomor_registrasi}/suratTenderKJPP/${data.kjpp.id}/kirimEmailKJPP" title="Kirim Email KJPP" class="btn btn-sm btn-icon btn-clear btn-primary"><i class="ki-outline ki-paper-plane"></i></a></div>`
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user