<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Test_email 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 read($invoice_number='')
	{	
		$filename = 'reminder2025.csv';
		
		$data = [];

		if (($handle = fopen($filename, "r")) !== false) {
			while (($row = fgetcsv($handle, 1000, ",")) !== false) {
				$data[] = $row; // Each line is an array of values
			}
			fclose($handle);
		}
		
		foreach($data as $d)
		{
			$data_list[trim($d[2])] = $d;
		}
		
		return $data_list[$invoice_number];
		
	}
	
	public function send($id='')
	{		
	
		$content = "
		<p>Dear Members,</p>
<p>We hope this message finds you well.</p>
<p>As part of IMAS' ongoing efforts to maintain accurate and up-to-date records, we kindly request you to review and update your company's information in the IMAS Members Online Directory. This ensures that your organization's profile reflects the latest details, making it easier for others to connect with you.
</p>
<p><strong>How to Update Your Information:</strong></p>
<p>
<ul>
<li>Designated administrators may log in <a href='https://imas.org.sg/login/'>here</a> to access your company's account.</li>
<li>Click on <strong>'My Company Profile'</strong> at the top right icon.</li>
<li>Review your current company details and make any necessary updates.</li>
<li>Save your changes at the end of the page.</li>
</ul>
</p>
<p>Upon completion, please send us a confirmation to <a href='mailto:replies@imas.org.sg'>replies@imas.org.sg</a> </p>
<p>We kindly ask that updates be completed by <strong>Friday, 28 November 2025</strong> to ensure the directory remains current. </p>
<p>If you need any assistance, please contact the IMAS Secretariat at <a href='mailto:replies@imas.org.sg'>replies@imas.org.sg</a> or at +65 6223 9353. </p>
<p>Thank you for your continued support of IMAS as always. </p>";

		$data['content'] = $content;
		
		$html = $this->load->view('emails/mass-email.php',$data,TRUE);
		
		$final_html = $html;
		
		
		$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 = 'IMAS Online Members\' Directory Update';
		
		$to = $to_email;	
		$to = 'jingwen_poh@imas.org.sg';
		$cc = 'weeyong_ang@imas.org.sg';
		//$cc = $cc_email.',replies@imas.org.sg';
		
		if($to != '')
		{
			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 */