<?php

include_once(EMAIL_DIR_PATH."class.phpmailer.php");


$from_email		=	"support@testingcolorvision.com";
$reply_to		=	"support@testingcolorvision.com";
$mail_message 	= 	'';

$EMAILHEADER	= 	"<table cellspacing='0' cellpadding'0' style=''";

$EMAILFOOTER 	= 	"<p>Warm Regards,<br>
					TCV - Admin<br>
					<a href='mailto:support@KonanMedical.com'>support@KonanMedical.com</a>
					";
					
					
define('EMAIL_FOOTER',$EMAILFOOTER);

switch($email_template)
{
	case '1': 	//Add Sub Admin -- admin/sub_admin_list_controller.php
				
				$subject =  "Admin Account at TestingColorVision.com";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>

									<p>Your login details are as follows:</p>
							  		<p><b>Username</b>: ".$email_address."<br>
									<b>Password</b>: ".$password."</p>
									
									<br><p>Thank you for visiting <a href='http://www.TestingColorVision.com'>www.TestingColorVision.com</a>.</p>";
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;		
				
	case '2'://Admin Update Profile(Update Email)
				$subject =  "Admin Account at TCV";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>
									<p>Your account has been updated. If you did not recently update your account, contact us immediately at <a href='mailto:support@KonanMedical.com'>support@KonanMedical.com</a> or (949) 521-7730.</p><br><p>Thank you for visiting <a href='http://www.TestingColorVision.com'>www.TestingColorVision.com</a>.</p>";
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);					
				break;		
				
	case '3' :			
				$from_email		=	$mailFrom;
				$reply_to		=	$mailFrom;
				$send_to		=   $mailTo;
				$subject = $mailSub;
				$mail_message  = $mailBody;
				
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;
				
	case '333' :			
				$from_email		=	$mailFrom;
				$reply_to		=	$mailFrom;
				//$send_to		=   $mailTo;
				//$subject = $mailSub;
				$mail_message  = $mail_message1;
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;			
	/*case '3':
				/*$subject =  "Admin Account at TCV";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>
									<p>Your email id successfully changed.<br/>
										The  activation link as follows:</p>
							  		<p><b>Activation Link</b>: <a href='".$activationLink."'>Click Here</a><br>
									</p>";
				
		   		$to_mail 	= explode(",",$send_to);
				$toMailCnt 	= count($to_mail);
				for($k=0;$k<$toMailCnt;$k++)
				{   
				  	if($to_mail[$k])   
					$mail->AddAddress($to_mail[$k]);
				}
				break;				*/		
				
	case '4': 	//resend affiliate/discount code/ created discount code from backend							 							 
				$subject 	 =  "Discount/Affiliate Code Information";
				$mail_message=  "<p>Hello ".ucfirst(stripslashes($name)).",</p>
								 <p>Congratulations! TestingColorVision.com Team has sent you a Discount/Affiliate Code. If people purchase a color vision testing plan using your discount code, they will get a discount and you will get a commission.<br>		
								 Below are the Discount Code details:<br><br>
								 <b>Discount Code</b>: ".stripslashes($dis_code)."<br>
								 <b>Discount</b>: ".$dis_on_coupon."<br>
								 <b>Commission</b>: ".$comm_on_coupon."<br>
								 <b>Email Address</b>: ".stripslashes($email_address)."<br>
								 <b>Address</b>: ".stripslashes($address)."<br>
								 <b>Contact No.</b>: ".$contact_no."<br>
								 <b>Notification Email Status</b>: ".$notification_email_status."<br>";
								 if($par_salesman_id!= 0) {
								 $mail_message	.="<b>Parent Salesman</b>: ".ucfirst(stripslashes($parent_salesman_name))."<br>
								 <b>Commisson to Parent Salesman on Sales</b>: ".$comm_to_parent_sal."<br>";
								 }
								 $mail_message	.="<br>Please click following link to Use Discount Code: <br>";
								 
								 if($public_safety == 1)
								 {
								 	$link	=	FOLDER_PATH_HTTP.$dept_name."/sign-up.php?dis_affi_cd=".$dis_code."&rid=".base64_encode($disc_id);
								 	$mail_message	.= "<a href=\"".FOLDER_PATH_HTTP.$dept_name."/sign-up.php?dis_affi_cd=".$dis_code."&rid=".base64_encode($disc_id)."\" >Click here</a>";
								}
								 else
								 {
								 	$link	=	FOLDER_PATH_HTTP."overview.php?dis_affi_cd=".$dis_code;
								 	$mail_message	.= 	"<a href=\"".FOLDER_PATH_HTTP."overview.php?dis_affi_cd=".$dis_code."\" >Click here</a>";
								 }
								 	
									$mail_message	.= "<br><br>
									If you cannot access the link, please copy paste the following URL in the browser:<br>";
									$mail_message	.= $link."</p>
									
									<br><br><p>Thank you for helping us raise the awareness about color vision deficiencies at <a href='http://www.TestingColorVision.com'>www.TestingColorVision.com</a>.</p>";
									
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);					
				break;		
				
	case '5': 	//Corporate user/Single user/Distributor account added by admin  from Back end
				
				$subject =  "New Account at TCV";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>
									<p>A user has been created for you at TestingColorVision.com.</p>
									<p>Your login details are as follows:</p>
							  		<p><b>Username</b>: ".$email_address."<br>
									<b>Password</b>: ".$password."</p>
									<br><p>To login, please go to TestingColorVision.com and click on the button that says, \"Sign In\" in the upper-right hand corner. This is where you will input your login information. After you have logged in, you can also change your password if you wish.</p>
									<br>Thank you for visiting <a href='http://www.TestingColorVision.com'>www.TestingColorVision.com</a>.";
									
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;	
				
	case '6': 	//Admin edits username and password for corporate user/single user 
				$subject =  "Account at TCV: Password has been changed";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>

									<p>Your password has been changed by TestingColorVision.com admin. Your login details are as follows:</p>
							  		<p><b>Username</b>: ".$email_address."<br>
									<b>Password</b>: ".$password."</p>
									
									<br><p>Thank you for visiting <a href='http://www.TestingColorVision.com'>www.TestingColorVision.com</a>.</p>";
				
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;	
				
	case '7': 	///on discount code usage Send notification mail to salesman
				$send_to = $salesman_email;
				$subject 	 =  "Discount Code [".stripslashes($discount_code)."] Usage Details" ;
				$mail_message=  "<p>Hello ".ucfirst(stripslashes($salesman_name)).",</p>
								 <p>Congratulations! Your discount code has been used by ".ucfirst(stripslashes($user_created_by)).".<br><br>		
								 Transaction Details:<br><br>
								 <b>Discount Code</b>: ".stripslashes($discount_code)."<br>
								 <b>Transaction Type</b>: ".$transaction."<br>
								 <b>User Name</b>: ".ucfirst($reg_user_name)."<br>								 
								 <b>Commison Amount</b>: &#36;".$comm_amount."<br>
								 
								 <p>
								 Thank you for helping raise awareness about color vision deficiencies. If you no longer want to receive emails pertaining to your discount/affiliate code usage, please email TCV admin at <a href='mailto:support@KonanMedical.com'>support@KonanMedical.com</a>.</p>
								 ";
								 
									/*<b>Commission Rate</b>: ".$salesman_commision."<br>*/
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);					
				break;	
				
	case '8': 	///on discount code usage Send notification mail to parent salesman if any
				$send_to = $par_salesman_email;
				$subject 	 =  "Discount Code [".stripslashes($discount_code)."] has been used" ;
				$mail_message=  "<p>Hello ".ucfirst(stripslashes($par_salesman_name)).",</p>
								 <p>Congratulations! ".ucfirst(stripslashes($salesman_name))." recently sold a color vision testing plan at TestingColorVision.com. You can find the transaction details below.<br><br>		
								 Transaction Details:<br><br>
								 <b>Salesman's Discount Code</b>: ".stripslashes($discount_code)."<br>
								 <b>Transaction Type</b>: ".$transaction."<br>
								 <b>User Name</b>: ".ucfirst($reg_user_name)."<br>
								 
								 <b>Commision Amount</b>: &#36;".$par_comm_amt."<br>
								 <b>Transaction done by</b>: ".$user_created_by."<br>
								 
								 <p>
								 Thank you for helping raise awareness about color vision deficiencies. If you no longer want to receive emails pertaining to your discount/affiliate code usage, please email TCV admin at <a href='mailto:support@KonanMedical.com'>support@KonanMedical.com</a>.
								 </p>";
								 
									/*<b>Commission Rate</b>: ".$par_salesman_commision."<br>*/
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);					
				break;		
				
	case '9':	//while account Updated from front end, if user changes email then activation link is sent in mail
				$subject =  "User Account at TCV";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>
									<p>Your account has been updated. If you did not recently update your account, contact us immediately at <a href='mailto:support@KonanMedical.com'>support@KonanMedical.com</a> or (850) 288-1246.</p>
									<br><p>Thank you for visiting <a href='http://www.TestingColorVision.com'>www.TestingColorVision.com</a>.</p>
									";
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);					
				break;		
				
	case '10':
				if(isset($_SESSION['C_uId']) && $_SESSION['C_uId'] != 0)
				{
					$subject =  "Corporate User Account at TCV";
				}
				else if(isset($_SESSION['S_uId']) && $_SESSION['S_uId'] != 0)
				{
					$subject =  "Single User Account at TCV";
				}
				
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>
									<p><br/>Assign Plan to Profile :".$C_name."<br/>
										The  Plan Details are as follows:</p>
							  		<p><b>Plan Name</b>: "." ".$planName."<br>
									</p>
									<p><b>Plan Credit</b>: " .$planCredit."<br>
									</p>
									<p><b>Plan Price</b>: " .$planPrice."<br>
									</p>
									<p><b>Plan Description</b>: " .$planDesc."<br>
									</p>
									<p>".$mailBody.".</p>
									";
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);					
				break;		
	
	case '11':
				$subject =  "Test User Account at TCV";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>
									<p>You have been asked to take a test at TestingColorVision.com to test for color vision deficiencies.You can proceed to take a test from <a href='$act_link'>Here</a></p>

									<br><p>Thank you for visiting <a href='http://www.TestingColorVision.com'>www.TestingColorVision.com</a>.</p>
									";
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);					
				break;		
				
		case '12': 	//from frontend user edits username and password for corporate user/single user 
				$subject =  "Account at TCV: Password has been changed";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>

									<p>You recently changed your password at TestingColorVision.com. Your login information is as follows:</p>
							  		<p><b>Username</b>: ".$Username."<br>
									<b>Password</b>: ".$password."</p>
									
									<p>If you did not change your password, please contact TCV immediately at <a href='mailto:support@KonanMedical.com'>support@KonanMedical.com</a> or (949) 521-7730.</p>
									<br><p>Thank you for visiting <a href='http://www.TestingColorVision.com'>www.TestingColorVision.com</a>.</p>
									";
				
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;		
																	
		case '13': 	//Account Setting Updated 
				$subject =  "Account at TCV: Account Settings Updated.";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>

									<p>Your TestingColorVision.com account has been updated. If you did not recently update your account, contact us immediately at <a href='mailto:support@KonanMedical.com'>support@KonanMedical.com</a> or (949) 521-7730.
									</p>
									<br><p>Thank you for visiting <a href='http://www.TestingColorVision.com'>www.TestingColorVision.com</a>.</p>
							  		";
				
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;			
		case '14': 	//Contact Us 
				$subject =  "Contact Form Enquiry by $userfname $lname";
						$mail_message=  "<p>Hello, $admin_name</p>
						
						<p>
						<b>First Name </b> $userfname <br />
						<b>Last Name </b> $lname <br />";
						
						if($comp_name!='')
							$mail_message.="<b>Company Name </b> $comp_name <br />";
			
						if($address!='' || $country  || $state_name  || $city  || $zip  || $country_name)
							$mail_message.="<b>Address </b> $address <br />";
			
						if($country_name!='')
							$mail_message.="$country_name <br />";
			
						if($state_name!='')
							$mail_message.="$state_name <br />";
			
						if($city!='')
							$mail_message.="$city <br />";
			
						if($zip!='')
							$mail_message.="$zip <br />";
			
						if($email!='')
							$mail_message.="<b>Email Address </b> $email <br />";
						
						if($commentbox!='')
							$mail_message.="<b>Enquiry </b> $commentbox <br />";
							
						$mail_message.="</p>";
				

				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;
				
		case '15': 	//Distributor signup 
				$subject =  "Distributor Enquiry by $userfname $lname";
					$mail_message=  "<p>Hello, $admin_name</p>
						
						<p>
						<b>First Name </b> $userfname <br />
						<b>Last Name </b> $lname <br />";
						
						if($comp_name!='')
							$mail_message.="<b>Company Name </b> $comp_name <br />";
			
						if($address!='' || $country  || $state_name  || $city  || $zip  || $country_name)
							$mail_message.="<b>Address </b> $address <br />";
			
						if($country_name!='')
							$mail_message.="$country_name <br />";
			
						if($state_name!='')
							$mail_message.="$state_name <br />";
			
						if($city!='')
							$mail_message.="$city <br />";
			
						if($zip!='')
							$mail_message.="$zip <br />";
			
						if($email!='')
							$mail_message.="<b>Email Address </b> $email <br />";
			
						if($phone!='')
							$mail_message.="<b>Phone Number </b> $phone <br />";
			
						if($commentbox!='')
							$mail_message.="<b>Enquiry </b> $commentbox <br />";
					$mail_message.="</p>";
			
				
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;	
				
		case '16': 	//Sign up from front end: Single/corporate User
				
				$subject =  "Your Account Info at TestingColorVision.com";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>
									<p>Thank you for purchasing a test plan from TestingColorVision.com. Your login details are as follows:</p>									
							  		<p><b>Username</b>: ".$email_address."<br>
									<b>Password</b>: ".$password."</p>
									
									<br><p>Thank you for visiting <a href='http://www.TestingColorVision.com'>www.TestingColorVision.com</a>.</p>";
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;	
				
		case '17': 	//Forgot Password corporate/single/distributor
				
				$subject =  "Account at TCV: Password has been reset";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>
									<p>Your password has been successfully reset. Your login details are as follows:</p>									
							  		<p><b>Username</b>: ".$email_address."<br>
									<b>Password</b>: ".$password."</p>
									
									<br><p>Thank you for visiting <a href='http://www.TestingColorVision.com'>www.TestingColorVision.com</a>.</p>";
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;
		
		
		case '18': 	//Only for Expired corporate Users - unlimited credits
				
				$subject =  "Account at TCV: 2 weeks until expiration";
				$mail_message=  "<p>Hi ".stripslashes(ucfirst($first_name)).",</p>
									<p>We appreciate your decision to use TestingColorVision.com for all of your color vision testing needs. We want to let you know that there are 2 weeks left until your unlimited testing plan expires. We invite you to make arrangements to pay now for a seamless transition. We will send you one more reminder 2 days prior to your plan expiring, for your convenience. If your testing needs have changed, please choose the plan that is best for you, or contact a representative so that we can best satisfy your needs.</p>									
							  		<p>If you have any questions or comments, please don’t hesitate to contact us.Konan Medical can be reach at sales@KonanMedical.com and (949) 521-7730.</p>
				  					<p>Again, thank you for using TestingColorVision.com. We hope you have a splendid day!</p>";
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;
				
		case '19': 	//Only for Expired corporate Users - unlimited credits
				
				$subject =  "Account at TCV: 2 days until expiration";
				$mail_message=  "<p>Hi ".stripslashes(ucfirst($first_name)).",</p>
									<p>We hope you are having a wonderful day. This note is to let you know that there are 2 days left until your unlimited testing plan expires. We invite you to make the proper arrangements to pay promptly for a seamless transition. If your testing needs have changed, please choose the plan that is best for you, or contact a representative so that we can best satisfy your needs.</p>									
							  		<p>If you have any questions or comments, please don't hesitate to contact us.Konan Medical can be reached at sales@KonanMedical.com and (949) 521-7730 </p>
				  					<p>Thank you for using TestingColorVision.com. We hope you have a perfect day!</p>";
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;				
				
		case '20': 	//Only for corporate Users - limited credits
				
				$subject =  "Account at TCV: 5 credits left";
				$mail_message=  "<p>Hi ".stripslashes(ucfirst($first_name)).",</p>
									<p>We appreciate your decision to use TestingColorVision.com for all of your color vision testing needs. We want to let you know that you have 5 test credits remaining on your account. For a seamless transition, we recommend you make the proper arrangements to pay before it hits zero. If your testing needs have changed, please choose the plan that is best for you or contact a representative so that we can best satisfy your needs.</p>									
							  		<p>If you have any questions or comments, please don't hesitate to contact us. Konan Medical can be reached at sales@KonanMedical.com and (949) 521-7730</p>
				  					<p>Again, thank you for using TestingColorVision.com. We hope you have a splendid day!</p>";
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;
				
		case '21': 	//resend affiliate/discount code/ created discount code from backend							 							 
				$subject 	 =  "Discount/Affiliate Code Information";
				$mail_message=  "<p>Hello ".ucfirst(stripslashes($name)).",</p>
								 <p>Congratulations! TestingColorVision.com Team has sent you a Discount/Affiliate Code. If people purchase a color vision testing plan using your discount code, they will get a discount and you will get a commission.<br>		
								 Below are the Discount Code details:<br><br>
								 <b>Discount Code</b>: ".stripslashes($discount_str)."<br>
								 <b>Discount</b>: ".$discount_on."<br>
								 <b>Commission</b>: ".$commission_on."<br>
								 <b>Email Address</b>: ".stripslashes($email)."<br>
								 <b>Address</b>: ".stripslashes($address)."<br>
								 <b>Contact No.</b>: ".$contact."<br>
								 <b>Notification Email Status</b>: Yes<br>";
								 	
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,$EMAILFOOTER);
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);					
				
				break;
				
		case '22': 	//Admin edits username and password for corporate user/single user 
				$subject =  "Account at TCV: Admin Password has been changed";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>

									<p>Whoops! Looks like you forgot your password that allows you to view test-takers' results. Here is your new password:</p>									
							  		
									".$password."</p>
									
									<p>We recommend changing this password when you log back into your account. If you received this email and did not select the 'Forgot Password' link, please immediately login and change your administrator password. Please contact Konan Medical at support@KonanMedical.com or (949) 521-7730 if you are concerned.</p>
									
									<br><p>Cordially,<br>
									The ColorDx Team,</p>
									
									";
				
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,'');
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;	
		case '23': 	//Forgot Password corporate/single/distributor
				
				$subject =  "Account at TCV: Password has been reset";
				$mail_message=  "<p>Hello ".stripslashes(ucfirst($first_name)).",</p>
									<p>Whoops! Looks like you forgot your password that allows you to view test-takers' results. Here is your new password:</p>									
							  		
									".$password."</p>
									
									<p>We recommend changing this password when you log back into your account. If you received this email and did not select the 'Forgot Password' link, please immediately login and change your administrator password. Please contact Konan Medical at support@KonanMedical.com or (949) 521-7730 if you are concerned.</p>
									
									<br><p>Cordially,<br>
									The ColorDx Team,</p>
									
									";
				$pattern  = array('/{mail_message}/','/{IMAGE_PATH_HTTP}/','/{EMAILFOOTER}/');
				$value    = array($mail_message,IMAGE_PATH_HTTP,'');
				$template = file_get_contents(MODULE_PATH."email/templates/email_template.html"); 
				$mail_message    = preg_replace($pattern,$value,$template);
				break;				
}

//echo $mail_message;
$bcc  	= 	"support@testingcolorvision.com";
try
{
$mail 	= 	new PHPMailer();

$mail->IsQmail();
 $mail->From		= $from_email;
 $mail->Subject  = $subject;
//$mail->Body     = $mail_message.($email_template != 3 ? EMAIL_FOOTER : '');
//$mail->AltBody  = $mail_message.($email_template != 3 ? EMAIL_FOOTER : '');
$mail->Body     = $mail_message;
$mail->AltBody  = $mail_message;
$mail->AddAddress($send_to);

if($corpadmin_email != '')
{
	$mail->AddReplyTo($corpadmin_email);
}else{
	$mail->AddReplyTo($reply_to);
}
$mail->AddAttachment($attachment);
$mail->AddBCC($bcc, "BCC's You"); 

//echo 'aaaaa'.$corpadmin_email;exit;
	if($mail->Send())
	{
		//echo "Sent";
	}
	else
	{
		if($corpadmin_email != '')
		{
			 $mail_message = "<p>Hello ".stripslashes(ucfirst($corpadmin_name)).",</p>
							  <p>Email sending failed for user with email ".$send_to."</p>";
							  
							
									
			$mail 	= 	new PHPMailer();

			$mail->IsQmail();
			$mail->From		= $from_email;
			$mail->Subject  = "Email Sending failed";
			//$mail->Body     = $mail_message.($email_template != 3 ? EMAIL_FOOTER : '');
			//$mail->AltBody  = $mail_message.($email_template != 3 ? EMAIL_FOOTER : '');
			$mail->Body     = $mail_message;
			$mail->AltBody  = $mail_message;
			$mail->AddAddress($corpadmin_email);
			$mail->AddReplyTo($corpadmin_email);
			//$mail->AddAttachment($attachment);
			$mail->AddBCC($corpadmin_email, "BCC's You"); 
			if($mail->Send())
			{
			}else{
			}
		}
		//echo "mail error";
		//exit;
	}
	
}catch (phpmailerException $e) {
  echo $e->errorMessage(); 
}catch(phpmailerException  $e)
{
	echo $e->errorMessage(); 
	throw $e;
}


?>
