86 lines
4.3 KiB
PHP
Executable File
86 lines
4.3 KiB
PHP
Executable File
<!-- partial -->
|
|
<div class="content-wrapper">
|
|
<div class="row ">
|
|
<div class="col-md-8 offset-md-2 grid-margin stretch-card">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h4 class="card-title">Kirim Notifikasi</h4>
|
|
<?php if ($this->session->flashdata('send')) : ?>
|
|
<div class="alert alert-success" role="alert">
|
|
<?php echo $this->session->flashdata('send'); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if ($this->session->flashdata('error')) : ?>
|
|
<div class="alert alert-danger" role="alert">
|
|
<?php echo $this->session->flashdata('error'); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?= form_open_multipart('appnotification/send'); ?>
|
|
<div class="form-group">
|
|
<label>Tipe kirim</label>
|
|
<div class="d-flex flex-wrap align-items-center" style="gap:1rem;">
|
|
<label class="mb-0 font-weight-normal">
|
|
<input type="radio" name="send_target" value="topic" checked onchange="toggleAppnotifTarget()"> Topik (broadcast)
|
|
</label>
|
|
<label class="mb-0 font-weight-normal">
|
|
<input type="radio" name="send_target" value="users" onchange="toggleAppnotifTarget()"> Pengguna terpilih (by ID)
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="form-group" id="wrap-topic">
|
|
<label for="topic">Kirim ke topik</label>
|
|
<select id="topic" class="js-example-basic-single" style="width:100%" name="topic">
|
|
<option value="pelanggan">User</option>
|
|
<option value="driver">Driver</option>
|
|
<option value="mitra">Merchant Partner</option>
|
|
<option value="ouride">Semua</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group" id="wrap-users" style="display:none;">
|
|
<label for="user_ids">Pilih pengguna <span class="text-muted">(nama dan ID)</span></label>
|
|
<select id="user_ids" class="js-example-basic-multiple" name="user_ids[]" multiple="multiple" style="width:100%" data-placeholder="Cari nama atau ID…">
|
|
<?php if (!empty($pelanggan_list)) : ?>
|
|
<?php foreach ($pelanggan_list as $u) : ?>
|
|
<?php
|
|
$label = $u->fullnama;
|
|
if ($label === null || trim((string) $label) === '') {
|
|
$label = $u->no_telepon ?: $u->email ?: ('User #' . (int) $u->id);
|
|
}
|
|
$option_text = $label . ' (ID: ' . (int) $u->id . ')';
|
|
?>
|
|
<option value="<?= (int) $u->id ?>"><?= htmlspecialchars($option_text, ENT_QUOTES, 'UTF-8') ?></option>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</select>
|
|
<small class="form-text text-muted">Hanya pengguna yang pernah login dari aplikasi dengan token FCM valid yang menerima push.</small>
|
|
</div>
|
|
<script>
|
|
function toggleAppnotifTarget() {
|
|
var r = document.querySelector('input[name="send_target"]:checked');
|
|
var topic = document.getElementById('wrap-topic');
|
|
var users = document.getElementById('wrap-users');
|
|
if (!r || !topic || !users) return;
|
|
var isTopic = r.value === 'topic';
|
|
topic.style.display = isTopic ? 'block' : 'none';
|
|
users.style.display = isTopic ? 'none' : 'block';
|
|
}
|
|
document.addEventListener('DOMContentLoaded', toggleAppnotifTarget);
|
|
</script>
|
|
<div class="form-group">
|
|
<label for="title">Judul</label>
|
|
<input type="text" class="form-control" placeholder="notification" name="title" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="message">Deskripsi</label>
|
|
<textarea type="text" class="form-control" placeholder="enter notification title" name="message" required></textarea>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-success">Kirim<i class="mdi mdi-send ml-1"></i></button>
|
|
|
|
<?= form_close(); ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end of content wrapper -->
|