<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class r2 extends CI_Controller {
	public function __construct()
	{
		parent::__construct();
		session_start();
		
		date_default_timezone_set('Asia/Singapore');
		$this->load->model('edm_m');
	}
	
	public function edm($existing_content='',$url='')
	{
				
		$content = "
		<p>Dear Regular Members,</p>
		
		<p>Following up on our broadcast below, this is a gentle reminder to please complete the <strong>online Professional Conduct Statement</strong> <a href='".$url."'>here</a> and submit <strong><u>no later than 7 February 2024</u></strong> if you have not already done so.

</p>
<p>Thank you for your urgent attention in this matter. If you have any queries, please contact the IMAS Secretariat at <a href='mailto:replies@imas.org.sg'>replies@imas.org.sg</a>.

</p>
		</p>

";
		
		$data['content'] = $content;
		
		$html = $this->load->view('emails/mass-email.php',$data,TRUE);
		
		$html .= '<br><br>'.$existing_content;
		
		return $html;
	}
	
	public function reminder222()
	{
		
		$submitted_pcs = $this->edm_m->submitted_pcs();

		foreach($submitted_pcs as $ss)
		{
			$submitted_pcs_list[] = $ss['company_code'];
		}	
	
		$listing = $this->edm_m->user_listing(5);
		
		
		foreach($listing as $a)
		{
			
			if(in_array($a['company_code'],$submitted_pcs_list))
				continue;
			
			
			if($a['id'] == 82)
				continue;
						
			$to = '';			

			$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 = 'REMINDER: FOR YOUR IMMEDIATE RESPONSE [IMAS Compliance Notice] Professional Conduct Statement for 2023';
			$to = $a['email'];			
			
			$cc = '';
			$cc = $a['cc_emails'];	
			$cc = $cc.',replies@imas.org.sg';
			
			$html = '';
			$url = '';
			$url = site_url('form/viewlink2/'.$a['code'].'/'.$a['company_code']);

			$html = $this->edm($a['email_content'],$url);
		
			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_sent'] = date('Y-m-d H:i:s');

				$d['reminder_email_content'] = $html;

				$this->edm_m->update_email_blast($id,$d);		
				
			}	
			
			
		}		
		
		print 'DONE';
	}
	 
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */