- Menambahkan tampilan detail untuk email blast yang mencakup subjek, konten, jumlah penerima, status, dan tanggal dibuat. - Menambahkan halaman indeks untuk menampilkan daftar email blast dengan kemampuan pencarian dan pagination. - Mengimplementasikan tabel yang dapat diatur dengan opsi untuk memilih dan menampilkan data email blast.
161 lines
7.2 KiB
PHP
161 lines
7.2 KiB
PHP
@extends('layouts.main')
|
|
|
|
@section('breadcrumbs')
|
|
{{ Breadcrumbs::render('emailblast.create') }}
|
|
@endsection
|
|
|
|
@section('content')
|
|
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
|
<form method="POST" action="{{ route('emailblast.store') }}">
|
|
@csrf
|
|
<div class="card pb-2.5">
|
|
<div class="card-header" id="basic_settings">
|
|
<h3 class="card-title">
|
|
Create Email Blast
|
|
</h3>
|
|
<div class="flex items-center gap-2">
|
|
<a href="{{ route('emailblast.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
|
|
</div>
|
|
</div>
|
|
<div class="card-body grid gap-5">
|
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
|
<label class="form-label max-w-56">
|
|
Subject
|
|
</label>
|
|
<div class="flex flex-wrap items-baseline w-full">
|
|
<input class="input @error('subject') border-danger bg-danger-light @enderror" type="text" name="subject" value="{{ old('subject') }}">
|
|
@error('subject')
|
|
<em class="alert text-danger text-sm">{{ $message }}</em>
|
|
@enderror
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
|
<label class="form-label max-w-56">
|
|
Recipients Type
|
|
</label>
|
|
<div class="flex flex-wrap items-baseline w-full">
|
|
<select id="recipients-type" class="input @error('recipients_type') border-danger bg-danger-light @enderror" name="recipients_type">
|
|
<option value="all">All Customers</option>
|
|
<option value="custom">Custom Recipients</option>
|
|
</select>
|
|
@error('recipients_type')
|
|
<em class="alert text-danger text-sm">{{ $message }}</em>
|
|
@enderror
|
|
</div>
|
|
</div>
|
|
<div id="custom-recipients-container" class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="display: none;">
|
|
<label class="form-label max-w-56">
|
|
Custom Recipients
|
|
</label>
|
|
<div class="flex flex-wrap items-baseline w-full">
|
|
<select id="recipients-select" class="input @error('recipients') border-danger bg-danger-light @enderror" name="recipients[]" multiple>
|
|
</select>
|
|
@error('recipients')
|
|
<em class="alert text-danger text-sm">{{ $message }}</em>
|
|
@enderror
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
|
<label class="form-label max-w-56">
|
|
Content
|
|
</label>
|
|
<div class="flex flex-wrap items-baseline w-full">
|
|
<!-- Output -->
|
|
<textarea id="example" name="content"></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex justify-end">
|
|
<button type="submit" class="btn btn-primary">
|
|
Send Email
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
@endsection
|
|
@push('scripts')
|
|
<link href='https://cdn.jsdelivr.net/npm/froala-editor@latest/css/froala_editor.pkgd.min.css' rel='stylesheet' type='text/css' />
|
|
<script type='text/javascript' src='https://cdn.jsdelivr.net/npm/froala-editor@latest/js/froala_editor.pkgd.min.js'></script>
|
|
|
|
<script>
|
|
var editor = new FroalaEditor('#example',{
|
|
// Aktifkan penyimpanan gambar sebagai base64
|
|
iframe:true,
|
|
fullPage: true,
|
|
htmlExecuteScript: true,
|
|
imagePaste: true, // Aktifkan paste gambar
|
|
imageAllowedTypes: ['jpeg', 'jpg', 'png'], // Batasi tipe gambar
|
|
events: {
|
|
'image.beforeUpload': function (files) {
|
|
if (files.length) {
|
|
var reader = new FileReader();
|
|
reader.onload = function (e) {
|
|
var base64Image = e.target.result;
|
|
editor.image.insert(base64Image, null, null, editor.image.get());
|
|
};
|
|
reader.readAsDataURL(files[0]);
|
|
}
|
|
return false; // Mencegah upload ke server
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const recipientsTypeSelect = document.getElementById('recipients-type');
|
|
const customRecipientsContainer = document.getElementById('custom-recipients-container');
|
|
|
|
let tomSelect = null;
|
|
|
|
recipientsTypeSelect.addEventListener('change', function () {
|
|
if (this.value === 'custom') {
|
|
customRecipientsContainer.style.display = 'flex';
|
|
initializeTomSelect();
|
|
} else {
|
|
customRecipientsContainer.style.display = 'none';
|
|
if (tomSelect) {
|
|
tomSelect.destroy();
|
|
tomSelect = null;
|
|
}
|
|
}
|
|
});
|
|
|
|
function initializeTomSelect() {
|
|
if (!tomSelect) {
|
|
tomSelect = new TomSelect('#recipients-select', {
|
|
valueField: 'email',
|
|
labelField: 'name',
|
|
searchField: ['name', 'email'],
|
|
load: function (query, callback) {
|
|
if (!query.length || query.length < 3) return callback();
|
|
|
|
fetch(`/api/customers/search?query=${encodeURIComponent(query)}`)
|
|
.then(response => response.json())
|
|
.then(json => {
|
|
callback(json.map(customer => ({
|
|
email: customer.email,
|
|
name: `${customer.name} (${customer.email})`
|
|
})));
|
|
}).catch(() => {
|
|
callback();
|
|
});
|
|
},
|
|
render: {
|
|
option: function (item, escape) {
|
|
return '<div>' + escape(item.name) + '</div>';
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
@endpush
|