﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <!--<xsl:template name="NoteObselete">

        <xsl:param name="Notes" select="'N/A'"></xsl:param>
        
        <xsl:variable name="Origin" select="$Notes/Origin"></xsl:variable>
        
        <xsl:apply-templates select ="$Notes/Note">
            <xsl:with-param name="DisplayReply">
                <xsl:choose>
                    <xsl:when test="$Origin = 'comment'">
                        <xsl:text>False</xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text>True</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:with-param>
        </xsl:apply-templates>
    </xsl:template>-->


    <xsl:template name="NoteItemObsolete">
        <xsl:param name="DisplayReply">
            <xsl:text>True</xsl:text>
        </xsl:param>
        <xsl:param name ="TemplatePathURL" select ="'N/A'"></xsl:param>
        <xsl:param name ="itemID" select="'N/A'"></xsl:param>
        <xsl:param name ="FirstName" select="'N/A'"></xsl:param>
        <xsl:param name ="LastName" select="'N/A'"></xsl:param>
        <xsl:param name ="NoteDesc" select="'N/A'"></xsl:param>
        <xsl:param name ="CreatedMinutes" select="'N/A'"></xsl:param>
        <xsl:param name ="NoteDateTime" select="'N/A'"></xsl:param>
        <xsl:param name="NotesUserImage" select="'N/A'"></xsl:param>


        
        <div id="div_Note_{normalize-space($itemID)}"
             style="background-color:#E6E6E6;border-top:1px solid #D2D2D2;"
                 class="labelSmall ">
            <div id="div_Note_{normalize-space($itemID)}_View" style="width:472px;">
                <div style="background-color:#E6E6E6;">

                    <table class="tableMaster" cellpadding="2" cellspacing="0">
                        <tr>
                            <td width="10%">
                                <span>
                                    <xsl:choose>
                                        <xsl:when test="$NotesUserImage != ''">
                                            <img src="{$NotesUserImage}" width="50" height="50" align="absmiddle" ></img>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <img src="{$TemplatePathURL}/Web/Images/Ver_2_0/DefaultUserPic.jpg"  align="absmiddle"  width="50" height="50"></img>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </span>
                            </td>
                            <td>
                                <div class="packageTitle sentenceFont">
                                    <xsl:value-of select ="$FirstName"/>&#xa0;<xsl:value-of select ="$LastName"/>
                                </div>
                                <div id="lbl_itemNote_{normalize-space($itemID)}" class="labelSmall marginBottom10" style="text-align: justify;">
                                    <xsl:apply-templates select ="$NoteDesc/."></xsl:apply-templates>
                                </div>
                                <a href="#" class="link" style="font-size: 9pt; margin-left: 5px; margin-right: 5px;"
                                             onClick='return Notes_EditNote(
                                                                        "div_Note_{normalize-space($itemID)}_Update",
                                                                        "div_Note_{normalize-space($itemID)}_View",
                                                                        "lbl_itemNote_{normalize-space($itemID)}",
                                                                        "txt_itemNote_{normalize-space($itemID)}"
                                                                        );'>
                                    Edit
                                </a>
                                <a href="#" class="link" style="font-size: 9pt;"
                                                         onClick='return Notes_DeleteNote(
                                                                    "{normalize-space($itemID)}", 
                                                                    "div_Note_{normalize-space($itemID)}"
                                                                    );'>
                                    Delete
                                </a>
                            </td>
                        </tr>
                    </table>
                </div>

                <div>
                    <span style="color: #7F7F7F;" class="labelSmall">
                        <xsl:choose>
                            <xsl:when test="$DisplayReply = 'False'">
                                <xsl:call-template name="TimeStamp">
                                    <xsl:with-param name="CreatedMinutes" select="$CreatedMinutes"></xsl:with-param>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select ="$NoteDateTime"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </span>

                </div>
            </div>

            <div id="div_Note_{normalize-space($itemID)}_Update" style="display:none">
                <div>
                    <textarea id="txt_itemNote_{normalize-space($itemID)}" rows="2" class="textAreaEditMode" style="font-size: 9pt;">
                        <xsl:value-of select ="$NoteDesc"/>
                    </textarea>
                </div>
                <div>
                    <a href="#" class="link" style="font-size: 9pt; margin-right: 5px;" onClick='return Notes_UpdateNote(
                                                                            "txt_itemNote_{normalize-space($itemID)}",
                                                                            "{normalize-space($itemID)}",
                                                                            "div_Note_{normalize-space($itemID)}_Update",
                                                                            "div_Note_{normalize-space($itemID)}_View",
                                                                            "lbl_itemNote_{normalize-space($itemID)}"
                                                                           );'>Update</a>
                    <a href="#" class="link" style="font-size: 9pt;" onClick='return Notes_CancelNote(
                                                                            "div_Note_{normalize-space($itemID)}_Update",
                                                                            "div_Note_{normalize-space($itemID)}_View"
                                                                          )'>Cancel</a>
                </div>
            </div>

      
        </div>
    </xsl:template>

    <xsl:template name ="TimeStamp">
        <xsl:param name="CreatedMinutes" select="'N/A'"></xsl:param>
        <font color="#414040">
            <xsl:if test ="$CreatedMinutes &lt; 1">
                &#xa0;<xsl:value-of select="round(normalize-space($CreatedMinutes) * 60)"/> second(s) ago
            </xsl:if>
            <xsl:if test ="$CreatedMinutes &gt;= 1 and $CreatedMinutes &lt; 60">
                &#xa0;<xsl:value-of select="round(normalize-space($CreatedMinutes))"/> minute(s) ago
            </xsl:if>
            <xsl:if test ="$CreatedMinutes &gt;= 60 and $CreatedMinutes &lt; 1440 ">
                &#xa0;<xsl:value-of select="round(normalize-space($CreatedMinutes) div 60)"/> hour(s) ago
            </xsl:if>
            <xsl:if test ="$CreatedMinutes &gt; 1440 ">
                &#xa0;<xsl:value-of select="round(normalize-space($CreatedMinutes) div 1440)"/> day(s) ago
            </xsl:if>
        </font>
    </xsl:template>

    <xsl:template match ='NoteDesc'>
        <xsl:call-template name ='break'></xsl:call-template>
    </xsl:template>

    <xsl:include href="Notes_LineBreak.xslt"/>

</xsl:stylesheet>
