<script type="text/javascript">
    $.ctrl('S', function () {
        return json_add('subscription_penalty-add', 'x', '0', 'popupform');
    });
</script>


<form action="" method="post" id="popupform" onsubmit="return json_add('subscription_penalty-add','x','0','popupform');">

    <div id="popupsave">
        <input type="submit" value="Save" class="save"/>
    </div>

    <h1>Subscription Penalties</h1>
    <div class="pad24t popupbody">

        <p class="highlight">This screen controls penalties for failed subscriptions.
            The "No." column represents the current failed attempt.
        </p>

        <ul id="source_list" class="popup_longlist">
            <li>
                <div class="col10">
                    <b>No.</b>
                </div>
                <div class="col45">
                    <b>Percent Penalty</b>
                </div>
                <div class="col45">
                    <b>Fixed Penalty</b>
                </div>
                <div class="clear"></div>
            </li>

            <?php
            $q1 = $db->run_query("
                SELECT *
                FROM `ppSD_subscription_reattempts`
                ORDER BY `fail_attempt` ASC
            ");

            $cur = 0;
            while ($item = $q1->fetch()) {
                $cur++;
                ?>

                <li id="td-cell-<?php echo $item['id'] ?>">
                    <div class="col10">
                        <?php echo $cur; ?>
                    </div>
                    <div class="col45">
                        <input type="text" name="attempt_<?php echo $item['fail_attempt'] ?>[penalty_percent]" style="width:80px;"
                                   value="<?php echo $item['penalty_percent'] ?>" maxlength="2" />%
                    </div>
                    <div class="col45">
                        <?php
                        echo place_currency('<input type="text" name="attempt_' . $cur . '[penalty_fixed]" style="width:80px;" value="' . $item['penalty_fixed'] . '" maxlength="5" />');
                        ?>
                    </div>
                    <div class="clear"></div>
                </li>

            <?php
            }
            ?>

        </ul>

    </div>

</form>