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

class r6 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 Members,</p>
		
		<p><strong>IMAS Online Members' Directory Update</strong></p>

<p>If you have missed our previous emails below due to your busy schedules, here is another reminder to update your company's profile at the IMAS Online Members' Directory.

</p>

<table style='color:#fff;background:gray;padding:10px;font-family: Verdana;font-size: 12px'>
<tr>
<td>
<p>For members who have already updated, please now login to provide the verification that you have fully completed the exercise.</p>
</td>
</tr>

<tr>
<td>
<p>For members who have only updated partially, we would also require you to login to provide indication when the exercise can be completed.</p>
</td>
</tr>
</table>
<p>To login, please click <a href='https://imas.org.sg/login'>here</a>.</p>
<p>Please provide your response by this <strong>Thursday, 7 March 2024</strong>.</p>
<p>We are grateful for your understanding and cooperation in helping us to complete this exercise. </p>

If you have any queries, 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 attention in this matter.</p>

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

	
	public function reminder()
	{
		$listing = $this->edm_m->get_one();
		$updated = $this->edm_m->get_updated();
		
		foreach($updated as $u)
		{
			$company_list[] = strtolower($u['company']);
		}
		
		
		foreach($listing as $i)
		{
			if(in_array(strtolower($i['company_name']),$company_list))
				continue;
		
			$to = '';	
			$cc = '';			

			$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 & FURTHER ACTION REQUIRED] IMAS Online Members\' Directory Update';
			
			
			$to = $i['email'];			
			$cc = $i['cc_emails'];	
			$cc = $cc.',replies@imas.org.sg';
									
			$html = '';
			
			$edm_content = $i['reminder_email_content2'];

			$html = $this->edm($edm_content);
			
			$html = str_replace('05 March','5 March',$html);
			$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 = $i['id'];

				$d['reminder_datetime_sent3'] = date('Y-m-d H:i:s');

				$d['reminder_email_content3'] = $html;

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