<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Importd extends CI_Controller {
	public function __construct()
	{
		parent::__construct();
		session_start();
		
		$url = $this->uri->segment(2);
	
		$this->load->model('edm_m');
	}	
	
	
	public function index()
	{
		
		$a = read_excel('Regular2.xlsx');
		
		foreach($a[0] as $counter=>$b)
		{
			if($counter>0)
			{
			
				
				$company_name = '';
				$membership_type = '';
				$email_to = '';
				$cc_emails = array();
				
				$company_name = $b[0];
				$membership_type = $b[1];
				
				if($b[3] != '')
				{
					$email_to = $b[3];
					
				} else {
					$email_to = $b[2];					
				}
				
				
				
				
				if($b[2] != '' && $b[2] != 'N/A')
				{					
					array_push($cc_emails, trim($b[2]));
				}
				if($b[4] != '' && $b[4] != 'N/A')
				{					
					array_push($cc_emails, trim($b[4]));
				}
				if($b[5] != '' && $b[5] != 'N/A')
				{					
					array_push($cc_emails, trim($b[5]));
				}
				if($b[6] != '')
				{					
					array_push($cc_emails, trim($b[6]));
				}
				if($b[7] != '')
				{					
					array_push($cc_emails, trim($b[7]));
				}
				if($b[8] != '')
				{					
					array_push($cc_emails, trim($b[8]));
				}
				if($b[9] != '')
				{					
					array_push($cc_emails, trim($b[9]));
				}
				
				$cc_emails_joined = '';
				$cc_emails_joined = implode(',',$cc_emails);
				
				$aa = generateRandomString(5);
				$record['blast_id'] = 7;
				$record['edm_type'] = 2;
				$record['company_name'] = $company_name;
				$record['company_code'] = md5($company_name);
				$record['email'] = $email_to;
				$record['cc_emails'] = $cc_emails_joined;
				$record['code'] = md5($email_to).$aa;
			
				$this->edm_m->add_user_record($record);
				
				
				$record = array();
				
				
			}
		}
		
	}	
	 
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */