Update simpan email baru saat kirim email
This commit is contained in:
parent
7d456e67f6
commit
85a173fea8
@ -1288,7 +1288,7 @@ class Activities extends Controller {
|
|||||||
$query = $db->query($sql);
|
$query = $db->query($sql);
|
||||||
|
|
||||||
// Untuk Simpan Email Otomatis
|
// Untuk Simpan Email Otomatis
|
||||||
// $this->syncEmails($tos, $ccs, $bccs);
|
$this->syncEmails($tos, $ccs, $bccs);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'replyto' => $replyto,
|
'replyto' => $replyto,
|
||||||
@ -1327,42 +1327,42 @@ class Activities extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Untuk Simpan Email Otomatis
|
// Untuk Simpan Email Otomatis
|
||||||
// public function syncEmails($tos="", $ccs="", $bccs="") {
|
public function syncEmails($tos="", $ccs="", $bccs="") {
|
||||||
// $db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
|
|
||||||
// // Khusus Untuk Simpan email yg dimasukkan
|
// Khusus Untuk Simpan email yg dimasukkan
|
||||||
// $allEmails = $tos .",". $ccs .",". $bccs;
|
$allEmails = $tos .",". $ccs .",". $bccs;
|
||||||
// // pecah jadi array
|
// pecah jadi array
|
||||||
// $emailArr = array_filter(array_map('trim', explode(',', $allEmails)));
|
$emailArr = array_filter(array_map('trim', explode(',', $allEmails)));
|
||||||
// // optional: lowercase biar konsisten
|
// optional: lowercase biar konsisten
|
||||||
// $emailArr = array_map('strtolower', $emailArr);
|
$emailArr = array_map('strtolower', $emailArr);
|
||||||
// // buang duplikat di request
|
// buang duplikat di request
|
||||||
// $emailArr = array_unique($emailArr);
|
$emailArr = array_unique($emailArr);
|
||||||
|
|
||||||
// // GUARD CLAUSE (WAJIB)
|
// GUARD CLAUSE (WAJIB)
|
||||||
// if (empty($emailArr)) {
|
if (empty($emailArr)) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // CEK email
|
// CEK email
|
||||||
// $placeholders = implode(',', array_fill(0, count($emailArr), '?'));
|
$placeholders = implode(',', array_fill(0, count($emailArr), '?'));
|
||||||
// $sql = "SELECT email FROM emails WHERE email IN ($placeholders)";
|
$sql = "SELECT email FROM emails WHERE email IN ($placeholders)";
|
||||||
// $query = $db->query($sql, array_values($emailArr));
|
$query = $db->query($sql, array_values($emailArr));
|
||||||
// $existingEmails = array_column($query->getResultArray(), 'email');
|
$existingEmails = array_column($query->getResultArray(), 'email');
|
||||||
// $newEmails = array_diff($emailArr, $existingEmails);
|
$newEmails = array_diff($emailArr, $existingEmails);
|
||||||
|
|
||||||
// if (!empty($newEmails)) {
|
if (!empty($newEmails)) {
|
||||||
// $values = [];
|
$values = [];
|
||||||
// $binds = [];
|
$binds = [];
|
||||||
|
|
||||||
// foreach ($newEmails as $email) {
|
foreach ($newEmails as $email) {
|
||||||
// $values[] = "(?, NULL)";
|
$values[] = "(?, NULL)";
|
||||||
// $binds[] = $email;
|
$binds[] = $email;
|
||||||
// }
|
}
|
||||||
// $sql = "INSERT INTO emails (email, enddate) VALUES " . implode(',', $values);
|
$sql = "INSERT INTO emails (email, enddate) VALUES " . implode(',', $values);
|
||||||
// $db->query($sql, $binds);
|
$db->query($sql, $binds);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
public function export(){
|
public function export(){
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user