<%if save%>
  <%Links::Payment::save_cat_price%>
  <%if payment_config_invalid_fee%>
  <%set message = "<br><font color=red>You entered an invalid signup charge!</font>"%>
  <%endif%>
  <%if payment_config_invalid_term%>
  <%set message .= "<br><font color=red>You entered an invalid signup term!</font>"%>
  <%endif%>
  <%if payment_term_exists%>
  <%set message .= "<br><font color=red>This term has been defined for this category!</font>"%>
  <%endif%>
  <%if payment_invalid_cat_id%>
  <%set message .= "<br><font color=red>Invalid category ID!</font>"%>
  <%endif%>
  <%if config_saved_done%>
  <%set message = "<font color=green>Your payment configuration has been saved successfully</font>"%>
  <%endif%>
  <%if config_copied_done%>
  <%set message = "<font color=green>Your payment configuration has been copied successfully</font>"%>
  <%endif%>
<%endif%>

<html>
<head>
  <title>Gossamer Links - Payments - Payment Setup</title>
</head>

<body bgcolor="white">
<%set header_title = "Payment Setup"%>
<%set header_description = "This page allows you to add and remove payment terms for a particular category."%>
<%include payment_header.html%>
<%set font_tag = '<font face="Tahoma,Arial,Helvetica" size="2">'%>
<%Links::Payment::load_cat_price($ID)%>  
<br>
<form method="post" action="admin.cgi">
<input type="hidden" name="do" value="page">
<input type="hidden" name="page" value="payment_cat_price.html">
<input type="hidden" name="save" value="1">
<input type="hidden" name="not_global" value="1">
<input type="hidden" name="ID" value="<%ID%>">

<table border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <table border=0 bgcolor="#FFFFFF" width="500">
        <tr>
          <td width="30%" valign="top"><%font_tag%>Category:</font></td>
          <td width="70%"><%font_tag%><%Name%></td>
        </tr>
        <tr>
          <td width="30%" valign="top"><%font_tag%>Payment Mode:</font></td>
          <td width="70%"><%font_tag%>
            <%if Payment_Mode == 1%>Not Accepted<%endif%>
            <%if Payment_Mode == 2%>Optional<%endif%>
            <%if Payment_Mode == 3%>Required<%endif%>
            </font>
          </td>
        </tr>
        <tr>
          <td width="30%" valign="top"><%font_tag%><a href="admin.cgi?db=Category;do=search_results;ID=<%ID%>;ID-opt==">Back</a></font></td>
          <td width="70%"><%font_tag%><a href="admin.cgi?do=page;page=payment_cat_price.html;ID=<%ID%>;save=1;copy_global=1">Copy global terms</a></font></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<br>
<table border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <table bgcolor="white" border="0" cellpadding="3" cellspacing="3" width="500" valign="top">
      <%if num_signup or num_renewal%>
        <tr>
          <td valign="top" style="padding-top: 6px"><%font_tag%><b>
              <%if num_renewal and renewal_differs%>Initial Terms:
              <%else%>Payment Terms:
              <%endif%>
          </b></td>
          <td valign="top" style="padding-top: 0px">
            <table border="0" cellpadding="0" cellspacing="6">
              <tr>
                <td><%font_tag%><u>Delete</u></font></td>
                <td><%font_tag%><u>Cost</u></font></td>
                <td><%font_tag%><u>Term</u></font></td>
              </tr>
              <%loop signup%>
              <tr>
                <td><%font_tag%><input type="checkbox" name="delete_term" value="<%cp_id%>"></font></td>
              <td><%font_tag%><%Links::Payment::currency($cost)%></font></td>
                <td><%font_tag%><%ifnot term_unit%>Lifetime<%else%><%term_num%> <%term_unit%><%endif%></font></td>
              </tr>
              <%endloop%>
            </table>
          </td>
        </tr>
        <tr>
          <td valign="top"><%font_tag%><b>Renewal Terms:</b></td>
          <%if num_renewal and renewal_differs%>
          <td valign="top" style="padding-top: 0px">
            <table border="0" cellpadding="0" cellspacing="6">
              <tr>
                <td><%font_tag%><u>Delete</u></font></td>
                <td><%font_tag%><u>Cost</u></font></td>
                <td><%font_tag%><u>Term</u></font></td>
              </tr>
              <%loop renewal%>
              <tr>
                <td><%font_tag%><input type="checkbox" name="delete_term" value="<%cp_id%>"></font></td>
                <td><%font_tag%><%Links::Payment::currency($cost)%></font></td>
                <td><%font_tag%><%ifnot term_unit%>Lifetime<%else%><%term_num%> <%term_unit%><%endif%></font></td>
              </tr>
              <%endloop%>
            </table>
          </td>
          <%else%>
          <td valign="top">
            <%font_tag%>Same as payment terms above.</font>
          </td>
          <%endif%>
        </tr>
      <%endif%>
      <%if num_recurring%>
        <tr>
          <td valign="top"><%font_tag%><b>Recurring Terms:</b></td>
          <td valign="top" style="padding-top: 0px">
            <table border="0" cellpadding="0" cellspacing="6">
              <tr>
                <td><%font_tag%><u>Delete</u></font></td>
                <td><%font_tag%><u>Cost</u></font></td>
                <td><%font_tag%><u>Term</u></font></td>
              </tr>
              <%loop recurring%>
              <tr>
                <td><%font_tag%><input type="checkbox" name="delete_term" value="<%cp_id%>"></font></td>
                <td><%font_tag%><%Links::Payment::currency($cost)%></font></td>
                <td><%font_tag%><%term_num%> <%term_unit%></font></td>
              </tr>
              <%endloop%>
            </table>
            <%unless Links::Payment::recurring_enabled()%>
            <%font_tag%><font color="red">Note that recurring payments require
              a supporting payment method.  No appropriate payment method is
              currently enabled.</font></font>
            <%endunless%>
          </td>
        </tr>
      <%endif%>
        <tr>
          <td valign="top"><%font_tag%><b>New Term:</b></td>
          <td valign="top" style="padding-top: 0px">
            <table border="0" cellpadding="0" cellspacing="6">
              <tr>
                <td><%font_tag%>
                  <%Links::Payment::currency('<input type="text" name="signup_cost" size="6">')%>
                  <input type="radio" name="add_type" value="signup"<%if not add_type or add_type eq 'signup'%> checked="checked"<%endif%>> Single
                  <input type="radio" name="add_type" value="renewal"<%if add_type eq 'renewal'%> checked="checked"<%endif%>> Renewal
                  <input type="radio" name="add_type" value="recurring"<%if add_type eq 'recurring'%> checked="checked"<%endif%>> Recurring<br>
                  <input type="text" name="term_length" size="2">
                  <select name="term_unit">
                    <option value="d">days</option>
                    <option value="w">weeks</option>
                    <option value="m">months</option>
                    <option value="y">years</option>
                    <option value="unlimited">lifetime</option>
                  </select>
                </font></td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td colspan="3" align="center"><%font_tag%><input type="submit" value="Save Changes"></font></td>
        </tr>
      </table>
    </td>
  </tr>
</table>

</form>
</body>
</html>
