<%if !request.path_info.include?('second_display') %>
<nav class="navbar">
    <div class="container-fluid">
        <div class="navbar-header">
                <a class="navbar-brand m-0 mbl_view" href="<%= origami_dashboard_path%>">
                <img src="<%= asset_path('SX-Logo-small.png') %>" width="40" height="40" alt="Logo" />
                <span class="navbar-brand-txt">SX Restaurant</span>
            </a>
        </div>
        <!-- Start Shop Info -->
        <div class="navbar-right m-auto">
            <span class="navbar-brand navbar-brand-txt"><%= current_shop.name %></span>
        </div>
        <!-- End Shop Info -->

        <!-- Start Delete confirrm text !-->
        <div class="navbar-right toggle_mbl">
            <a href="javascript:void(0);" class="dropdown-toggle waves-block" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                <% if current_login_employee %>
                   <span>
                     <% if request.user_agent.include? "Mobile" %>
                       <img src="/assets/user_icon.png" alt="<%= current_login_employee.name %>" />
                     <% else %>
                       <%= current_login_employee.name %>
                     <% end %>
                   </span>
                <% end %>
            </a>
            <ul class="dropdown-menu">
                <li>
                    <p class="waves-effect waves-block p-l-30 m-b-5 team_viewer">
                       <i class="material-icons font-7 logout_icon shopinfo">touch_app</i>
                        <span class="font-15 shopinfo" >Team Viewer</span>
                    </p>
                </li>
                <li>
                    <p class="waves-effect waves-block p-l-30 m-b-5">
                        <a href="/foodcourt/second_display" onclick="window.open('/foodcourt/second_display', 'newwindow', 'width=700,height=500'); return false;" style="text-decoration: none;">
                            <i class="material-icons font-7 logout_icon shopinfo">info</i>
                            <span class="font-15 shopinfo" >Second Display</span>
                        </a>
                    </p>
                </li>
                <li>
                    <p class="waves-effect waves-block p-l-30 m-b-5" id="close_cashier">
                        <i class="material-icons font-7 logout_icon">close</i>
                        <span class="font-15">Close Cashier</span>
                    </p>
                </li>
                <li>
                    <p class="delete waves-effect waves-block p-l-30 m-b-5 logout" data-ref="<%= logout_path %>" data-method="delete">
                        <i class="material-icons font-7 logout_icon">exit_to_app</i>
                        <span class="font-15">Logout</span>
                    </p>
                     <span class="hidden" id="delete_text">
                        <h6>Are you sure you want to Logout ?</h6>
                    </span>
                </li>
            </ul>
        </div>
    </div>
</nav>
<%end%>
<script type="text/javascript">
    $(function(){
        $('.delete').click(function(){
            var method    = $(this).attr('data-method');
            var url       = $(this).attr('data-ref');
            var html_text = $(this).siblings( "#delete_text" ).html();
            //var page = url.substring(url.lastIndexOf('/') + 1);
            swal({
                title: "Confirmation",
                text: html_text,
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                html: true
            }, function (isConfirm) {
                if (isConfirm) {
                  $.ajax({
                    type: method,
                    url: url ,
                    success: function(data) {
                        location.href = data.url;
                    }
                 });
                } else {
                    swal("Cancelled", "Your imaginary file is safe :)", "error");
                }
            });
        });
        $(".team_viewer").on('click',function(){
            // /opt/teamviewer/tv_bin/script/teamviewer
            $.ajax({
                type: "POST",
                data: {},
                dataType: 'json',
                url: "/run_teamviewer",
                success: function(data){
                    if(!data.status){
                        window.open('https://www.teamviewer.com', '_blank');
                        return false;
                    }
                }
            });
        });

    });
    $('.close_cashier').on('click',function(e){
        e.preventDefault(); // Prevent the href from redirecting directly
        var linkURL = '/foodcourt/shift/cashier/close';
        swal({
          title: "Alert!",
          text: "Are you sure you want to close cashier?",
          type: "warning",
          showCancelButton: true,
          html: true
        }, function() {
            window.location.href = linkURL;
          });
      })
</script>
