Location: PHPKode > projects > MembersGear > membersgear/templates/admin_canned_email.tpl
{$ADMIN_HEADER}
{literal}
<script type="text/javascript">
         function Change(value)
          {
                 for (i=0;i<document.getElementsByName('user_email_config').length;i++) {
                    document.getElementsByName('user_email_config')[i].style.display = ((value & 1) == 1)?'':'none';
                  }
                  
                  for (i=0;i<document.getElementsByName('admin_email_config').length;i++) {
                    document.getElementsByName('admin_email_config')[i].style.display = ((value & 2) == 2)?'':'none';
                  }
                //alert('here from '+ value + 'element is ' + element);
          }
</script>

{/literal}
  <div id="content" class="setdiv">
    <div id="full-contentdiv">
        <div class="righttop">
            <h2 align="center">
                
                {if $IsEdit neq ''}
                    Edit Canned Email
                    {assign var="action" value="update"}
                {else}
                    Create Canned Email
                    {assign var="action" value="insert"}
                {/if}
            </h2>
        </div>
        <div class="whole-page clear">
           
           <form name="frmCannedEmail" id="frmCannedEmail" action="admin_canned_email.php?action={$action}" method="post">  
              
              <div class="borderless borderless-1">
                
            
              <table border="0" cellpadding="0" cellspacing="0" style="width:800px" align="center">
                    <tr>
                            <td colspan="2">
                                    <div class="horizontal-line">
                                    </div>
                            </td>
                    </tr>
                    
                    <tr>
                            
                            <td class="right-side-text-borderless space" valign="top"><label>
                                Canned Email Name <label class="star">*</label>
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                <input type="text" class="txtcss" id="txtName" name="txtName" style="width: 580px ! important;" value="{$data[0].name}" {if $IsEdit neq ''}readonly=""{/if}>
                            </td>
                    </tr>
                    
                    <tr>
                            <td class="right-side-text-borderless space" valign="top" id=""><label>
                                Send Message To <label class="star">*</label>
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                <select class="" style="width: 588px ! important;" id="ddlSendMessageTo" name="ddlSendMessageTo" onchange="Change(this.value)">
                                         <option value="1" {if $data[0].sendmessageto eq 'User'}selected=""{/if}>User</option>
                                         <option value="2" {if $data[0].sendmessageto eq 'Admin'}selected=""{/if}>Administrator</option>
                                         <option value="3" {if $data[0].sendmessageto eq 'Both'}selected=""{elseif $IsEdit eq ''}selected=""{/if}>Both</option>
                                </select>
                            </td>
                    </tr>
                    
                    <tr style="display:none;">
                            <td class="right-side-text-borderless space" valign="top" id=""><label>
                                Status <label class="star">*</label>
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                <select class="" style="width: 588px ! important;" id="ddlStatus" name="ddlStatus" onchange="">
                                         <option value="1" {if $data[0].status eq '1'}selected=""{/if}>Active</option>
                                         <option value="0" {if $data[0].status eq '0'}selected=""{/if}>InActive</option>
                                </select>
                            </td>
                    </tr>
                    
                    <tr>
                            
                            <td class="right-side-text-borderless space" valign="top"><label>
                                Sender Name <label class="star">*</label>
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                <input type="text" class="txtcss" id="txtSenderName" name="txtSenderName" style="width: 580px ! important;" value="{$data[0].sender_name}">
                                <div class="comment-div" style="width:565px !important">
                                         Sender name - administrator's name by default
                                </div>
                            </td>
                    </tr>
                    
                     <tr>
                            
                            <td class="right-side-text-borderless space" valign="top"><label>
                                Sender Email <label class="star">*</label>
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                <input type="text" class="txtcss" id="txtSenderEmail" name="txtSenderEmail" style="width: 580px ! important;" value="{$data[0].sender_email}">
                                <div class="comment-div" style="width:565px !important">
                                         Sender Email - administrator's Email by default
                                </div>
                            </td>
                    </tr>
                    
                    <tr id="user_email_config" name="user_email_config">
                            <td class="right-side-text-borderless space" valign="top" id=""><label>
                              User Email Format <label class="star">*</label>
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                <select class="" style="width: 588px ! important;" id="ddlUserEmailFormat" name="ddlUserEmailFormat" onchange="">
                                         <option value="HTML" {if $data[0].email_format eq 'HTML'}selected=""{/if}>HTML</option>
                                         <option value="Text" {if $data[0].email_format eq 'Text'}selected=""{/if}>TEXT</option>
                                </select>
                            </td>
                    </tr>
                    
                    <tr  id="user_email_config" name="user_email_config">
                            
                            <td class="right-side-text-borderless space" valign="top"><label>
                              User Email Subject <label class="star">*</label>
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                <input type="text" class="txtcss" id="txtUserEmailSubject" value="{$data[0].email_subject}" name="txtUserEmailSubject" style="width: 580px ! important;" onmouseover="className='txthover';" onmouseout="className='txtcss';">
                                 <div class="comment-div" style="width:565px !important">
                                       <strong>You may use the following attributes in any of your Emails subject</strong><br/>
                                       first name-[firstname]<br/>
                                       last name-[lastname]<br/>
                                       username-[username]<br/> 
                                       product name-[productname]
                                </div>
                            </td>
                            
                    </tr>

                    <tr  id="user_email_config" name="user_email_config">
                        <td class="right-side-text-borderless space" valign="top"><label>
                                Email Copy To 
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                <textarea class="txtareacss" id="txtUserEmailCopyTo" name="txtUserEmailCopyTo" style="width: 580px ! important;">{$data[0].email_copy_to}</textarea>
                                <div class="comment-div" style="width:565px !important">
                                         List of Emails, comma separated
                                </div>
                            </td>
                    </tr>
                    
                    <tr  id="user_email_config" name="user_email_config">
                            <td class="right-side-text-borderless space" valign="top"><label>
                               User Email Message <label class="star">*</label>
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                 <textarea class="txtareacss" id="txtUserEmailMessage" name="txtUserEmailMessage" rows="5" style="width: 580px ! important;">{$data[0].email_message}</textarea>
                            </td>
                    </tr>
                    
                    <tr id="admin_email_config" name="admin_email_config">
                            <td class="right-side-text-borderless space" valign="top" id=""><label>
                               Admin Email Format <label class="star">*</label>
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                <select class="" style="width: 588px ! important;" id="ddlAdminEmailFormat" name="ddlAdminEmailFormat" onchange="">
                                         <option value="HTML" {if $data[0].admin_email_format eq 'HTML'}selected=""{/if}>HTML</option>
                                         <option value="Text" {if $data[0].admin_email_format eq 'Text'}selected=""{/if}>TEXT</option>
                                </select>
                            </td>
                    </tr>
                    
                    <tr id="admin_email_config" name="admin_email_config">
                            
                            <td class="right-side-text-borderless space" valign="top"><label>
                              Admin Email Subject <label class="star">*</label>
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                <input type="text" class="txtcss" id="txtAdminEmailSubject" value="{$data[0].admin_email_subject}" name="txtAdminEmailSubject" style="width: 580px ! important;" onmouseover="className='txthover';" onmouseout="className='txtcss';">
                               <div class="comment-div" style="width:565px !important">
                                       <strong>You may use the following attributes in any of your admin Emails subject</strong><br/>
                                       first name-[firstname]<br/>
                                       last name-[lastname]<br/>
                                       username-[username]<br/> 
                                       product name-[productname]
                                </div>
                            </td>
                    </tr>
                    
                    <tr id="admin_email_config" name="admin_email_config">
                            <td class="right-side-text-borderless space" valign="top"><label>
                               Admin Email Message <label class="star">*</label>
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                 <textarea class="txtareacss" id="txtAdminEmailMessage" name="txtAdminEmailMessage" rows="5" style="width: 580px ! important;">{$data[0].admin_email_message}</textarea>
                            </td>
                    </tr>
                    
                     <tr>
                            <td class="right-side-text-borderless space" valign="top"><label>
                               Email Attachment 
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                                 
                                 {php}
                                        require_once "../includes/directorydropdownlist/get_dir_list.php";
                                 {/php}
                             <div class="comment-div" style="width:565px !important">
                                 Please add your attachment file into root dir/email_attachements/ 
                             </div>     
                            </td>
                    </tr>
                    {if $data[0].sendmessageto eq 'User'}
                        {assign var="SendTo" value="1"}
                    {elseif $data[0].sendmessageto eq 'Admin'}
                        {assign var="SendTo" value="2"}
                    {elseif $data[0].sendmessageto eq 'Both'}
                        {assign var="SendTo" value="3"}
                    {/if}                                              
                    {if $IsEdit neq ''}
                        <input type="hidden" id="hdnSendTo" name="hdnSendTo" value="{$SendTo}">
                        <input type="hidden" id="hdnID" name="hdnID" value="{$data[0].id}">
                        {php}
                             echo "<script language=javaScript>";
                             echo "Change(document.getElementById('hdnSendTo').value);";
                             echo "</script>";
                        {/php}
                    {/if}
                    
                    <tr>
                        <td>
                        </td>
                        <td colspan="">
                            <div  class="comment-div" style="width:565px !important">
                                <strong>You may use the following attributes in any of your Emails:</strong><br/>
                                [username] - username<br/>
                                [password] - password<br/>
                                [email] - user Email<br/>
                                [firstname] - first name<br/>
                                [lastname] - last name<br/>
                                [productname] - product name<br/> 
                                [product_url] - product url<br/> 
                                [unsubscribe_link] - unsubscribe link<br/>
                                [today_date] - date when Email sent<br/>
                                [today_time] - time when Email sent<br/>
                                [today_datetime] - date and time when Email sent<br/>
                                [validateuser_link] - validate user link<br/>
                            </div>
                        </td>
                    </tr>
                      
                    <tr>
                        <td colspan="2">
                             <div class="horizontal-line">
                                    </div>   
                        </td>
                    </tr>
                  
                    <tr>
                         <td/>
                         <td class="buttontd">
                                <input type="submit" class="btncss" name="submit" {if $IsEdit eq 'yes'}value="Save"{else}value="Submit"{/if}>&nbsp;&nbsp;&nbsp;
                                <input type="button" class="btncss" name="btnBack" value="Cancel" style="width:60px !important" onclick="window.history.go(-1);">
                         </td>
                    </tr>
              
              </table>
            
        </div>
           </form>
         {literal}
           <script language="JavaScript" type="text/javascript">
                //You should create the validator only after the definition of the HTML form
                  var frmvalidator  = new Validator("frmCannedEmail");

                  frmvalidator.EnableMsgsTogether();
                  //frmvalidator.EnableOnPageErrorDisplaySingleBox();
                
                  frmvalidator.addValidation("txtName","req","Please enter Canned Email Name.");
                  frmvalidator.addValidation("txtName","maxlen=100",    "Maximum length for Canned Email Name is 100 character.");
                  frmvalidator.addValidation("txtName","alnum_s","Enter only alphabetic/numeric characters in Canned Email Name.");
                  
                  frmvalidator.addValidation("txtSenderName","req","Please enter Sender Name.");
                  frmvalidator.addValidation("txtSenderName","maxlen=45",    "Maximum length for Sender Name is 45 character.");
                  frmvalidator.addValidation("txtSenderName","alnum_s","Enter only alphabetic/numeric characters Sender Name.");
                  
                  frmvalidator.addValidation("txtSenderEmail","req","Please enter Sender Email.");
                  frmvalidator.addValidation("txtSenderEmail","maxlen=45","Maximum length for Sender Email is 45 character.");
                  frmvalidator.addValidation("txtSenderEmail","email","Invalid Sender Email.");
                  
                  /************************User Field Validation**************************************/
                  frmvalidator.addValidation("txtUserEmailSubject","req","Please enter User Email Subject.","document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '3' || document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '1'"); 
                  frmvalidator.addValidation("txtUserEmailSubject","maxlen=100","Maximum length for User Email Subject is 100 character.");
                  
                 /* frmvalidator.addValidation("txtUserEmailCopyTo","req","Please enter User Email copy to.","document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '3' || document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '1'"); */
                  //frmvalidator.addValidation("txtUserEmailCopyTo","email","Invalid Email enter.","document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '3' || document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '1'");
                  
                  frmvalidator.addValidation("txtUserEmailMessage","req","Please enter User Email Message.","document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '3' || document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '1'"); 
                  
                  /**************************Admin Field Validation***********************************************/
                  frmvalidator.addValidation("txtAdminEmailSubject","req","Please enter Admin Email Subject.","document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '3' || document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '2'"); 
                  frmvalidator.addValidation("txtAdminEmailSubject","maxlen=100","Maximum length for User Email Subject is 100 character.");
                  
                  frmvalidator.addValidation("txtAdminEmailMessage","req","Please enter Admin Email Message.","document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '3' || document.getElementById('ddlSendMessageTo').options[document.getElementById('ddlSendMessageTo').selectedIndex].value == '2'");
                  frmvalidator.setAddnlValidationFunction("emailvalidation"); 
                  // frmvalidator.addValidation("dirlist","dontselect=''","Please select Email attachment.");
                  
                  
                  /*
                  
                  frmvalidator.addValidation("txtFieldDescription","req","Please enter field description.");
                  frmvalidator.addValidation("txtFieldDescription","maxlen=100","Max length for field description is 100 character.");
                  
                  frmvalidator.addValidation("ddlSQLFieldType","dontselect=''","Please select  SQL field type.");
                  
                  
                  frmvalidator.addValidation("txtFieldSize","req","Please enter field size.");
                  frmvalidator.addValidation("txtFieldSize","maxlen=20",    "Max length for field name is 20 character.");
                  frmvalidator.addValidation("txtFieldSize","num","Enter only digits in field size.");
                  
                  
                  frmvalidator.addValidation("txtDefaultValue","req","Please enter field default value.");
                  
                  frmvalidator.addValidation("ddlDisplaySignup","dontselect=''","Please select display in signup form.");
                  
                  frmvalidator.addValidation("ddlDisplayProfile","dontselect=''","Please select display in profile form.");
                  
                  frmvalidator.addValidation("ddlValidateFunction","dontselect=''","Please select validate function.");
                  */
                 
                 
                 function emailvalidation()
                 {
                      var frm = document.forms["frmCannedEmail"];
                      var EmailCopyTo = document.getElementById('txtUserEmailCopyTo');
                      var SplitEmailList = EmailCopyTo.value.split(',');
                      
                      //alert(SplitEmailList.length);
                      if(SplitEmailList[SplitEmailList.length] == null )
                            counter = SplitEmailList.length - 1;
                      //else
                           // counter = SplitEmailList.length;
                           
                         
                      /* if(counter==1)
                        {
                          if(trim(SplitEmailList[0])=="")
                           {
                     
                             alert("please enter valid email.");
                             EmailCopyTo.focus(); 
                             return false;
                           }
                            EmailCopyTo.value=SplitEmailList[0];
                        }
                       else
                       {  */   
                              var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                              var error="";
                              var emails="";
                              for(i=0;i<=counter;i++)
                               {
                                  //alert(SplitEmailList[i]);
                                  if(trim(SplitEmailList[i])!="" && trim(SplitEmailList[i]).length!=0)
                                   {
                                      if(reg.test(trim(SplitEmailList[i])) == false)
                                           error=error+"invalid Email "+SplitEmailList[i]+".\n";
                                      else
                                        {     
                                           emails+=trim(SplitEmailList[i]);
                                           if(i!=counter)
                                             emails+=","; 
                                        }      
                                   }
                                      
                               }
                               if(error!="")
                               {
                                   alert(error);
                                   EmailCopyTo.focus();
                                   return false; 
                               }
                              else
                               {     
                               
                                  
                                  if(emails!="")
                                   {  
                                      var atpos = emails.length-1;
                                       var lastChar=emails.substring(atpos);
                                      if(lastChar==',')
                                       {
                                         emails = emails.substring(0, atpos);
                                       } 
                                      EmailCopyTo.value=emails; 
                                      return true;
                                   }
                                  else
                                   {
                                    // alert("please enter valid email.");
                                     EmailCopyTo.value="";
                                       EmailCopyTo.focus();
                                     return true;
                                   }   
                               }
                      // }       
                                 
                            
                 }

 
           </script>
          {/literal}
    </div>
</div>
</div>
{$ADMIN_FOOTER}
Return current item: MembersGear