<%set set_focus = 'myform.tpl_dir'%>
<%set book_mark = 'tpl_email'%>
<%include include_header.html%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="82%">
  <tr>
    <td rowspan="2" bgcolor="#008000" height="100%" width="1"><img src="<%image_url%>/pics/1pixel.gif" width="1" height="1"></td>
    <td colspan="3" height="3%" bgcolor="#E8EAD0" valign="top"><%include admin_template_include_menu.html%></td>
    <td rowspan="2" bgcolor="#008000" height="100%" width="1"><img src="<%image_url%>/pics/1pixel.gif" width="1" height="1"></td>
  </tr>
  <tr>
    <td height="97%" colspan="3" valign="top">
      <table width="99%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
        <tr>
          <td><img src="<%image_url%>/pics/1pixel.gif" width="1" height="3"></td>
        </tr>
        <tr>
          <td>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#336600" style="border: 1px solid #C5E1A3">
              <tr class="bold_white">
                <td height="20"><img src="<%image_url%>/icons/glist.gif" hspace="2" vspace="0" align="texttop">Edit Templates</td>
                <td align="right"><img src="<%image_url%>/icons/close.gif" width="17" height="16" border=0></td>
              </tr>
            </table>
            <form name=myform action="glist.cgi" method=post>
            <table width="" border="0" cellspacing="0" cellpadding="0" align=center>
                <tr valign="middle" class=body>
                  <td height="0" class=body><br />
                    <%GList::Tools::default_email_editor%>
                    <%if bsave%>
                      <%if save_as%>
                        <%set template_file = $save_as%>
                      <%else%>
                        <%set template_file = $tpl_file%>
                      <%endif%>
                      <%if demo%>
                        <%set msg = '<font color="red">Template Editor has been disabled in the demo!</font>'%>
                      <%else%>
                      <%if tpl_to eq '' or tpl_from eq '' or tpl_subject eq '' or tpl_body eq ''%>
                        <%set error = '<font color="red">Required fields are not specified!</font>'%>
                      <%else%>
                      <%GT::Mail::Editor::tpl_save(
                         dir      => $tpl_dir,
                         template => $selected_dir,
                         file     => $template_file,
                         header   => To      => $tpl_to,
                         header   => Subject => $tpl_subject,
                         header   => From    => $tpl_from,
                         extra_headers => $extra_headers,
                         body     => $tpl_body
                      )%>
                      <%endif%>
                      <%if error%>
                        <%set msg = $error%>
                        <%set color = red%>
                      <%else%>
                        <%set msg = "Template saved successfully."%>
                      <%endif%>
                      <%endif%>
                    <%elsif bload%>
                      <%GT::Mail::Editor::tpl_load(
                        dir      => $tpl_dir,
                        template => $selected_dir,
                        file     => $tpl_file,
                        header   => To,
                        header   => From,
                        header   => Subject
                      )%>
                        <%if error%>
                          <%set msg = $error%>
                          <%set color = red%>
                        <%else%>
                          <%set loaded = 1%>
                        <%endif%>
                    <%endif%>
                    <table border="0" cellspacing="2" cellpadding="2" align=center>
                      <tr class=body>
                        <td class=body>Templates Set</td>
                        <td class=body>
                          <%dir_select%>
                          <input name="bchange" value="Change" type=submit class=button />
                        </td>
                      </tr>
                      <tr class=body>
                        <td class=body>Templates</td>
                        <td class=body>
                          <%select_list%>
                          <input name="bload" value=" Load " type=submit class=button />
                        </td>
                      </tr>
                      <tr class=body>
                        <td class=body>To</td>
                        <td>
                          <input type="text" class="object" name="tpl_to" size="<%if is_ie or is_mozilla%>70<%else%>50<%endif%>" value="<%if loaded%><%escape_html header_To%><%elsif tpl_to%><%tpl_to%><%endif%>" /> *
                        </td>
                      </tr>
                      <tr class=body>
                        <td class=body>Subject</td>
                        <td>
                          <input type="text" class="object" name="tpl_subject" size="<%if is_ie or is_mozilla%>70<%else%>50<%endif%>" value="<%if loaded%><%escape_html header_Subject%><%elsif tpl_subject%><%tpl_subject%><%endif%>" /> *
                        </td>
                      </tr>
                      <tr class=body>
                        <td class=body>From</td>
                        <td>
                          <input type="text" class="object" name="tpl_from" size="<%if is_ie or is_mozilla%>70<%else%>50<%endif%>" value="<%if loaded%><%escape_html header_From%><%elsif tpl_from%><%tpl_from%><%endif%>" /> *
                        </td>
                      </tr>
                      <tr class=body>
                        <td class=body>Extra Headers</td>
                        <td>
                          <textarea name="extra_headers" cols=70 rows=2 class=object><%if loaded%><%loop extra_headers%><%escape_html name%>: <%escape_html value%><%endloop%><%elsif extra_headers%><%extra_headers%><%endif%></textarea>
                        </td>
                      </tr>
                      <tr class=body>
                        <td class=body>E-mail body *</td>
                        <td align=right>
                          <font color="green">*: required</font>
                        </td>
                      </tr>
                      <tr class=body>
                        <td colspan=2>
                          <textarea cols="<%if is_ie%>120<%elsif is_mozilla%>100<%else%>90<%endif%>" rows=16 name="tpl_body" class=object><%if loaded%><%escape_html body%><%elsif tpl_body%><%tpl_body%><%endif%></textarea>
                        </td>
                    </tr>
                    <tr class=body>
                        <td valign=top class=body colspan="2">
                        <%if tpl_file%>
                          <input name="save_as" type=hidden size=30 class="object" value="<%tpl_file%>" />
                          <input type="submit" name="bsave" value=" Save Template " class="button" />
                        <%endif%>
                        <%if msg%><font color="<%if color%><%color%><%else%>green<%endif%>"><%msg%></font><%endif%>
                       </td>
                    </tr>
                    </table>
                  </td>
                </tr>
            </table>
            <input type=hidden name="do" value="admin_page" />
            <input type=hidden name="pg" value="admin_template_default.html" />
            <%hidden_objects%>
            </form>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<%include include_footer.html%>
