<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class rm2 extends CI_Controller {
	public function __construct()
	{
		parent::__construct();
		session_start();
		
		date_default_timezone_set('Asia/Singapore');
		$this->load->model('edm_m');
	}
	
	public function import()
	{
		
			// Path to the CSV file
		$filename = 'export.csv';

		// Open the CSV file for reading
		if (($handle = fopen($filename, 'r')) !== false) {
			// Skip the header row
			$header = fgetcsv($handle);
			
			
			// Read and insert each row
			while (($row = fgetcsv($handle)) !== false) {
				$data[] = $row;
			}

			// Close the file
			fclose($handle);

			foreach($data as $s)
			{
				$d['company'] = $s[0];
				$d['membership_type'] = $s[1];
				$d['email1'] = $s[2];
				$d['email2'] = $s[3];
				$d['email3'] = $s[4];
				$d['email4'] = $s[5];
				$d['email5'] = $s[6];
				$d['email6'] = $s[7];
				
				$this->edm_m->add2($d);
				
				$d = array();
			}
			
			echo "CSV data has been successfully inserted into the database!";
		} else {
			echo "Failed to open the CSV file.";
		}

	}

	public function edm($existing_content='')
	{
				
		$content = "
		<p>Dear Members,</p>
		
		<p>We hope this message finds you well.</p>

 

<p>As part of IMAS' ongoing efforts to maintain accurate and up-to-date records, we kindly request you to review and update your company's information in the IMAS Members Online Directory. This ensures that your organization's profile reflects the latest details, making it easier for others to connect with you.</p>

 

<p><strong>How to Update Your Information:</strong><br>

<ul>
<li>Designated administrators may log in <a href='https://imas.org.sg/login/'>here</a> to access your company's account.</li>
<li>Click on <strong>'My Company Profile'</strong> at the top right icon.</li>
<li>Review your current company details and make any necessary updates.</li>
<li>Save your changes at the end of the page.</li>
</ul>
 </p>
<p>
Upon completion, please send us a confirmation to <a href='mailto:replies@imas.org.sg'>replies@imas.org.sg</a>
</p>
<p>
We kindly ask that updates be completed by <strong>Thursday, 2 January 2025</strong> to ensure the directory remains current.
</p>
<p>
 

If you need any assistance, 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 continued support of IMAS as always.
</p>
 
";

		
		$data['content'] = $content;
		
		$html = $this->load->view('emails/mass-email.php',$data,TRUE);
		
		$html .= '<br><br>'.$existing_content;
		
		return $html;
	}
	
	
	public function test()
	{
		$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 = 'IMAS Online Members\' Directory Update';
		$to = $a['email'];	
	    $to = 'juliet_lee@imas.org.sg';
	   

	   
		$cc = '';			

		//$cc = $a['cc_emails'];	
		//$cc = $cc.',replies@imas.org.sg';

		$cc = 'jasmine_ng@imas.org.sg,tech@arkstudio.sg';
		$html = '';

		$html = $this->edm($a['email_content']);
	
		
		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_reminder_email_blast2($id,$d);			

		}
	}
	 
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */