<div style="margin-bottom: 10px; margin-top: 10px;" class="table-summary">
    <h2>Process Invoices Options</h2>
	<font color='black'>Note: There is a service to automate the generation of non-batch payments</font>
</div>
<?php
    if ($this->phase == 'StartRunningRecurringActions') {
        //processing credit card
        if ($this->passphraseDoNotMatch) {
            echo "<br/><font color='red'><center><b>You have entered an invalid passphrase, please try again</b></center></font>";
        }

        if (($this->showMessage)&&(!$this->failed)){
            echo "<br/><font color='red'><center><b>Your recurring billing actions are currently in progress</b></center></font>";
            ?>
                <script type="text/javascript">
                    startProcessingInvoices('<?php echo $this->passphrase ?>',
                                       <?php echo $this->processDueinvoices ?>,
                                       <?php echo $this->nonautopayment ?>,
                                       <?php echo $this->autopayment ?>);
                </script>
            <?php
        } //endif

    } else {
        ?>
        <form action="index.php?fuse=admin&view=ProcessInvoices&phase=StartRunningRecurringActions" name='generateinvoice' method='post'>
        <table border='0' width="100%">
        <tr>
            <td width='10' align='center'><input type='radio' name='batchtype' value='0' onClick='HidePassPhrase();' checked='checked'></td>
            <td width='310' nowrap="nowrap">&nbsp;Generate Pending Invoices (<a href="#" qtip="This processes all non-merchant account plugins. i.e. PayPal, 2checkout, Google Checkout etc.">except autopayment</a>)</td><td align='left'><font color='gray'>&nbsp;&nbsp;<b>Last Generated:</b> <?php echo $this->lastGeneratedDate ?></font></td>
        </tr>
        <?php
        if ($this->passphraseInLimbo) {
        ?>
            <tr><td colspan='2'><?php echo $this->inLimboMsg ?></td></tr>
        <?php
        
        } else {
        ?>
            <tr><td width='10' align='center'><input type='radio' name='batchtype' value='1' onClick='ShowPassPhrase();'></td><td width='270' nowrap="nowrap">&nbsp;Run Batch Payments (<a href="#" qtip="This is for payment processors that require a merchant account. i.e. Authorize.net, Quantum etc">autopayment accounts</a>)</td><td align='left'><font color='gray'>&nbsp;&nbsp;<b>Last Generated:</b> <?php echo $this->lastRunBatch ?></font></td></tr>
        <?php
        } //end else
        ?>
            <tr>
                <td colspan='4'>
                    <div id="passphrasediv" style="display:none;padding-top:5px;padding-left:20px;">
                        <input name="processDueInvoices" type="checkbox" />&nbsp;Also process current and overdue invoices<br/>
                        <div style="padding-top:8px; display:<?php echo $this->displayPassphrase ?>">
                            <span style="color:red;">Passphrase is required</span><br>
                            <input type='password' class="x-form-text x-form-field" name='passphrase'>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan='4'><input id="performaction" type='button' class='button' value='Perform Action(s)' onClick='SubmitForm();' ></td>
            </tr>
        </table>
        </form>
            
            
        <?php
            if ($this->phase == 'CompletedRunningRecurringActions') {
                echo "<br/><font color='green'><b>Your recurring actions have been completed</b></font><br/><br/>";
            }
            if ($this->phase == 'CompletedRunningRecurringActions' && isset($_SESSION['all_invoices'])) {
        ?>
            <br/><b>Generated Invoices:</b>
        <?php
                foreach ($_SESSION['all_invoices'] AS $clientInvoiced => $allClientInvoices){
                    ?>
                        <br/><br/><font color="green"><b><?php echo $clientInvoiced?>:</b></font>
                    <?php
                    foreach ($allClientInvoices AS $invoiceID => $invoiceAmount){
                        ?>
                        <br>Invoice #<?php echo $invoiceID?>&nbsp;<?php echo $invoiceAmount ?>;
                    <?php
                    }
                }
                unset($_SESSION['all_invoices']);
            }
    }
?>
