<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Email_updates extends CI_Controller {
	public function __construct()
	{
		parent::__construct();
		session_start();

		
		date_default_timezone_set('Asia/Singapore');
		$this->load->model('edm_m');
		$this->load->model('invoices_m');
	}
	
	public function send2($id='')
	{	
		print 's';
	}
	public function send($id='')
	{		
		$record = $this->edm_m->pending_record($id);
		
		if(empty($record))
		{
			print 'ERROR';
			exit;
		}
	
		$content = "
		<p>Dear Members,</p>

<p>
This is a gentle reminder to update your company's profile at the IMAS Online Members' Directory.
</p>
<div style='background-color:#808080;padding:10px;color:#fff;'>
For members who have yet to complete the exercise, please <a href='https://imas.org.sg/login/' style='color:#fff'>log in</a> to the IMAS directory to do so.
</div> 
<br><br>
<div style='background-color:#808080;padding:10px;color:#fff;'>
For members who have already completed the exercise, kindly ensure that you have saved the changes by clicking \"SAVE\" at the bottom of the page.
</div> 
<br>
<img src='https://imas.org.sg/members-directory/block.png?v2' width='300'>
<br>
<p>To login, please click <a href='https://imas.org.sg/login/'>here</a>.</p>
<p>We are grateful for your understanding and cooperation in helping us to complete this important update <strong>by 12 December 2025</strong>. 
</p>
<p>If you have any queries, please contact the IMAS Secretariat at replies@imas.org.sg or at +65 6223 9353. 
</p>
<p>Thank you for your attention in this matter.</p>
";

		$data['content'] = $content;
		
		$html = $this->load->view('emails/mass-email.php',$data,TRUE);
		
		$ss = file_get_contents('m.html');
		
		$final_html = $html.$ss;
		
		
		
		$from = 'replies@imas.org.sg';
		$username = $this->config->item('username');
		$password = $this->config->item('password');
		$host = $this->config->item('host');
		$port = $this->config->item('port');
		$from_name = $this->config->item('from_name');
		$subject = '[REMINDER] IMAS Online Members\' Directory Update';
		
		$to_email = $record['email'];
		$cc_email = $record['cc_emails'];
		
		
		
		if($to_email == '')
		{
			print 'EMAIL NOT FOUND';
			exit;
		}
		
		$to = $to_email;

		
		$cc = $cc_email.',replies@imas.org.sg';
	
	
		if($to != '')
		{
			$d['datetime_sent'] = date('Y-m-d H:i:s');
			$d['email_content'] = $html;
			$this->edm_m->update_email_blast($id,$d);
			send_email($to,$host,$port,$username,$password,$from,$from_name,$subject,$final_html,$file,$filename,$file,$filename,$cc);
			
		}
		
		print 'SENT';
	}
	 
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */