<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$language.lblAdmin} : {$language.lblEmailTemplats}</title>
{include file='CommonStyles.tpl'}
{include file='CommonJavaScript.tpl'}
<link href="{$view_styles}/inner-formlisting.css" rel="stylesheet" type="text/css" />
<link href="{$view_styles}/email-template.css" rel="stylesheet" type="text/css" />
<link href="{$view_styles}/colorbox.css" rel="stylesheet" type="text/css" />
{include file='CommonCustomStyles.tpl'}
</head><body>
<div class="outer_container">
  {include file='CommonTop.tpl'}
  <!--End:Header Container-->
  <!--***********************************************************************START CONTAINER SECTION******************************************************-->
  <div class="content_container">      
    <!--End: Right Block-->
    <a id="jump-to-message"></a>
    <div class="content_wrapper">  
	{form->select name="brandID" value=$brandID options=$listBrand style="float:right;width:150px;margin-left:5px;padding:2px 5px"}			
    {include file='ContentLanguageOptions.tpl'}
    
      <h2>{$language.lblEmailTemplats}</h2>
     <label>{$language.lblCopyTemplates}</label>{form->select name="copybrandID" options=$copylistBrands style="width:150px;margin-left:5px;padding:2px 5px" caption="->{$language.lblSelect}" }	
	 {form->button name="copytemplates" class="button01" value="{$language.lblCopy}"}
      <!-- Inner Content Container starts-->
      <div class="inner_content_wrapper clearfix">
          <div id="common_message" ></div>
          
           <div class="etemplist">
          <ul>
			{foreach $emailTemplates item=emailTemplate key=i}  
            <li>{html->anchor id="templateGroup_$i" class="levl01 parentLevel{if $emailTemplateDetails.templateGroupID eq $i} {assign var="currentTemplateGroup" value=$language[$emailTemplate.0.groupLabel]} clps {/if}" content="{$language[$emailTemplate.0.groupLabel]}<span></span>"}
              <ul class="childLevel" {if $emailTemplateDetails.templateGroupID neq $i} style="display:none;" {/if}>
              	{assign var="templateCount" value=$emailTemplate|count} 
                {assign var="templateCounter" value=1} 
                {foreach $emailTemplate item=template}  
                {assign var="tid" value=$template.emailTempID}              
                <li>{html->anchor href="emailtemplate/index/action/preview/id/$tid/brandID/$brandID/" id="template_$tid" class="levl02 {if $tid eq $emailTempID} selected {/if}" caption=$language[$template.emailTemplateName]}</li>
                {assign var="templateCounter" value=$templateCounter+1} 
                {/foreach}                 
              </ul>
            </li>
            {/foreach}            
          </ul>
        </div>
        <div class="etempdetail">          
        {if $showDetailSection eq '1'}
        <div class="sec01">
			{if $currentAction eq 'preview'} 
			{html->anchor href="emailtemplate/index/action/edit/id/$emailTempID/brandID/$brandID/" caption="{$language.lblEdit}"  class="fixing_right button02"}            
			{/if} 
            <div class="left">
        	  <p class="tempname">{$language.lblEmailTemplate} : <span><strong>{$currentTemplateGroup}</strong> &raquo; {$language[$emailTemplateDetails.emailTemplateName]}</span></p>
        	  <p class="lstdt">{$language.lblTemplateLastUpdate}: <span>{$emailTemplateDetails.lastUpdatedDate|date_format:$settingsDateFormat} {$emailTemplateDetails.lastUpdatedDate|date_format:$settingsTimeFormat}</span></p>
              </div>
        	</div>
          	{if $currentAction eq 'preview'} 
            <div class="sec02">
        	  <p >{$language.lblSubject} :  <span>{$emailTemplateDetails.emailSubject|escape:html}</span></p>
        	  <p >{$language.lblFrom} :  <span>{$emailTemplateDetails.emailFromName} [{$emailTemplateDetails.emailFromEmail}]</span></p>
        	</div>
        	{/if}
            <div class="editing-sect {if $currentAction eq 'edit'} editing-sect-edit{/if}">
			 {form->hidden name="emailKey" value=$emailTemplateDetails.emailKey}
            {if $currentAction eq 'preview'}                       
            {$email_body}
            {else if $currentAction eq 'edit'}
            {form->start name="formEmailTemplate" action="" method="post"}            
            <div class="form_listing" > 
            {form->hidden name="emailTempID" value=$emailTemplateDetails.emailTempID}    	  
            {form->hidden name="emailTempDetID" value=$emailTemplateDetails.emailTempDetID}       	   	
            <!--section wrap :: Starts-->
            <div class="section_wrap clearfix">
                <div class="forlisting_fullwidth padding-l-100">
                    <ul>
                        <li class="selection clearfix">
                            <div class="leftside01 mandatory">{$language.lblnewsletterFromName}</div>
                            <div class="rightside01">
                                 {form->textbox name="emailFromName" value=$emailTemplateDetails.emailFromName class="textbox width_50per"  validate="required" error=$language.errFromName}
                            </div>
                        </li>
                        <li class="selection clearfix">
                            <div class="leftside01 mandatory">{$language.lblnewsletterFromEmail}</div>
                            <div class="rightside01">
                                 {assign var="errFromEmail" value=$language.errFromEmail}                  
                                 {assign var="errEnterValidEmailMsg" value=$language.errEnterValidEmailID}                
                                 {form->textbox value=$emailTemplateDetails.emailFromEmail name="emailFromEmail" class="textbox width_50per" validate="required~*email" error="$errFromEmail~*$errEnterValidEmailMsg"}                                
                            </div>
                        </li>
                        <li class="selection clearfix">
                            <div class="leftside01 mandatory">{$language.lblSubject} </div>
                            <div class="rightside01">
                              {form->textbox name="emailSubject" value=$emailTemplateDetails.emailSubject class="textbox width_50per" validate="required" error=$language.errSubject}
                            </div>
                        </li>
                        <li class="selection clearfix">
                            <div class="leftside01 mandatory">{$language.lblnewsLetterContentHtml}</div>
                            <div class="rightside01">
                              {form->editor  name="emailHtml" value=$emailTemplateDetails.emailHtml rows="20" cols="40" mode="simple" uploads="editor-images/" skin=2 validate="required" error=$language.errEmailBody relative_urls="true"}                                
                            </div>
                        </li>
                        <li class="selection clearfix">
                            <div class="leftside01"> {$language.lblnewsLetterContentText}</div>
                            <div class="rightside01">
                                {form->textarea name="emailText" value=$emailTemplateDetails.emailText class="textbox width_80per" rows="5" cols="5"}                
                            </div>
                        </li>                        
                    </ul>
                </div>
            </div>           
			</div>               
            {/if} 
            </div>
          {if $currentAction eq 'preview'}  
          <div class="sec03 clearfix">
         {$language.lblEmailAddress}  
         {form->start name="testEmailTemplate" action="" method="post" class="send-test-email"}
         {form->hidden name="emailTempID" value=$emailTemplateDetails.emailTempID}  
         {form->textbox name="testEmailId" class="textbox"}
         {form->button name="testMail" class="button01" value="{$language.lblSendTestMail}"}  
         {form->close}          
          </div>
          {else if $currentAction eq 'edit'}
          <div class="sec03 clearfix" align="center">
			{form->submit name="submitEmailTemplate" class="button01" value="{$language.lblSave}"} {$language.lblOr}            {html->anchor href="emailtemplate/index/action/preview/id/$emailTempID/brandID/$brandID/" tabindex="1" caption="{$language.lblCancel}"} 
            {form-> close}  
            {form->editor_script names="emailHtml"}{form->validate_script form="formEmailTemplate"} 
		  </div>	  
          {/if} 
        {else}
        <div class="select-template-msg">{$language.lblSelectATemplate}</div>
        {/if}
		</div>
    <!--End: left Block-->
  </div>
  </div>
  </div>
  <!--******************************************************END CONTAINER SECTION******************************************************-->
  <!--End:Content Container-->
  {include file='CommonBottom.tpl'} 
