<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" encoding="utf-8" indent="yes"/>

    <!-- Parameters -->

    <xsl:param name="VERSION">1.0</xsl:param>
    <xsl:param name="PAGE-TITLE">Choose Export</xsl:param>
    <xsl:param name="PAGE-NAME">chooseExport</xsl:param>

    <xsl:template match="/">
    
        <script src="js/{$PAGE-NAME}.js?version={$VERSION}"/>   

        <div class="{$PAGE-NAME}">
      
            <div class="card">
        
                <div class="card-header bg-primary text-white p-1 ps-3">
                    <i class="fa-regular fa-circle-user me-2"/>
                    <xsl:value-of select="$PAGE-TITLE"/>
                </div>
        
                <div class="card-body">
          
                    <form action="" name="{$PAGE-NAME}" method="post" id="{$PAGE-NAME}">

                        <input type="hidden" name="action" value="Export.chooseExport"/>
                        <input type="hidden" name="step"   value="run"/>
          
                        <div class="row">
                            
                            <div class="col-lg-4 mb-3">
                
                                <label class="form-label" for="export_processdate">Process Date</label>
                                <div class="input-group input-group-sm process_date">
                                    <input type="text" class="form-control form-control-sm date-mask" name="export_processdate" id="export_processdate" autocomplete="no" maxlength="10" autofocus="autofocus"/>
                                    <button class="btn btn-sm btn-outline-primary btnProcessDateCalendar" type="button" data-bs-toggle="tooltip" data-bs-title="Calendar" data-bs-custom-class="custom-tooltip" tabindex="-1">
                                        <i class="fa-solid fa-calendar-days"/>
                                    </button>
                                </div>
                
                            </div>

                        </div>
          
                        <div class="row">

                            <div class="col-lg-4 mb-3">
                                <label class="form-label" for="export_accounting_period">Accounting Period</label>
                                <input type="text" class="form-control form-control-sm autosave accounting-period" name="export_accounting_period" id="export_accounting_period" maxlength="7" autocomplete="off"/>
                            </div>
              
                        </div>

                        <div class="col-lg-4 mb-3">

                            <label class="form-label" for="export_type">Export Type</label>

                            <select class="form-control form-control-sm search-dropdown" name="export_type" id="export_type" size="1">
                                <xsl:call-template name="dropdowns">
                                    <xsl:with-param name="dropdown-name">export_type</xsl:with-param>
                                </xsl:call-template>
                            </select>

                        </div>
            
                    </form>

                    <div class="buttons mt-1 mb-2">
                        <button type="button" class="btn btn-sm btn-primary me-2 btnRun">
                            <i class="fa-solid fa-file-export me-2"/>Run</button>
                        <button type="button" class="btn btn-sm btn-primary me-2 btnCancel">
                            <i class="bi bi-check-lg me-2"/>Cancel</button>
                    </div>
          
                </div>
        
            </div>
      
        </div>
          
    </xsl:template>
    
    <!-- Template for Dropdowns -->

    <xsl:template name="dropdowns">
    
        <xsl:param name="dropdown-name"/>
    
        <option value="">Choose...</option>
    
        <xsl:for-each select="//dropdowns/record[dropdowntype_name = $dropdown-name]">
      
            <option value="{dropdown_serial}" data-tokens="{dropdown_value}">
                <xsl:if test="boolean(number(dropdown_default)) = true()">
                    <xsl:attribute name="selected">selected</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="dropdown_value" />
            </option>
      
        </xsl:for-each>
    
    </xsl:template>

</xsl:stylesheet>
