FIX_Notification validation for exist
This commit is contained in:
parent
21c1c6c508
commit
9bcefd7aff
1048
Notifications.php
Normal file
1048
Notifications.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -619,11 +619,44 @@ class Notifications extends BaseController
|
||||
if (empty($fullName)) {
|
||||
$this->logger->error('There is no subcription Name');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ($status === 'Approved') {
|
||||
# EXPIRY NOTIFY TEMPLATE EMAIL
|
||||
$emailTemplateName = $NotificationModel->getTempName('EXPIRY NOTIFY TEMPLATE EMAIL');
|
||||
echo "#".$customerId." - Person Name :".$fullName." <br>";
|
||||
echo "#".$customerId." - Person Name :".$fullName." ----- ( Expiry on ". $expirydate.") <br>";
|
||||
if(empty($row['email'])){
|
||||
echo ($inx+1).") Email Not Available <br>";
|
||||
continue;
|
||||
}
|
||||
|
||||
$existingcheck = $NotificationModel->checkEmailAlreadyExisting($row['email'],$customerId);
|
||||
$check_existing = 0;
|
||||
$check_date = "";
|
||||
$check_diff_days = "";
|
||||
|
||||
if(!empty($existingcheck)){
|
||||
|
||||
foreach ($existingcheck as $i => $r) {
|
||||
if($r['receiving_status'] == 1){
|
||||
$check_existing = 1;
|
||||
$check_date = $r['sent_time'];
|
||||
$sentTimestamp = strtotime($r['sent_time']);
|
||||
$provedTimestamp = strtotime($providedDate);
|
||||
|
||||
|
||||
$diffInSeconds = abs($provedTimestamp - $sentTimestamp);
|
||||
$diffInDays = $diffInSeconds / (60 * 60 * 24);
|
||||
|
||||
$check_diff_days = $diffInDays;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($check_existing){
|
||||
echo ($inx+1).") Email already send on - ".$check_date."<br>";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($emailTemplateName) && !empty($emailTemplateName)) {
|
||||
$campaign_id = 1;
|
||||
# Insertion on History Email Means Campaign ID 1 Hardcoded
|
||||
@ -704,6 +737,35 @@ class Notifications extends BaseController
|
||||
}
|
||||
# EXPIRY NOTIFY TEMPLATE EMAIL Closed
|
||||
if ($status === 'Approved') {
|
||||
|
||||
|
||||
$existingcheck2 = $NotificationModel->checkEmailAlreadyExisting($userMobileNumber,$customerId);
|
||||
$check_existing2 = 0;
|
||||
$check_date2 = "";
|
||||
$check_diff_days2 = "";
|
||||
|
||||
if(!empty($existingcheck2)){
|
||||
|
||||
foreach ($existingcheck2 as $i2 => $r2) {
|
||||
if($r2['receiving_status'] == 1){
|
||||
$check_existing2 = 1;
|
||||
$check_date2 = $r2['sent_time'];
|
||||
$sentTimestamp2 = strtotime($r2['sent_time']);
|
||||
$provedTimestamp2 = strtotime($providedDate);
|
||||
|
||||
|
||||
$diffInSeconds2 = abs($provedTimestamp2 - $sentTimestamp2);
|
||||
$diffInDays2 = $diffInSeconds2 / (60 * 60 * 24);
|
||||
|
||||
$check_diff_days2 = $diffInDays2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($check_existing2){
|
||||
echo ($inx+1).") whatsapp already send ".$check_date2."<br>";
|
||||
continue;
|
||||
}
|
||||
# EXPIRY NOTIFY TEMPLATE WHATSAPP
|
||||
$whatsappTemplateName = $NotificationModel->getTempName('EXPIRY NOTIFY TEMPLATE WHATSAPP');
|
||||
// print_r($whatsappTemplateName);die;
|
||||
@ -817,7 +879,7 @@ class Notifications extends BaseController
|
||||
$model->where('to_subscription <', $currentDate)
|
||||
->set(['status' => 0])
|
||||
->update();
|
||||
log_message('info','inside the update function');
|
||||
log_message('error','inside the update function');
|
||||
}
|
||||
# getExpCustomerDetail fns Closed
|
||||
|
||||
|
||||
@ -177,11 +177,10 @@ public function customerGroupQueryExecution($queries){
|
||||
}
|
||||
}
|
||||
|
||||
public function getTempName($constant)
|
||||
public function getTempName($name)
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
$query = "SELECT * FROM templates WHERE isactive = 1 AND template_name = '".$constant."'";
|
||||
// print_r($query);die;
|
||||
$query = "SELECT * FROM templates WHERE isactive = 1 AND template_name = '".$name."'";
|
||||
$result = $db->query($query)->getResultArray();
|
||||
if (isset($result)) {
|
||||
return $result;
|
||||
@ -319,6 +318,14 @@ public function customerGroupQueryExecution($queries){
|
||||
return count($arr)>0 ? $arr : [];
|
||||
|
||||
}
|
||||
public function checkEmailAlreadyExisting($email,$customerId){
|
||||
return $this->db->table('notification_history_children as nhc' )
|
||||
->join('customers as C', 'C.customer_id = nhc.customer_id', 'left')
|
||||
->where('nhc.receiving_entity =',$email)
|
||||
->where('C.customer_id =',$customerId)
|
||||
->where('nhc.sent_time >=', date('Y-m-d H:i:s', strtotime('-30 days')))
|
||||
->get()->getResultArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user