From 957616db54cea8eb15f254fb6eed6631944bef60 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 1 Apr 2025 10:27:42 +0000 Subject: [PATCH] igr live issues --- app/Controllers/Inwardgateregister.php | 38 ++++++++++++++----------- app/Models/Inwardgateregister_model.php | 17 +++++++---- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index 4fa4fd29..5a361bbd 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -928,7 +928,7 @@ function viewIGRDetails() $result_for_email = $this->inwardgateregister_model->getDetailsforEmail($this->session->get('userId'),$roleId); $result_for_history = $this->inwardgateregister_model->getHistoryDetailsforEmail($IGRNo); - + $notification = new Notification(); $history_content = "
IGR History

"; - $email = ""; - for ($i = 0; $i < count($result_for_email['emails']); $i++) { - $email .= $result_for_email['emails'][$i]->email . " , "; + + $to_email_addr = ""; + for ($i = 0; $i < count($result_for_email['to_mails']); $i++) { + $to_email_addr .= $result_for_email['to_mails'][$i]->email . " , "; + // $to_email_addr .= "sanjeev.p@venbainfotech.com,gowtham.m@venbainfotech.com"; } - $email = rtrim($email, " ,"); + $to_email_addr = rtrim($to_email_addr, " ,"); $email_response = $notification->sendEmail([ - 'recipient_email' => $email, + 'recipient_email' => $to_email_addr, 'subject' => $result_for_email['company'].' - IGR Notification', // 'carboncopy'=>Sales@resicoindustries.com,Factory@resicoindustries.com,Invoice@resicoindustries.com, // 'description' => 'IGR Number : '.$IGRNo.' is Edited By '.($result_for_email['full_name'] ?? $this->session->get('name'))." On ".date('d-m-Y H:i A', strtotime(get_current_date_time() . ' +30 seconds')). $history_content, 'description' => $result_for_history['first_line']."
" .$history_content, 'company' => $result_for_email['company'], - 'from_mail'=> $result_for_email['from_mail'] + 'from_mail'=> $result_for_email['from_mails'] ]); log_message('error', 'email reponse : ' . json_encode($email_response)); @@ -1006,9 +1008,9 @@ function viewIGRDetails() // Log the result if ($receiving_status) { - $this->logger->info("Email IDs = " . $email . " " . $mail_log); + $this->logger->info("Email IDs = " . $to_email_addr . " " . $mail_log); } else { - $this->logger->error("Email IDs = " . $email . " " . $mail_log); + $this->logger->error("Email IDs = " . $to_email_addr . " " . $mail_log); } // echo "***".$history_content;die; @@ -1424,22 +1426,24 @@ function updateIGRWeight(){ $result_for_email = $this->inwardgateregister_model->getDetailsforEmail($this->session->get('userId'),$roleId); - - $email = ""; - for ($i = 0; $i < count($result_for_email['emails']); $i++) { - $email .= $result_for_email['emails'][$i]->email . " , "; - } - $email = rtrim($email, " ,"); + // print_r($result_for_email);die; + + $to_email_addr = ''; + for ($i = 0; $i < count($result_for_email['to_mails']); $i++) { + $to_email_addr .= $result_for_email['to_mails'][$i]->email . " , "; + } + // $to_email_addr = " gowtham.m@venbainfotech.com , sanjeev.p@venbainfotech.com"; + $to_email_addr = rtrim($to_email_addr, " ,"); $content = 'A new remark was created by '.$result_for_email['full_name'].' against IGR no '.$IGRNo.',

"'.$remark.'"'; $notification = new Notification(); $notification->sendEmail([ - 'recipient_email' => $email, + 'recipient_email' => $to_email_addr, 'subject' => $result_for_email['company'].' - IGR Remark Raised', 'description' => $content, 'company' => $result_for_email['company'], - 'from_mail'=> $result_for_email['from_mail'] + 'from_mail'=> $result_for_email['from_mails'] ]); diff --git a/app/Models/Inwardgateregister_model.php b/app/Models/Inwardgateregister_model.php index e8c54b66..09cc930e 100755 --- a/app/Models/Inwardgateregister_model.php +++ b/app/Models/Inwardgateregister_model.php @@ -1317,15 +1317,22 @@ $builder = $this->db->table('t_igr_history') $query2 = $this->db->query(" SELECT email FROM tbl_users - WHERE isDeleted = 0 AND roleId =".$roleId // hardcoded because auditor role only. refer with gwm 29/01/2025 + WHERE isDeleted = 0 AND roleId =".$roleId ); - $emails = $query2->getResult(); + $to_mails = $query2->getResult(); + + $query3 = $this->db->query(" + SELECT email FROM tbl_users + WHERE isDeleted = 0 AND userId =".$userId + ); + $from_mails = $query3->getRow(); return [ - 'from_mail' => $company ? $company->EmailAddress : null, - 'full_name' => $fullName ? $fullName->FullName : null, 'company' => $company ? $company->CompanyName : null, - 'emails' => $emails + 'company_mail' => $company ? $company->EmailAddress : null, + 'full_name' => $fullName ? $fullName->FullName : null, + 'from_mails' => $from_mails ? $from_mails->email : null , + 'to_mails' => $to_mails, ]; }