<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Reminder_2025 extends CI_Controller {
	public function __construct()
	{
		parent::__construct();
		session_start();
		
		date_default_timezone_set('Asia/Singapore');
		$this->load->model('edm_m');
	}
	
	public function test()
	{
		
		$old_edm = $this->edm_m->reminder_last();
		
		$email_content = $old_edm['email_content'];
		
		$content = '
		<p style="color: #000000;font-family: Verdana;font-size: 12px">
		<p>Dear Members,</p>
		
		<p><strong>IMAS Online Members\' Directory Update</strong></p>

<p>This is a gentle reminder to update your company\'s profile at the IMAS Online Members\' Directory.</p>

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

<tr>
<td style="padding:10px;">
For members who have only updated partially, please login to complete the exercise.

</td>
</tr>
</table>
<br>
<p>To login, please click <a href=\'https://imas.org.sg/login/\'>here</a>.</p>
<p>We are grateful for your understanding and cooperation in helping us to complete this important update. </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><br><br>

</p>';
		
		$data['content'] = $content;
		
		$html = $this->load->view('emails/mass-email.php',$data,TRUE);
		
		$html = $html.$email_content;
		
		$get_updated = $this->edm_m->get_updated();
		$reminder_list = $this->edm_m->reminder_list();
		
		$get_updated_list = array();
		foreach($get_updated as $r)
		{
					
			$get_updated_list[trim($r['company'])] = 1;
		}
		
	
		
		foreach($reminder_list as $r)
		{
			$company = '';
			
			$company = $r['company'];
			
			if($get_updated_list[$company] != 1)
			{
				//print $company.'<br>';
				$to = '';
				$to = $r['email1'];
				$cc_list = array();
				$cc_list_list = '';
				
				if($r['email2'] != '')
				{
					$cc_list[] = $r['email2'];
				}
				if($r['email3'] != '')
				{
					$cc_list[] = $r['email3'];
				}
				if($r['email4'] != '')
				{
					$cc_list[] = $r['email4'];
				}
				if($r['email5'] != '')
				{
					$cc_list[] = $r['email5'];
				}
				if($r['email6'] != '')
				{
					$cc_list[] = $r['email6'];
				}
				
				$cc_list_list = implode(',',$cc_list);
				$cc_list_list = $cc_list_list.',replies@imas.org.sg';
				
				
				$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 = 'Reminder: IMAS Online Members\' Directory Update';
				
				$cc = $cc_list_list;
								
				if($to != '')
				{
					
					send_email($to,$host,$port,$username,$password,$from,$from_name,$subject,$html,$file,$filename,$file,$filename,$cc);
				}
				
				$data2['reminder_email_content'] = $html;
				$data2['datetime_reminder_sent'] = date('Y-m-d H:i:s');				
				$this->edm_m->update_members_update($r['id'],$data2);
				
				$cc = '';
				$cc_list_list = '';
				$cc_list = array();
				$cc_list_list = '';
			}
		}
		
		print 'DONE';
		
	}
	 
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */