MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/hrms_cafsinfotech_in/OLD/application_bk/controllers/Email_campaign.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Email_campaign  extends Action_controller{
	
	public function __construct(){
		parent::__construct('email_campaign');
		if(!$this->Appconfig->isAppvalid()){
			redirect('config');
		}
	}
	
	// LOAD PAGE WITH TABLE DATA
	public function index(){
		$data['key']          = $this->generateKey();
		$this->load->view("$this->control_name/manage",$data);
	}		

	//Get Email Campaign list
	public function get_email_campaign_list(){
		$encString         = file_get_contents('php://input');
		$_POST             = $this->cryptoDecrypt($encString);
		if(!$_POST){
			echo json_encode(array('success' => false,'message' => 'Invalid Request..','table_data' => ""));
			exit(0);
		}
		$email_for     = $this->input->post('email_for');
		$process_month = $this->input->post('process_month');
		$campaign_query  = 'SELECT prime_email_line_id,process_month,email_line_name,configuration_name,email_for,pdf_template FROM cw_email_line INNER JOIN cw_mail_configurations on cw_mail_configurations.prime_mail_configurations_id = cw_email_line.mail_configuration  WHERE email_for ="'.$email_for.'" and process_month ="'.$process_month.'" and cw_email_line.trans_status = 1 and cw_mail_configurations.mail_status = 1';
		$campaign_info   = $this->db->query("CALL sp_a_run ('SELECT','$campaign_query')");
		$campaign_result = $campaign_info->result();
		$campaign_info->next_result();
		$tr_line = "";
		$i = 1;
		foreach ($campaign_result as $key => $value) {
			$email_line_id      = $value->prime_email_line_id;
			$process_month      = $value->process_month;
			$email_line_name    = $value->email_line_name;
			$configuration_name = $value->configuration_name;
			$email_for          = $value->email_for;
			$log_query  = 'SELECT COUNT(IF(status = 1, 1, NULL)) "success", COUNT(IF(status = 0, 1, NULL)) "failure" FROM cw_email_log WHERE email_line_id ="'.$email_line_id.'"';		
			$log_info   = $this->db->query("CALL sp_a_run ('SELECT','$log_query')");
			$log_result = $log_info->result();
			$log_info->next_result();
			$success  = $log_result[0]->success;
			$failure  = $log_result[0]->failure;
			$tr_line .= "<tr style='cursor:pointer'><td>$i</td><td>$process_month</td><td>$email_line_name</td><td>$configuration_name</td><td>$email_for</td><td onclick=get_email_status($email_line_id,1)>$success</td><td onclick=get_email_status($email_line_id,0)>$failure</td></tr>";
			$i++;
		}
		$table_info = "<table class='table table-bordered' id='campaign_tbl'>
							<thead>
								<tr>
									<th>SNo</th>
									<th>Process Month</th>
									<th>Email Line Name</th>
									<th>Configuration Name</th>
									<th>Email For</th>
									<th>Success</th>
									<th>Failure</th>
								</tr>
							</thead>
							<tbody>$tr_line</tbody>
						</table>";
		echo $table_info;
	}
	public function get_email_logs(){
		$encString         = file_get_contents('php://input');
		$_POST             = $this->cryptoDecrypt($encString);
		if(!$_POST){
			echo json_encode(array('success' => false,'message' => 'Invalid Request..','table_data' => ""));
			exit(0);
		}
		$line_id    = $this->input->post('line_id');
		$status     = $this->input->post('status');
		$log_query  = 'SELECT employee_code,email_id,status,message FROM cw_email_log  WHERE email_line_id ="'.$line_id.'" and status ="'.$status.'"';
		$log_info   = $this->db->query("CALL sp_a_run ('SELECT','$log_query')");
		$log_result = $log_info->result();
		$log_info->next_result();
		$tr_line = "";
		$i = 1;
		foreach($log_result as $key => $value){
			$employee_code = $value->employee_code;
			$email_id      = $value->email_id;
			$status        = $value->status;
			$message       = $value->message;
			if((int)$status === 1){
				$status = "Success";
			}else{
				$status = "Failure";
			}
			$tr_line .= "<tr><td>$i</td><td>$employee_code</td><td>$email_id</td><td>$status</td><td>$message</td></tr>";
			$i++;
		}
		$table_info = "<table class='table table-bordered' id='log_tbl'>
							<thead>
								<tr>
									<th>SNo</th>
									<th>Employee Code</th>
									<th>Email ID</th>
									<th>Status</th>
									<th>Message</th>
								</tr>
							</thead>
							<tbody>$tr_line</tbody>
						</table>";
		echo $table_info;
	}
}
?>