<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Email_pcs extends CI_Controller {
	public function __construct()
	{
		parent::__construct();
		session_start();
		
		date_default_timezone_set('Asia/Singapore');
		$this->load->model('edm_m');
	}
	
	public function t($code='',$company_code='',$link)
	{
		print 'z5';
		
	}
	 
	 
	public function edm_content($code='',$company_code='',$link)
	{
		$content = "
		<p>Dear Regular Members,</p>
<p>
If you've missed our previous emails due to your busy schedule, this is a gentle reminder to complete the <strong>online Professional Conduct Statement</strong> <a href='".$link."'>here</a> if you have not already done so. Please ensure your submission is done by <strong>7 March 2025</strong>.
</p>
<p>We appreciate your prompt attention to this matter. If you have any questions, feel free to contact the IMAS Secretariat at <a href='mailto:replies@imas.org.sg'>replies@imas.org.sg</a>.
</p>
";
		
		$data['content'] = $content;
		
		$html = $this->load->view('emails/mass-email.php',$data,TRUE);
		
		
		return $html;
		
	}
	 
	public function index($id='')
	{			
		if($id == '')
		{
			print 'ERROR';
			exit;
		}
		
		$a = $this->edm_m->get_pcs_one($id);
		
		if(empty($a))
		{
			print 'ERROR';
			exit;
		}
	
		$html = '';
		$code = '';
		$company_code = '';
		$code = $a['code'];
		$company_code = $a['company_code'];
		
		$link = 'https://imas.org.sg/members-directory/index.php/form/index2/'.$code.'/'.$company_code;
		

		$html = $this->edm_content($code,$company_code,$link);
		$reminder_email_content = '';
		$reminder_email_content = $a['reminder_email_content'];
		
		$reminder_email_content = str_replace('[LINK]',$link,$reminder_email_content);
		
		
		$html = $html.$reminder_email_content;
		
		$to = '';
		$to = $a['email'];
		
		$from = $this->config->item('from');
		$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 Compliance Notice] [REMINDER] Professional Conduct Statement for 2024';
								
		$cc = $a['cc_emails'];
		$cc = $cc.',replies@imas.org.sg';
		
	

		if($to != '')
		{			
			send_email($to,$host,$port,$username,$password,$from,$from_name,$subject,$html,$file,$filename,$file,$filename,$cc);
			$id = $a['id'];
			$d['reminder_datetime_sent2'] = date('Y-m-d H:i:s');
			$d['reminder_email_content2'] = $html;
			$this->edm_m->update_email_blast($id,$d);
			
		}
		
		
		$html = '';
		$to = '';
		$cc = '';	
		print 'DONE';
		
	}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */