<%ifnot fd%><%set fd = 1%><%endif%>
<%if fd == 4%>
<table width="99%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td><img src="<%image_url%>/pics/1pixel.gif" width="1" height="3"></td>
  </tr>
  <tr bgcolor="#7a9f54">
    <td>
      <table width="100%" border="0" cellspacing="1" cellpadding="1">
        <tr class="body_white">
          <td width="3%" height="20" bgcolor="#256A19" class="body_white" align="center"><img src="<%image_url%>/icons/message.gif" hspace=2></td>
          <td width="3%" height="20" bgcolor="#256A19" class="body_white" align="center"><img src="<%image_url%>/icons/attachment.gif" hspace=2></td>
          <td width="6%" height="20" bgcolor="#256A19" class="body_bold" align="center"><b>
            <%ifnot hits%>ID
            <%else%>
            <a href="glist.cgi?<%if do%>do=mli_search&<%endif%><%if query%><%query%><%endif%>&fd=<%if fd%><%fd%><%else%>1<%endif%><%if id%>&id=<%id%><%endif%>;sb=mli_id&so=<%if so eq 'ASC'%>DESC<%else%>ASC<%endif%><%hidden_query%>"><font color="#FFFFFF">ID</font></a>
            <%if sb eq 'mli_id' or $sb eq ''%>
                <img src="<%image_url%>/icons/<%if so eq 'ASC'%>up.gif<%else%>down.gif<%endif%>" border=0>
              <%endif%>
            <%endif%></b>
          </td>
          <td width="42%" height="20" bgcolor="#256A19" class="body_bold">
            <%ifnot hits%>Subject
            <%else%>
              <a href="glist.cgi?<%if do%>do=mli_search&<%endif%><%if query%><%query%><%endif%>&fd=<%if fd%><%fd%><%else%>1<%endif%><%if id%>;id=<%id%><%endif%>;sb=mli_subject;so=<%if so eq 'ASC'%>DESC<%else%>ASC<%endif%><%hidden_query%>"><font color="#FFFFFF">Subject</font></a>
              <%if sb eq 'mli_subject'%>
                <img src="<%image_url%>/icons/<%if so eq 'ASC'%>down.gif<%else%>up.gif<%endif%>" border=0>
              <%endif%>
            <%endif%>
          </td>
          <td class="body_bold" width="8%" align="center" bgcolor="#256A19" height="22">Recipients</td>
          <td class="body_bold" width="23%" align="center" bgcolor="#256A19" height="22">Frequency</td>
          <td class="body_bold" width="12%" align="center" bgcolor="#256A19" height="22">Time</td>
          <td class="body_bold" width="8%" align="center" bgcolor="#256A19" height="22">Status</td>
          <td class="body" width="3%" align="center" bgcolor="#256A19"><input name=c_all type=checkbox onclick="check_all()" <%if fd == 1%>checked<%endif%>/></td>
        </tr>
        <%loop results%>
        <tr class="body" bgcolor="<%if even%>#d9e4f2<%else%>#FFFFFF<%endif%>">
          <td align="center"><img src="<%image_url%>/icons/<%if mli_done%>sent.gif<%else%>draft.gif<%endif%>" hspace=1></td>
          <td align="center">
            <%GList::HTML::generate_attachments('mli_id')%>
            <%if attachments%><img src="<%image_url%>/icons/attachment.gif" hspace=2><%else%>&nbsp;<%endif%>
          </td>
          <td class="body" align=center><%mli_id%></td>
          <td class="body">
            <%if mli_user_id_fk and mli_user_id_fk ne $usr_username%>
              <%set user_search = 1%>
            <%elsif mli_user_id_fk eq $usr_username and mli_user_id_fk-opt eq '<>'%>
              <%set user_search = 1%>
            <%endif%>
            <a href="glist.cgi?do=mli_home;d=1;mli_id=<%mli_id%><%if lookup%>&lu=<%lookup%><%endif%><%if fd%>;fd=<%fd%><%endif%><%if id%>&id=<%id%><%endif%><%if url%>;<%url%><%endif%><%hidden_query%>"><%mli_subject%></a>
          </td>
          <td align="center" class="body"><%if total%><%total%><%endif%></td>
          <%GList::Tools::schedule_info($mli_id)%>
          <td align="center" class="body">
            <%if scm_type == 1%>One on <%scm_option%>
            <%elsif scm_type == 2%>Daily
            <%elsif scm_type == 3%>Weekly on <%scm_option%>
            <%elsif scm_type == 4%>Monthly on <%scm_option%><%endif%>
          </td>
          <td align="center" class="body"><%scm_hour%>:<%if scm_minute < 10%>0<%endif%><%scm_minute%> <%if scm_hour <= 12%>AM<%else%>PM<%endif%></td>
          <td align="center" class="body">
            <%if GList::Tools::schedule_status%>Sent<%endif%>
          </td>
          <td align="center">
            <input type="checkbox" name="modify" value="<%row_num%>" onclick="check_item(this)" <%if fd == 1%>checked<%endif%>>
            <input type="hidden" name="<%row_num%>-mli_id" value="<%mli_id%>" />
          </td>
        </tr>
        <%endloop%>
      </table>
    </td>
  </tr>
  <tr>
    <td class="body">
    <%if msg%><%msg%><%endif%>
      <%if hits%>
      <table width="100%" border="0" cellspacing="0" cellpadding="0"  height=30>
        <%if hits > $mh%>
        <tr align="left" class="body">
          <td class="body"><%include include_toolbar.html%></td>
        </tr>
        <%endif%>
        <tr>
          <td align="right">
            <input type="hidden" name="mod_action" value="delete">
            <input type="button" name="bschedule" value="Delete Scheduled Mailings" onclick="init_do('myform', 'mli_schedule_delete', '', '', 'mli_', '<%fd%>')" class="button" />
            <input type="button" name="bdelete" value="<%if fd != 1%>Delete<%else%>Cancel<%endif%> Mailings" onclick="init_do('myform', 'mli_delete', '', '', 'mli_', '<%fd%>')" class="button" />
          </td>
        </tr>
      </table>
      <%endif%>
    </td>
  </tr>
</table>
<%else%>
<table width="99%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td><img src="<%image_url%>/pics/1pixel.gif" width="1" height="3"></td>
  </tr>
  <tr bgcolor="#7a9f54">
    <td>
      <table width="100%" border="0" cellspacing="1" cellpadding="1">
        <tr class="body_white">
          <td width="3%" height="20" bgcolor="#256A19" class="body_white" align="center"><img src="<%image_url%>/icons/message.gif" hspace=2></td>
          <td width="3%" height="20" bgcolor="#256A19" class="body_white" align="center"><img src="<%image_url%>/icons/attachment.gif" hspace=2></td>
          <td width="6%" height="20" bgcolor="#256A19" class="body_bold" align="center"><b>
            <%ifnot hits%>ID
            <%else%>
            <a href="glist.cgi?<%if do%>do=mli_search&<%endif%><%if query%><%query%><%endif%>&fd=<%if fd%><%fd%><%else%>1<%endif%><%if id%>&id=<%id%><%endif%>;sb=mli_id&so=<%if so eq 'ASC'%>DESC<%else%>ASC<%endif%><%hidden_query%>"><font color="#FFFFFF">ID</font></a>
            <%if sb eq 'mli_id' or $sb eq ''%>
                <img src="<%image_url%>/icons/<%if so eq 'ASC'%>up.gif<%else%>down.gif<%endif%>" border=0>
              <%endif%>
            <%endif%></b>
          </td>
          <td width="45%" height="20" bgcolor="#256A19" class="body_bold">
            <%ifnot hits%>Subject
            <%else%>
              <a href="glist.cgi?<%if do%>do=mli_search&<%endif%><%if query%><%query%><%endif%>&fd=<%if fd%><%fd%><%else%>1<%endif%><%if id%>;id=<%id%><%endif%>;sb=mli_subject&so=<%if so eq 'ASC'%>DESC<%else%>ASC<%endif%><%hidden_query%>"><font color="#FFFFFF">Subject</font></a>
              <%if sb eq 'mli_subject'%>
                <img src="<%image_url%>/icons/<%if so eq 'ASC'%>down.gif<%else%>up.gif<%endif%>" border=0>
              <%endif%>
            <%endif%>
          </td>
          <td class="body"_bold width="8%" align="center" bgcolor="#256A19" height="22">Recipients</td>
          <td class="body"_bold width="8%" align="center" bgcolor="#256A19" height="22">Sent</td>
          <td class="body"_bold width="8%" align="center" bgcolor="#256A19" height="22">Bounced</td>
          <td class="body"_bold width="8%" align="center" bgcolor="#256A19" height="22">Opened</td>
          <td class="body"_bold width="8%" align="center" bgcolor="#256A19" height="22">Clicked</td>
          <td class="body" width="3%" align="center" bgcolor="#256A19"><input name=c_all type=checkbox onclick="check_all()" <%if fd == 1%>checked<%endif%>/></td>
        </tr>
        <%loop results%>
        <tr class="body" bgcolor="<%if even%>#d9e4f2<%else%>#FFFFFF<%endif%>">
          <td align="center"><img src="<%image_url%>/icons/<%if mli_done%>sent.gif<%else%>draft.gif<%endif%>" hspace=1></td>
          <td align="center">
            <%GList::HTML::generate_attachments('mli_id')%>
            <%if attachments%><img src="<%image_url%>/icons/attachment.gif" hspace=2><%else%>&nbsp;<%endif%>
          </td>
          <td class="body" align=center><%mli_id%></td>
          <td class="body">
            <%if mli_user_id_fk and mli_user_id_fk ne $usr_username%>
              <%set user_search = 1%>
            <%elsif mli_user_id_fk eq $usr_username and mli_user_id_fk-opt eq '<>'%>
              <%set user_search = 1%>
            <%endif%>
            <a href="glist.cgi?do=mli_home;d=1;mli_id=<%mli_id%><%if lookup%>;lu=<%lookup%><%endif%><%if fd%>;fd=<%fd%><%endif%><%if id%>;id=<%id%><%endif%><%if url%>;<%url%><%endif%><%hidden_query%>"><%mli_subject%></a>
          </td>
          <td align="center" class="body"><%if total%><%total%><%endif%></td>
          <td align="center" class="body"><%if done%><%done%><%endif%></td>
          <td align="center" class="body"><%if bounced_emails%><%bounced_emails%><%endif%></td>
          <td align="center" class="body"><%if mli_num_opened%><%mli_num_opened%><%endif%></td>
          <td align="center" class="body"><%if mli_num_clicked%><%mli_num_clicked%><%endif%></td>
          <td align="center">
            <input type="checkbox" name="modify" value="<%row_num%>" onclick="check_item(this)" <%if fd == 1%>checked<%endif%>>
            <input type="hidden" name="<%row_num%>-mli_id" value="<%mli_id%>" />
          </td>
        </tr>
        <%endloop%>
      </table>
    </td>
  </tr>
  <tr>
    <td class="body">
    <%if msg%><%msg%><%endif%>
      <%if hits%>
      <table width="100%" border="0" cellspacing="0" cellpadding="0"  height=30>
        <%if hits > $mh%>
        <tr align="left" class="body">
          <td class="body"><%include include_toolbar.html%></td>
        </tr>
        <%endif%>
        <tr class="body">
          <td valign=bottom class="body">&nbsp;</td>
          <td class="body" align="right">
            <%ifnot users%>
              <%if fd == 1 and hits_draft%>
               <%set flag = 1%>
              <%elsif fd = 2 and hits_sent%>
              <%set flag = 1%>
              <%elsif fd = 3%>
              <%set flag = 1%>
              <%elsif id%>
               <%set flag = 1%>
              <%endif%>
              <%if flag%>
              <b><%if fd == 3%>Restore<%else%>Move<%endif%> to</b>:
              <select name="move_to" class=object>
                <option value="">-------</option>
                <%if id%>
                <option value='root'>Sent Items</option>
                <%endif%>
                <%if fd == 1%>
                  <%loop results_draft%>
                    <%if id ne $cm_id%>
                    <option value="<%cm_id%>"><%cm_name%></option>
                    <%endif%>
                  <%endloop%>
                <%elsif fd == 2%>
                  <%loop results_sent%>
                    <%if id ne $cm_id%>
                    <option value="<%cm_id%>"><%cm_name%></option>
                    <%endif%>
                  <%endloop%>
               <%elsif fd == 3%>
                  <option value='draft'>Queued Mailings</option>
                  <option value='sent'>Sent Items</option>
                <%endif%>
              </select>
              <input type="button" name="bmove" value="<%if fd == 3%>Restore<%else%>Move<%endif%>" onclick="init_do('myform', 'mli_move', '', '', 'mli_', '<%fd%>')" class=button />
              <%endif%>
            <%endif%>
            <%if fd <=1 %>
            <input type="button" name="s_send" value="Start Mailings" onclick="init_do('myform', 'mli_send', '', '', 'mli_', '<%fd%>')" class="button" />
            <input type="button" name="bschedule" value="Schedule Mailings" onclick="init_do('myform', 'mli_schedule', '', '', 'mli_', '<%fd%>')" class="button" />
            <%endif%>
            <input type="button" name="bdelete" value="<%if fd != 1%>Delete<%else%>Cancel<%endif%> Mailings" onclick="init_do('myform', 'mli_delete', '', '', 'mli_', '<%fd%>')" class="button" />
            <%if fd == 3%><input type="button" name="bempty" value="Delete All" onclick="init_do('myform', 'mli_empty')" class="button" /><%endif%>
          </td>
        </tr>
      </table>
      <%endif%>
    </td>
  </tr>
</table>
<%endif%>
