<?php
//This code is copyright (c) ViciSoft SL, all rights reserved.
//The contents of this file are protected under law as the intellectual property 
//of ViciSoft SL. Any use, reproduction, disclosure or copying of any kind 
//without the express and written permission of ViciSoft SL is forbidden.
//Author: Vince Reid, vincereid@gmail.com
if(@$storesessionvalue=="") $storesessionvalue="virtualstore".time();
if(@$_SESSION['loggedon']!=$storesessionvalue||@$GLOBALS['disallowlogin']||!@$GLOBALS['incfunctionsdefined']) exit;
$success=TRUE;
$alreadygotadmin=getadminsettings();
$dorefresh=FALSE;
if(getpost('posted')=="1"){
	if(getpost('act')=="domodify"){
		if(($adminlangsettings & 4096)==4096 && getpost("id")!="invoiceheaders") $maxlangs=$adminlanguages; else $maxlangs=0;
		for($index=0; $index <= $maxlangs; $index++){
			if($index==0) $mesgid=''; else $mesgid=$index+1;
			$sSQL="UPDATE emailmessages SET ";
			$themessage=getpost('emtextarea' . ($index+1));
			if(getpost('id')=="orderstatusemail"){
				$sSQL.="orderstatussubject".$mesgid."='" . escape_string(getpost('eminputtext' . ($index+1))) . "',";
				$sSQL.="orderstatusemail".$mesgid."='" . escape_string($themessage) . "'";
			}elseif(getpost('id')=="emailheaders"){
				$sSQL.="emailsubject".$mesgid."='" . escape_string(getpost('eminputtext' . ($index+1))) . "',";
				$sSQL.="emailheaders".$mesgid."='" . escape_string($themessage) . "'";
			}elseif(getpost('id')=="receiptheaders"){
				$sSQL.="receiptheaders".$mesgid."='" . escape_string($themessage) . "'";
			}elseif(getpost("id")=="invoiceheaders"){
				ect_query("UPDATE admin SET packingslipuseinvoice=".getpost("packingslipuseinvoice")." WHERE adminID=1") or ect_error();
				$sSQL.="invoiceheader='" . escape_string(getpost("invoiceheader")) . "',";
				$sSQL.="invoiceaddress='" . escape_string(getpost("invoiceaddress")) . "',";
				$sSQL.="invoicefooter='" . escape_string(getpost("invoicefooter")) . "',";
				$sSQL.="packingslipheader='" . escape_string(getpost("packingslipheader")) . "',";
				$sSQL.="packingslipaddress='" . escape_string(getpost("packingslipaddress")) . "',";
				$sSQL.="packingslipfooter='" . escape_string(getpost("packingslipfooter")) . "'";
			}elseif(getpost('id')=="dropshipheaders"){
				$sSQL.="dropshipsubject".$mesgid."='" . escape_string(getpost('eminputtext' . ($index+1))) . "',";
				$sSQL.="dropshipheaders".$mesgid."='" . escape_string($themessage) . "'";
			}elseif(getpost('id')=="giftcertificate"){
				$sSQL.="giftcertsubject".$mesgid."='" . escape_string(getpost('eminputtext' . ($index+1))) . "',";
				$sSQL.="giftcertemail".$mesgid."='" . escape_string($themessage) . "'";
			}elseif(getpost('id')=="giftcertsender"){
				$sSQL.="giftcertsendersubject".$mesgid."='" . escape_string(getpost('eminputtext' . ($index+1))) . "',";
				$sSQL.="giftcertsender".$mesgid."='" . escape_string($themessage) . "'";
			}elseif(getpost('id')=="notifybackinstock"){
				$sSQL.="notifystocksubject".$mesgid."='" . escape_string(getpost('eminputtext' . ($index+1))) . "',";
				$sSQL.="notifystockemail".$mesgid."='" . escape_string($themessage) . "'";
			}elseif(getpost('id')=="abandonedcart"){
				$sSQL.="abandonedcartsubject".$mesgid."='" . escape_string(getpost('eminputtext' . ($index+1))) . "',";
				$sSQL.="abandonedcartemail".$mesgid."='" . escape_string($themessage) . "'";
			}elseif(getpost('id')=="shiplineitem"){
				$sSQL.="shiplineitemsubject".$mesgid."='" . escape_string(getpost('eminputtext' . ($index+1))) . "',";
				$sSQL.="shiplineitememail".$mesgid."='" . escape_string($themessage) . "'";
			}
			$sSQL.=' WHERE emailID=1';
			ect_query($sSQL) or ect_error();
		}
		$dorefresh=TRUE;
	}
}
if($dorefresh){
	print '<meta http-equiv="refresh" content="1; url=adminemailmsgs.php';
	print '?id=' . urlencode(getpost('id'));
	print '">';
}
if(getpost('id')!='' && getpost('act')=='modify'){
	if(@$htmlemails!=TRUE) $htmleditor='';
	if(@$htmleditor=='ckeditor'){ ?>
<script src="ckeditor/ckeditor.js"></script>
<?php
	} ?>
<script>
<!--
function formvalidator(theForm){
return (true);
}
function setpsvisibility(theobj){
if(theobj[theobj.selectedIndex].value=='1'){
	for(var index=1;index<=3;index++)
		document.getElementById('ps'+index).style.display='none';
}else{
	for(var index=1;index<=3;index++)
		document.getElementById('ps'+index).style.display='';
}
}
function expandckeditor(divid){
	document.getElementById(divid).style.border='none';
	document.getElementById(divid).style.padding=0;
}
//-->
</script>
      <table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
        <tr>
		  <td width="100%" align="center">
		  <form name="mainform" method="post" action="adminemailmsgs.php" onsubmit="return formvalidator(this)">
<?php	writehiddenvar('posted', '1');
		writehiddenvar('act', 'domodify');
		writehiddenvar('id', getpost('id'));
?>
            <table width="100%" border="0" cellspacing="2" cellpadding="2">
			  <tr> 
                <td width="100%" colspan="2" align="center"><strong><?php print $yyEmlAdm . ': ' . getpost('id') . '<br />&nbsp;'; ?></strong></td>
			  </tr>
<?php	$theid=getpost('id');
		if(($adminlangsettings & 4096)==4096 && $theid!="invoiceheaders") $maxlangs=$adminlanguages; else $maxlangs=0;
		for($index=0; $index <= $maxlangs; $index++){
			$replacementfields='';
			$subjectreplacementfields='';
			$hassubject=FALSE;
			$languageid=$index+1;
			if($theid=='orderstatusemail'){
				$fieldlist=getlangid('orderstatussubject',4096).','.getlangid('orderstatusemail',4096);
				$replacementfields='%orderid% %ordername% %orderdate% %oldstatus% %newstatus% %date% %shipmethod% {%statusid<span style="color:#F00">#</span>%} {%statusinfo%} {%trackingnum%} {%hastrackingnum%} {%invoicenum%} {%reviewlinks%}';
				$subjectreplacementfields='%orderid%';
				$hassubject=TRUE;
			}elseif($theid=='emailheaders'){
				$fieldlist=getlangid('emailsubject',4096).','.getlangid('emailheaders',4096);
				$replacementfields='%messagebody% %ordername% %orderdate% {%reviewlinks%}';
				$subjectreplacementfields='%orderid% %ordername%';
				$hassubject=TRUE;
			}elseif($theid=='receiptheaders'){
				$fieldlist=getlangid('receiptheaders',4096);
				$replacementfields='%messagebody% %reviewlinks% %ordername% %orderdate%';
				$hassubject=FALSE;
			}elseif($theid=='invoiceheaders'){
				$fieldlist='invoiceheader,invoiceaddress,invoicefooter,packingslipheader,packingslipaddress,packingslipfooter';
				$replacementfields='';
				$hassubject=FALSE;
			}elseif($theid=='dropshipheaders'){
				$fieldlist=getlangid('dropshipsubject',4096).','.getlangid('dropshipheaders',4096);
				$replacementfields='%messagebody% %ordername% %orderdate%';
				$subjectreplacementfields='%orderid%';
				$hassubject=TRUE;
			}elseif($theid=='giftcertificate'){
				$fieldlist=getlangid('giftcertsubject',4096).','.getlangid('giftcertemail',4096);
				$replacementfields='%toname% %fromname% %value% %certificateid% %storeurl% {%message%}';
				$subjectreplacementfields='%fromname%';
				$hassubject=TRUE;
			}elseif($theid=='giftcertsender'){
				$fieldlist=getlangid('giftcertsendersubject',4096).','.getlangid('giftcertsender',4096);
				$replacementfields='%toname%';
				$subjectreplacementfields='%toname%';
				$hassubject=TRUE;
			}elseif($theid=='notifybackinstock'){
				$fieldlist=getlangid('notifystocksubject',4096).','.getlangid('notifystockemail',4096);
				$replacementfields='%pid% %pname% %link% %storeurl%';
				$subjectreplacementfields='%pid %pname%';
				$hassubject=TRUE;
			}elseif($theid=='abandonedcart'){
				$fieldlist=getlangid('abandonedcartsubject',4096).','.getlangid('abandonedcartemail',4096);
				$replacementfields='%ordername% %orderdate% %abandonedcartid% {%email1%} {%email2%} {%email3%}';
				$subjectreplacementfields='{%email1%} {%email2%} {%email3%}';
				$hassubject=TRUE;
			}elseif($theid=='shiplineitem'){
				$fieldlist=getlangid('shiplineitemsubject',4096).','.getlangid('shiplineitememail',4096);
				$replacementfields='%ordername% %orderdate% %orderid% %pid% %pname% %shipcarrier% {%trackingnum%} {%dropshipper<span style=""color:#F00"">#</span>%}';
				$subjectreplacementfields='%ordername% %orderdate% %orderid% %pid% %pname% %shipcarrier% %shipcarrierlink% %trackingnum% {%dropshipper<span style=""color:#F00"">#</span>%}';
				$hassubject=TRUE;
			}
			$sSQL="SELECT ".$fieldlist." FROM emailmessages WHERE emailID=1";
			$result=ect_query($sSQL) or ect_error();
			if($rs=ect_fetch_assoc($result)){
				if($theid=='orderstatusemail'){
					$thesubject=trim($rs[getlangid('orderstatussubject',4096)]);
					$themessage=trim($rs[getlangid('orderstatusemail',4096)]);
				}elseif($theid=='emailheaders'){
					$thesubject=trim($rs[getlangid('emailsubject',4096)]);
					$themessage=trim($rs[getlangid('emailheaders',4096)]);
				}elseif($theid=='receiptheaders'){
					$themessage=trim($rs[getlangid('receiptheaders',4096)]);
				}elseif($theid=='invoiceheaders'){
					$themessage='';
					$invoiceheader=trim($rs['invoiceheader']);
					$invoiceaddress=trim($rs['invoiceaddress']);
					$invoicefooter=trim($rs['invoicefooter']);
					$packingslipheader=trim($rs['packingslipheader']);
					$packingslipaddress=trim($rs['packingslipaddress']);
					$packingslipfooter=trim($rs['packingslipfooter']);
				}elseif($theid=='dropshipheaders'){
					$thesubject=trim($rs[getlangid('dropshipsubject',4096)]);
					$themessage=trim($rs[getlangid('dropshipheaders',4096)]);
				}elseif($theid=='giftcertificate'){
					$thesubject=trim($rs[getlangid('giftcertsubject',4096)]);
					$themessage=trim($rs[getlangid('giftcertemail',4096)]);
				}elseif($theid=='giftcertsender'){
					$thesubject=trim($rs[getlangid('giftcertsendersubject',4096)]);
					$themessage=trim($rs[getlangid('giftcertsender',4096)]);
				}elseif($theid=='notifybackinstock'){
					$thesubject=trim($rs[getlangid('notifystocksubject',4096)]);
					$themessage=trim($rs[getlangid('notifystockemail',4096)]);
				}elseif($theid=='abandonedcart'){
					$thesubject=trim($rs[getlangid('abandonedcartsubject',4096)]);
					$themessage=trim($rs[getlangid('abandonedcartemail',4096)]);
				}elseif($theid=='shiplineitem'){
					$thesubject=trim($rs[getlangid('shiplineitemsubject',4096)]);
					$themessage=trim($rs[getlangid('shiplineitememail',4096)]);
				}else
					print 'id not set';
			}
			ect_free_result($result);
			$themessage=str_replace(array('<br>','%nl%'), '<br />', $themessage);
			if($adminlanguages > 0){ ?>
			  <tr>
				<td align="center" colspan="2"><strong><?php print $yyLanID . ': ' . ($index+1)?></strong></td>
			  </tr>
<?php		}
			if($hassubject){
				if($subjectreplacementfields!=''){ ?>
			  <tr>
				<td align="right"><strong><?php print $yyRepFld?>:</strong></td>
				<td align="left"><?php print $subjectreplacementfields?></td>
			  </tr>
<?php			} ?>
			  <tr>
				<td align="right"><strong><?php print $yySubjc?>:</strong></td>
				<td align="left"><input type="text" name="eminputtext<?php print ($index+1)?>" size="55" maxlength="255" value="<?php print $thesubject?>" /></td>
			  </tr>
<?php		}
			if($replacementfields!=''){ ?>
			  <tr>
				<td align="right"><strong><?php print $yyRepFld?>:</strong></td>
				<td align="left"><?php print $replacementfields?></td>
			  </tr>
<?php		}
			if(@$htmlemails && @$htmleditor!='ckeditor' && @$htmleditor!='froala'){ ?>
			  <tr>
				<td align="right">&nbsp;</td>
				<td align="left">Remember to use <strong>&lt;br /&gt;</strong> for a new line.</td>
			  </tr>
<?php		}
			if($theid=='invoiceheaders'){
				$sSQL="SELECT packingslipuseinvoice FROM admin WHERE adminID=1";
				$result=ect_query($sSQL) or ect_error();
				$rs=ect_fetch_assoc($result);
				$packingslipuseinvoice=$rs['packingslipuseinvoice'];
				ect_free_result($result); ?>
			  <tr>
				<td colspan="2">
			<table>
			  <tr>
				<td align="right"><strong>Separate Packing Slip Headers:</strong></td>
				<td align="left">
				<select name="packingslipuseinvoice" size="1" onchange="setpsvisibility(this)"><option value="0">Set Packing Slip Headers Separately</option><option value="1"<?php if($packingslipuseinvoice!=0) print ' selected="selected"'?>>Use same headers for Packing Slips</option></select></td>
			  </tr>
			  <tr>
				<td align="right"><strong>Invoice Header:</strong></td>
				<td align="left">
<?php	if(@$htmleditor=='froala') print '<div id="invoiceheaderdiv" class="htmleditorcontainer">'; ?>
				<textarea id="invoiceheader" name="invoiceheader" cols="90" rows="10"><?php print htmlspecials($invoiceheader)?></textarea>
<?php	if(@$htmleditor=='froala') print '</div>'; ?>
				</td>
			  </tr>
			  <tr>
				<td align="right"><strong>Invoice Address:</strong></td>
				<td align="left">
<?php	if(@$htmleditor=='froala') print '<div id="invoiceaddressdiv" class="htmleditorcontainer">'; ?>
				<textarea id="invoiceaddress" name="invoiceaddress" cols="60" rows="10"><?php print htmlspecials($invoiceaddress)?></textarea>
<?php	if(@$htmleditor=='froala') print '</div>'; ?>
				</td>
			  </tr>
			  <tr>
				<td align="right"><strong>Invoice Footer:</strong></td>
				<td align="left">
<?php	if(@$htmleditor=='froala') print '<div id="invoicefooterdiv" class="htmleditorcontainer">'; ?>
				<textarea id="invoicefooter" name="invoicefooter" cols="90" rows="10"><?php print htmlspecials($invoicefooter)?></textarea>
<?php	if(@$htmleditor=='froala') print '</div>'; ?>
				</td>
			  </tr>
			  <tr id="ps1"<?php if($packingslipuseinvoice!=0) print ' style="display:none"'?>>
				<td align="right"><strong>Packing Slip Header:</strong></td>
				<td align="left">
<?php	if(@$htmleditor=='froala') print '<div id="packingslipheaderdiv" class="htmleditorcontainer">'; ?>
				<textarea id="packingslipheader" name="packingslipheader" cols="90" rows="10"><?php print htmlspecials($packingslipheader)?></textarea>
<?php	if(@$htmleditor=='froala') print '</div>'; ?>
				</td>
			  </tr>
			  <tr id="ps2"<?php if($packingslipuseinvoice!=0) print ' style="display:none"'?>>
				<td align="right"><strong>Packing Slip Address:</strong></td>
				<td align="left">
<?php	if(@$htmleditor=='froala') print '<div id="packingslipaddressdiv" class="htmleditorcontainer">'; ?>
				<textarea id="packingslipaddress" name="packingslipaddress" cols="60" rows="10"><?php print htmlspecials($packingslipaddress)?></textarea>
<?php	if(@$htmleditor=='froala') print '</div>'; ?>
				</td>
			  </tr>
			  <tr id="ps3"<?php if($packingslipuseinvoice!=0) print ' style="display:none"'?>>
				<td align="right"><strong>Packing Slip Footer:</strong></td>
				<td align="left">
<?php	if(@$htmleditor=='froala') print '<div id="packingslipfooterdiv" class="htmleditorcontainer">'; ?>
				<textarea id="packingslipfooter" name="packingslipfooter" cols="90" rows="10"><?php print htmlspecials($packingslipfooter)?></textarea>
<?php	if(@$htmleditor=='froala') print '</div>'; ?>
				</td>
			  </tr>
			</table>
				</td>
			  </tr>
<?php		}else{ ?>
			  <tr>
				<td align="right"><strong><?php print $yyMessag?>:</strong></td>
				<td align="left">
<?php	if(@$htmleditor=='froala') print '<div id="textareadiv'.($index+1).'" class="htmleditorcontainer">'; ?>
				<textarea id="emtextarea<?php print ($index+1)?>" name="emtextarea<?php print ($index+1)?>" cols="90" rows="15"><?php print htmlspecials($themessage)?></textarea>
<?php	if(@$htmleditor=='froala') print '</div>'; ?>
				</td>
			  </tr>
<?php		}
		} ?>
			  <tr>
                <td width="100%" colspan="2" align="center"><br /><input type="submit" value="<?php print $yySubmit?>" />&nbsp;<input type="reset" value="<?php print $yyReset?>" />&nbsp;<input type="button" value="<?php print $yyCancel?>" onclick="document.location='adminemailmsgs.php?id=<?php print getpost('id')?>'" /><br />&nbsp;</td>
			  </tr>
			  <tr>
                <td width="100%" colspan="2" align="center"><br />
                          <a href="admin.php"><strong><?php print $yyAdmHom?></strong></a><br />
                          &nbsp;</td>
			  </tr>
            </table>
		  </form>
		  </td>
        </tr>
      </table>
<?php
	if(@$htmleditor=='ckeditor'){
		$pathtovsadmin=dirname(@$_SERVER['PHP_SELF']);
		print '<script>function loadeditors(){';
		$streditor="var emtextarea=CKEDITOR.replace('emtextarea',{extraPlugins : 'stylesheetparser,autogrow',autoGrow_maxHeight : 800,removePlugins : 'resize', toolbarStartupExpanded : false, toolbar : 'Basic', filebrowserBrowseUrl :'ckeditor/filemanager/browser/default/browser.html?Connector=".$pathtovsadmin."/ckeditor/filemanager/connectors/php/connector.php',filebrowserImageBrowseUrl : 'ckeditor/filemanager/browser/default/browser.html?Type=Image&Connector=".$pathtovsadmin."/ckeditor/filemanager/connectors/php/connector.php',filebrowserFlashBrowseUrl :'ckeditor/filemanager/browser/default/browser.html?Type=Flash&Connector=".$pathtovsadmin."/ckeditor/filemanager/connectors/php/connector.php',filebrowserUploadUrl:'".$pathtovsadmin."/ckeditor/filemanager/connectors/php/upload.php?Type=File',filebrowserImageUploadUrl:'".$pathtovsadmin."/ckeditor/filemanager/connectors/php/upload.php?Type=Image',filebrowserFlashUploadUrl:'".$pathtovsadmin."/ckeditor/filemanager/connectors/php/upload.php?Type=Flash'});\r\n";
		$streditor.="emtextarea.on('instanceReady',function(event){var myToolbar='Basic';event.editor.on( 'beforeMaximize', function(){if(event.editor.getCommand('maximize').state==CKEDITOR.TRISTATE_ON && myToolbar != 'Basic'){emtextarea.setToolbar('Basic');myToolbar='Basic';emtextarea.execCommand('toolbarCollapse');}else if(event.editor.getCommand('maximize').state==CKEDITOR.TRISTATE_OFF && myToolbar != 'Full'){emtextarea.setToolbar('Full');myToolbar='Full';emtextarea.execCommand('toolbarCollapse');}});event.editor.on('contentDom', function(e){event.editor.document.on('blur', function(){if(!emtextarea.isToolbarCollapsed){emtextarea.execCommand('toolbarCollapse');emtextarea.isToolbarCollapsed=true;}});event.editor.document.on('focus',function(){if(emtextarea.isToolbarCollapsed){emtextarea.execCommand('toolbarCollapse');emtextarea.isToolbarCollapsed=false;}});});emtextarea.fire('contentDom');emtextarea.isToolbarCollapsed=true;});\r\n";
		if($theid=='invoiceheaders'){
			print str_replace('emtextarea','invoiceheader',$streditor);
			print str_replace('emtextarea','invoiceaddress',$streditor);
			print str_replace('emtextarea','invoicefooter',$streditor);
			print str_replace('emtextarea','packingslipheader',$streditor);
			print str_replace('emtextarea','packingslipaddress',$streditor);
			print str_replace('emtextarea','packingslipfooter',$streditor);
		}else{
			if(($adminlangsettings & 4096)==4096) $maxlangs=$adminlanguages; else $maxlangs=0;
			for($index=1; $index <= $maxlangs+1; $index++)
				print str_replace('emtextarea','emtextarea' . $index,$streditor);
		}
		print '}window.onload=function(){loadeditors();}</script>';
	}elseif(@$htmleditor=='froala'){
		if(($adminlangsettings & 4096)==4096) $maxlangs=$adminlanguages; else $maxlangs=0;
		if($theid=='invoiceheaders'){
			displayfroalaeditor('invoiceheader',$yyMessag,'.on(\'froalaEditor.focus\',function(){expandckeditor("invoiceheaderdiv");})');
			displayfroalaeditor('invoiceaddress',$yyMessag,'.on(\'froalaEditor.focus\',function(){expandckeditor("invoiceaddressdiv");})');
			displayfroalaeditor('invoicefooter',$yyMessag,'.on(\'froalaEditor.focus\',function(){expandckeditor("invoicefooterdiv");})');
			displayfroalaeditor('packingslipheader',$yyMessag,'.on(\'froalaEditor.focus\',function(){expandckeditor("packingslipheaderdiv");})');
			displayfroalaeditor('packingslipaddress',$yyMessag,'.on(\'froalaEditor.focus\',function(){expandckeditor("packingslipaddressdiv");})');
			displayfroalaeditor('packingslipfooter',$yyMessag,'.on(\'froalaEditor.focus\',function(){expandckeditor("packingslipfooterdiv");})');
		}else{
			for($index=1; $index <= $maxlangs+1; $index++)
				displayfroalaeditor('emtextarea'.$index,$yyMessag,'.on(\'froalaEditor.focus\',function(){expandckeditor("textareadiv'.$index.'");})');
		}
	}
}elseif(getpost('posted')=='1' && $success){ ?>
      <table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
        <tr>
          <td width="100%">
			<table width="100%" border="0" cellspacing="0" cellpadding="2">
			  <tr> 
                <td width="100%" colspan="2" align="center"><br /><strong><?php print $yyUpdSuc?></strong><br /><br /><?php print $yyNowFrd?><br /><br />
                        <?php print $yyNoAuto?> <a href="adminemailmsgs.php"><strong><?php print $yyClkHer?></strong></a>.<br />
                        <br />&nbsp;<br />&nbsp;
                </td>
			  </tr>
			</table></td>
        </tr>
      </table>
<?php
}elseif(getpost('posted')=='1'){ ?>
      <table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
        <tr>
          <td width="100%">
			<table width="100%" border="0" cellspacing="0" cellpadding="2">
			  <tr> 
                <td width="100%" colspan="2" align="center"><br /><span style="color:#FF0000;font-weight:bold"><?php print $yyOpFai?></span><br /><br /><?php print $errmsg?><br /><br />
				<a href="javascript:history.go(-1)"><strong><?php print $yyClkBac?></strong></a><p>&nbsp;</p><p>&nbsp;</p></td>
			  </tr>
			</table></td>
        </tr>
      </table>
<?php
}else{
?>
<script>
<!--
function mrec(id) {
	// document.mainform.id.value=id;
}
// -->
</script>
<h2><?php print $yyAdmEmm?></h2>
		  <form name="mainform" method="post" action="adminemailmsgs.php">
			<input type="hidden" name="posted" value="1" />
			<input type="hidden" name="act" value="modify" />
			<input type="hidden" name="id" id="idset" value="" />
			<table class="cobtbl" width="100%" border="0" cellspacing="1" cellpadding="3">
			  <tr>
				<td class="cobhl" colspan="3" align="center"><strong><?php
					print $yyHTMLic . ' ';
					if(@$htmlemails) print $yyOn; else print $yyNot . " " . $yyOn; ?></strong></td>
			  </tr>
			  <tr>
				<td class="cobhl" align="right" width="30%">Order Status Email:</td>
				<td class="cobll"><input type="button" value="Edit Email" onclick="document.getElementById('idset').value='orderstatusemail';document.forms.mainform.submit()" /></td>
				<td class="cobll">The email message that customers receive when you change the status of an order. The different status types that receive an email can be configured on the <a href="adminordstatus.php">Admin Order Status</a> page.</td>
			  </tr>
			  <tr>
				<td class="cobhl" align="right"><?php print $yyEmlHdr?>:</td>
				<td class="cobll"><input type="button" value="Edit Email" onclick="document.getElementById('idset').value='emailheaders';document.forms.mainform.submit()" /></td>
				<td class="cobll">The email message that is sent to the customer after a successful transaction. The parameter &quot;%messagebody%&quot; will be replaced by the products ordered.</td>
			  </tr>
			  <tr>
				<td class="cobhl" align="right">Receipt Headers / Footers:</td>
				<td class="cobll"><input type="button" value="Edit Email" onclick="document.getElementById('idset').value='receiptheaders';document.forms.mainform.submit()" /></td>
				<td class="cobll">This is the message that is displayed on the thanks page after a successful transaction. The parameter &quot;%messagebody%&quot; will be replaced by the products ordered.</td>
			  </tr>
			  <tr>
				<td class="cobhl" align="right">Invoice &amp; Packing Slip Headers / Footers:</td>
				<td class="cobll"><input type="button" value="Edit Email" onclick="document.getElementById('idset').value='invoiceheaders';document.forms.mainform.submit()" /></td>
				<td class="cobll">This is where you can set the headers, footers and company address for the printable receipt and packing slips.</td>
			  </tr>
			  <tr>
				<td class="cobhl" align="right"><?php print $yyDrSppr . ' ' . $yyEmlHdr?>:</td>
				<td class="cobll"><input type="button" value="Edit Email" onclick="document.getElementById('idset').value='dropshipheaders';document.forms.mainform.submit()" /></td>
				<td class="cobll">This is the email message that a drop shipper will receive after a successful order. The %messagebody% parameter will be replaced by the line items that relate to that drop shipper.</td>
			  </tr>
			  <tr>
				<td class="cobhl" align="right">Gift Certificate Email:</td>
				<td class="cobll"><input type="button" value="Edit Email" onclick="document.getElementById('idset').value='giftcertificate';document.forms.mainform.submit()" /></td>
				<td class="cobll">This is the email message that someone will receive when a Gift Certificate is purchased for them.</td>
			  </tr>
			  <tr>
				<td class="cobhl" align="right">Gift Certificate Sender:</td>
				<td class="cobll"><input type="button" value="Edit Email" onclick="document.getElementById('idset').value='giftcertsender';document.forms.mainform.submit()" /></td>
				<td class="cobll">This is the email message that someone will receive when they send someone a Gift Certificate.</td>
			  </tr>
			  <tr>
				<td class="cobhl" align="right">Notify Back In Stock Email:</td>
				<td class="cobll"><input type="button" value="Edit Email" onclick="document.getElementById('idset').value='notifybackinstock';document.forms.mainform.submit()" /></td>
				<td class="cobll">This is the email message that someone will receive when an item goes back in stock and they have requested notification.</td>
			  </tr>
			  <tr>
				<td class="cobhl" align="right">Abandoned Cart Email:</td>
				<td class="cobll"><input type="button" value="Edit Email" onclick="document.getElementById('idset').value='abandonedcart';document.forms.mainform.submit()" /></td>
				<td class="cobll">This is the email message that you can send to prompt a customer to complete an abandoned checkout.</td>
			  </tr>
			  <tr>
				<td class="cobhl" align="right">Ship Line Item:</td>
				<td class="cobll"><input type="button" value="Edit Email" onclick="document.getElementById('idset').value='shiplineitem';document.forms.mainform.submit()" /></td>
				<td class="cobll">This is the email message that you can send when a single line item is shipped.</td>
			  </tr>
			  <tr> 
                <td class="cobll" colspan="3" align="center"><br />
                          <a href="admin.php"><strong><?php print $yyAdmHom?></strong></a><br />&nbsp;</td>
			  </tr>
			</table>
		  </form>
<?php
}
?>