</div>
<!--End:Outer Container-->
{include file='CommonJavaScriptBottom.tpl'}
{form->basepath_script}
{form->rootpath_script}
<script type="text/javascript">
var msgTestMailSent = "{$language.msgTestMailSent}";
var errEnterValidEmail = "{$language.errEnterValidEmail}" ;
var errTestMailSendingFailed = "{$language.errTestMailSendingFailed}";
var errInvalideRequest = "{$language.errInvalideRequest}";
var lblAlertOk="{$language.lblAlertOk}";
var lblAlertCancel="{$language.lblAlertCancel}";
var lblAlertYes="{$language.lblAlertYes}";
var lblAlertNo="{$language.lblAlertNo}";
var lblAlert="{$language.lblAlert}";
var currentAction="{$currentAction}";
$(document).ready(function(){
$("#brandID").change(function(){ 
	var id			=	$('#brandID').val();
	var emailKey	=	$('#emailKey').val();
	var new_emailTempID = '';
	$.ajax({
		type: "GET",
		url: GLOBAL_BASE_PATH+"/emailtemplate/ajaxBrandChange/brandID/"+id+"/emailKey/"+emailKey+"/",
		success: function(msg){ 
		new_emailTempID = msg;
		window.location.href = GLOBAL_BASE_PATH+"/emailtemplate/index/action/"+currentAction+"/id/"+ new_emailTempID+"/brandID/"+ id+"/";
		 }
	 }); 
	 
	
});
$("#copytemplates").click(function(){ 
	if($('#copybrandID').val()!="") {
	var brandID			=	$('#brandID').val();
	var copybrandID		=	$('#copybrandID').val();
	$.ajax({
		type: "GET",
		url: GLOBAL_BASE_PATH+"/emailtemplate/ajaxCopyTemplates/brandID/"+brandID+"/copybrandID/"+copybrandID+"/",
		success: function(msg){ 
			location.reload();
		 }
	 });
	} 
});
});
</script>
<script type="text/javascript" src="{$view_javascript}/message.plugin.js"></script>
<script type="text/javascript" src="{$view_javascript}/jquery.colorbox.js"></script>
<script type="text/javascript" src="{$view_javascript}/emailtemplate.page.js"></script>
<script type="text/javascript" src="{$common_js}/validate.plugin.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
	{literal}	
$("a.fancylink").colorbox({iframe:true, innerWidth:"80%", innerHeight:"80%"});	{/literal}				   
	$('.template_grid ul li:last-child').addClass('last'); 
}); 
</script>
{html->messages_script id="common_message"}
</body>
</html>
