﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Logout.aspx.cs" Inherits="Axium.Web.Logout" EnableViewState="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head id="Head1" runat="server">
    <title>Logout</title>
    <script src="Includes/Scripts/jquery-3.5.1.min.js" type="text/javascript"></script>
    <script src="Includes/Scripts/jquery-migrate-3.3.2.min.js" type="text/javascript"></script>
    <script src="Includes/Scripts/iframe.231520.js" type="text/javascript"></script>    
    
    <script type="text/javascript">
       // AX-18522 Check if eForm is open and stop SignalR because an error comes when PatientAccess user logs out with an eForm opened
       function CloseSignalR() {
          var formIFrame = window.parent.document.getElementById('formIfrmId');
          if (formIFrame) {
             var hdnStopSignalR = $(formIFrame).contents().find('#hdnStopSignalR');  // Use contents() to get elements of formIFrame
             if (hdnStopSignalR.length > 0) {
                $(hdnStopSignalR).trigger('click');	// AX-24898.24919.2 $(hdnStopSignalR).click();
             }
          }
       }

        function newCheckCanLeavePageLogout() {
            var formIfrm = window.parent.document.getElementById('formIfrmId');      // Get iForms frame 
            var patientFrm = window.parent.document.getElementById('proIfrmId');     // AX-17079

            // if not in iForms or not loaded validateNavMenu() or validateNavMenu return true; then redirect
            //if ((formIfrm == null || !$.isFunction(formIfrm.contentWindow.validateNavMenu)) || formIfrm.contentWindow.validateLogoutOrAuthor(continueOption)) {
            if (((formIfrm == null || !$.isFunction(formIfrm.contentWindow.validateLogoutOrAuthor)) && (patientFrm == null || !$.isFunction(patientFrm.contentWindow.canLeavePatientInfoToLogout)))
                || ((formIfrm != null && formIfrm.contentWindow.validateLogoutOrAuthor(continueOption)) || (patientFrm != null && patientFrm.contentWindow.canLeavePatientInfoToLogout()))) {
                return true;
            }
            return false;
        }

       // AX-4481.1 For every PA menu, check if there is iForm open and has no saved answers; AX-17079 check if there is Patient Information no saved; AX-17079
       function CheckCanLeavePageLogoutOrAuthor(continueOption) {
          var formIfrm = window.parent.document.getElementById('formIfrmId');      // Get iForms frame 
          var patientFrm = window.parent.document.getElementById('proIfrmId');     // AX-17079

          // if not in iForms or not loaded validateNavMenu() or validateNavMenu return true; then redirect
          //if ((formIfrm == null || !$.isFunction(formIfrm.contentWindow.validateNavMenu)) || formIfrm.contentWindow.validateLogoutOrAuthor(continueOption)) {
          if (((formIfrm == null || !$.isFunction(formIfrm.contentWindow.validateLogoutOrAuthor)) && (patientFrm == null || !$.isFunction(patientFrm.contentWindow.canLeavePatientInfoToLogoutOrAuthor)))
             || ((formIfrm != null && formIfrm.contentWindow.validateLogoutOrAuthor(continueOption)) || (patientFrm != null && patientFrm.contentWindow.canLeavePatientInfoToLogoutOrAuthor(continueOption)))) {
             return true;
          }
          return false;
       }

    </script>

    <%--
    <script type="text/javascript">
        function goToMessagePage() {
            $('#hdnGoToMsgBtn').click();
        }
    </script>
    --%>
</head>
<body>
    <form id="form1" runat="server">
        <div id="LogoutArea">
            <h1 class="HideHeader">.</h1>
            <div id="AuthorRepresentDiv" runat="server">
                <label id="ViewingInformationLabel" for="AuthorRepresentDrp" runat="server"/>
                <asp:DropDownList ID="AuthorRepresentDrp" runat="server" title="Select patient for viewing" />
                <asp:Button ID="ApplyAuthorRepBtn" runat="server" Text="Apply" autopostback="true" OnClientClick="return(CheckCanLeavePageLogoutOrAuthor(1));" OnClick="AuthorRepresentDrpChanged" />
               <asp:Button ID="HiddenApplyAuthorBtn" runat="server" Text="" onclick="AuthorRepresentDrpChanged" style="visibility: hidden; display: none;" />
            </div>
            <div id="AuthRepSeparateLine" class="AuthRepSeparateLine" runat="server"></div>
            <div id="Logout">
                <asp:Button ID="LogoutASPBtn" runat="server" Text="Logout" OnClientClick="return(CheckCanLeavePageLogoutOrAuthor(2));" onclick="LogoutBtn_Click" CssClass="submitBtn" />
                <asp:Button ID="HiddenLogoutBtn" runat="server" Text="" onclick="LogoutBtn_Click" style="visibility: hidden; display: none;" />               
            </div>
            <%--53013999--%>
            <%--<div id="MessageAtLogout" runat="server">--%>
                <%--<span id="MsgLink" class="MsgLink"><asp:Label ID="MsgT" runat="server" Text="1" CssClass="MsgCount" /></span>--%>
                <%--
                <asp:ScriptManager ID="ScriptManager1" runat="server"/>
                <asp:Timer ID="TimerMessage" runat="server" Interval="200000" OnTick="GetNewMessages" />
                <asp:UpdatePanel ID="UpdatePanelMessage" runat="server">
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="TimerMessage" EventName="Tick" />
                    </Triggers>
                    <ContentTemplate>
                        <asp:LinkButton ID="MsgLink" runat="server" CssClass="MsgLink" OnClientClick="goToMessagePage()"><asp:Label ID="MsgT" runat="server" Text="1" CssClass="MsgCount" /></asp:LinkButton>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <input id="hdnGoToMsgBtn" type="button" value="goTo" runat="server" OnServerClick="GotoMessages" />
                --%>
            <%--</div>--%>
        </div>
    </form>
    <script type="text/javascript">

       $(parent.document).find("iframe").each(function () {
          // apply the logic only to the current iframe only
          if (this.contentDocument == window.document) {
             // if the href of the iframe is not same as 
             // the value of src attribute then reload it
             if (this.src != location.href) {
                this.src = this.src;
             }
          }
       });

       jQuery(document).ready(function () {
          $('#logoutIfrmId', window.parent.document).attr("scrolling", "no"); //AX-21453 Resized logout area in the side bar
          var logoutHeight = $('#LogoutArea').height();
          $('#logoutIfrmId', window.parent.document).css('height', logoutHeight + 15);
          //$childHeight = $(document).height();
          //jQuery('#logoutIfrmId', window.parent.document).css('height', $childHeight);
       });

    </script>
</body>
</html>