<?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">Add Subscription to User</xsl:param>
    <xsl:param name="PAGE-NAME">addSubscriptionToUser</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="bi bi-list-check me-2"/>
                    <xsl:value-of select="$PAGE-TITLE"/>
                    |
                    <xsl:value-of select="//users/record/user_name"/>
                </div>
        
                <div class="card-body">
          
                    <form action="" name="{$PAGE-NAME}" method="post" id="{$PAGE-NAME}">

                        <input type="hidden" name="action" value="Subscriptions.addSubscriptionToUser"/>
                        <input type="hidden" name="step"   value="add"/>
            
                        <input type="hidden" name="user_serial" value="{//users/record/user_serial}"/>
          
                        <div class="row">

                            <div class="col-lg-8 mb-3">
                                <label class="form-label" for="subscription_serial">Subscription</label>
                                <select class="form-control form-control-sm search-dropdown" name="subscription_serial" id="subscription_serial" size="1">
                                    <xsl:apply-templates select="//subscriptions"/>
                                </select>
                            </div>
              
                            <div class="col-lg-3 mb-3">
                                
                                <label class="form-label" for="subscription_stop_date">Stop Date</label>
                                <div class="input-group input-group-sm subscription_stop_date">
                                    <input type="text" class="form-control form-control-sm date-mask" name="subscription_stop_date" id="subscription_stop_date" value="{$TODAY_MMDDYYYY}"/>
                                    <button class="btn btn-sm btn-outline-primary btnSubscriptionStopDateCalendar" type="button" data-bs-toggle="tooltip" data-bs-title="Calendar" data-bs-custom-class="custom-tooltip" tabindex="-1">
                                        <i class="bi bi-calendar3"/>
                                    </button>
                                </div>
                                
                            </div>
              
                        </div>
                        
          
                    </form>

                    <div class="buttons mt-2 mb-2">
                        <button type="button" class="btn btn-sm btn-primary me-2 btnSave">
                            <i class="bi bi-save me-2"/>Save</button>
                        <button type="button" class="btn btn-sm btn-primary me-2 btnCancel">
                            <i class="bi bi-x-lg me-2"/>Cancel</button>
                    </div>
          
                </div>
        
            </div>
      
        </div>
          
    </xsl:template>
    
    <!-- Template for Subscription dropdown -->

    <xsl:template match="subscriptions">
    
        <option value="">Choose..</option>
    
        <xsl:for-each select="record">
      
            <option value="{subscription_serial}" data-tokens="{subscription_serial}">
                <xsl:value-of select="subscription_title"/>
                - 
                <xsl:value-of select="subscription_description"/>
            </option>
      
        </xsl:for-each>
    
    </xsl:template>

</xsl:stylesheet>
