<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class r4 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>no later than 05 March 2024</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 reminder22()
	{
		
		$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;
			
			
			if($a['id'] == 52)
				continue;
			
			
			if($a['id'] == 88)
				continue;
						
			
			if($a['id'] == 35)
				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'];			
			$to = 'jasmine_ng@imas.org.sg';
			$cc = 'juliet_lee@imas.org.sg,tech@arkstudio.sg';
			//$cc = $a['cc_emails'];	
			//$cc = $cc.',replies@imas.org.sg';
			
			
			$html = '';
			$url = '';
			$url = site_url('form/viewlink2/'.$a['code'].'/'.$a['company_code']);

			$remaining_content = $a['reminder_email_content2'].$a['reminder_email_content'];
			
			$html = $this->edm($remaining_content,$url);
			$html = str_replace('Copyright ? 2023','Copyright &copy; 2023',$html);
			
			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_sent3'] = date('Y-m-d H:i:s');

				$d['reminder_email_content3'] = $html;

				$this->edm_m->update_email_blast($id,$d);		
				
				
	
			}	
			
			exit;
			
		}		
				
		print 'DONE';
	}
	 
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */