<?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 User</xsl:param>
    <xsl:param name="PAGE-NAME">addUser</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 border-bottom-0">
                    <i class="bi bi-person-circle 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="Users.addUser"/>
                        <input type="hidden" name="step"   value="add"/>
          
                        <div class="row">

                            <div class="col-lg-4 mb-3">
                                <label class="form-label" for="user_name">User Name</label>
                                <input type="text" class="form-control form-control-sm text-capitalize" name="user_name" id="user_name" maxlength="100" autocomplete="off" autofocus="autofocus" data-bs-toggle="popover" data-bs-content="{//popovers/record[popover_name = 'user_name']/popover_text}" data-bs-html="true" data-bs-custom-class="custom-popover" data-bs-offset="0,10"/>
                            </div>
              
                        </div>
                        
                        <div class="row">

                            <div class="col-lg-4 mb-3">
                                <label class="form-label" for="user_client_name">Client Name</label>
                                <input type="text" class="form-control form-control-sm" name="user_client_name" id="user_client_name" maxlength="100" autocomplete="off"/>
                            </div>

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

                            <div class="col-lg-4 mb-3">
                                <label class="form-label" for="user_email">Email</label>
                                <input type="text" class="form-control form-control-sm" name="user_email" id="user_email" maxlength="128" autocomplete="off"/>
                            </div>
              
                        </div>
          
                        <div class="row">
            
                            <div class="col-lg-3 mb-4">

                                <label class="form-label" for="user_role">Role</label>
                
                                <select class="form-control form-control-sm search-dropdown" name="user_role" id="user_role" size="1">
                                    <xsl:apply-templates select="//Constants/UserRoles"/>
                                </select>

                            </div>

                        </div>
            
                    </form>

                    <div class="buttons mt-1 mb-2">
                        <button type="button" class="btn btn-sm btn-primary me-2 btnCancel">
                            <i class="bi bi-box-arrow-left me-2"/>Cancel</button>
                        <button type="button" class="btn btn-sm btn-primary me-2 btnSave">
                            <i class="bi bi-save me-2"/>Save</button>
                    </div>
          
                </div>
        
            </div>
      
        </div>
          
    </xsl:template>

    <!-- Template for Role dropdown -->

    <xsl:template match="Constants/UserRoles">
    
        <option value="">Choose...</option>
    
        <xsl:for-each select="UserRole"> 
            <xsl:sort select="."/>
            <option value="{.}" data-tokens="{.}">
                <xsl:value-of select="." />
            </option> 
        </xsl:for-each>
    
    </xsl:template>

</xsl:stylesheet>
