<script type="text/javascript" src="/oa/scripts/ppl_xml.js"></script>
<script type="text/javascript">
    addCalendar("Cal2", "Select Date", "valid_to", "upload_tuids_form");
</script>
<div class="panelHeader" ><b>Generate PPL XML</b></div>
<div>
    <div class="panelContent">
        <form action="/relationships/generatePplXml/" method="post" name="upload_tuids_form" enctype="MULTIPART/FORM-DATA">
            <table class="form full">
                <tbody>
                    <tr>
                        <td>Filename of upload will be used to name all output files</td>
                    </tr>
                    <tr>
                        <td>
                            <label for="tuid_file">Upload File:</label>
                            <input name="tuid_file" type="FILE" size="5">
                        </td>
                    </tr>
                    <tr>
                        <td><label><input name="excludeDeleted" type="checkbox" value="Y" checked="checked" />Exclude Deleted Catalog</label></td>
                    </tr>
                    <tr>
                        <td><label><input id="withdrawClaims" name="withdrawClaims" type="checkbox" value="Y" <?php echo (($this->withdrawClaimValidation) ? 'checked="checked"' : '') ?> />Withdraw Claims</label>
                            <input type="text" id="valid_to" name="valid_to" size="10" maxlength="10" class="textField small" value="" disabled="disabled" readonly> <a href="#" class="calendarimg" onclick="showCal('Cal2');" ><img src="/images/icoCalendar.gif" border="0" alt="Calendar" align="absmiddle"></a>
                        </td>
                    </tr>
                    <tr>
                        <td><label style="margin-left: 100px;">*YYYY-MM-DD</label></td>
                    </tr>
                    <tr>
                        <td>
                            <input class="btn btn-primary btn-sm" name="submit" type="submit" value="Submit" />
                        </td>
                    </tr>
                    <?php if ($this->showConfirmation) {?>
                    <tr>
                        <td>
                            <div id="confirmationMessage"><h3>File successfully uploaded to inbox.  A matching output file and log file should be visible in the download display shortly.</h3>(Please refresh the page to see new listing)</div>
                        </td>
                    </tr>
                    <?php } ?>
                    <?php if ($this->exception) {?>
                        <tr>
                            <td>
                                <div id="exception">File failed uploading: <?php echo $this->exception->getMessage(); ?></div>
                            </td>
                        </tr>
                    <?php } ?>
                    <?php if ($this->validation) {?>
                        <tr>
                            <td>
                                <div id="validation">File failed uploading: <?php echo $this->validation; ?></div>
                            </td>
                        </tr>
                    <?php } ?>
                    <?php if ($this->withdrawClaimValidation) { ?>
                        <tr>
                            <td>
                                <div id="withdrawClaimValidation">Invalid Withdraw Claim Date: <?php echo $this->withdrawClaimValidation; ?></div>
                            </td>
                        </tr>
                    <?php } ?>
                </tbody>
            </table>
        </form>
    </div>
</div>
<div class="panelHeader" ><b>Available PPL XML Files</b></div>
<div>
    <div class="panelContent">
        <table id="available-files" class="data">
            <tbody>
            <tr><th>Filename</th><th class="no-wrap">Last Modified</th><th>Output XML</th><th>Log File</th></tr>
            <?php if ($this->fileList) {
                foreach($this->fileList as $file) { ?>
                    <tr>
                        <td class="filename">
                            <a href="<?php echo $file["inputPath"]; ?>"><?php echo $file["inputFileName"]; ?></a>
                        </td>
                        <td><?php echo $file["modified"]->format('Y-m-d g:i:s a'); ?></td>
                        <td class="filename">
                        <?php if ( !preg_match('/.xml$/', $file["outputFileName"]) ) {
                            echo $file["outputFileName"];
                             } else { ?>
                            <a href="<?php echo $file["outputPath"]; ?>"><?php echo $file["outputFileName"]; ?></a>
                        <?php } ?>
                        </td>
                        <td class="filename">
                            <a href="<?php echo $file["logPath"]; ?>"><?php echo $file["logFileName"]; ?></a>
                        </td>
                    </tr>
                <?php }
            } ?>
            </tbody>
        </table>
    </div>
</div>

