<!DOCTYPE html>
<%= render 'layouts/script_url' %>
<%= render 'layouts/image_url' %>
<%= render 'layouts/validate' %>
<html>
  <head>
    <title>DECO Drive 個人管理</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

    <%= yield :head %>

    <link rel="manifest" href="/manifest.json">
    <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
    <%= stylesheet_link_tag "address_books" %>
    <%= stylesheet_link_tag "jquery.multiselect2side" %>
    <%= stylesheet_link_tag "jquery-ui" %>
    <%= stylesheet_link_tag "jquery-ui-timepicker-addon" %>
    <%= stylesheet_link_tag "os" %>
    <%= stylesheet_link_tag "receiver_list_import" %>
    <%= stylesheet_link_tag "styles" %>
    <%= stylesheet_link_tag "system.styles" %>
    <%= stylesheet_link_tag "template" %>
    <%= stylesheet_link_tag "uploadfile" %>
    <%= stylesheet_link_tag "user_log" %>
    <%= stylesheet_link_tag "user_management" %>
    <%= stylesheet_link_tag "validationEngine.jquery" %>
    <%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>
    <%= javascript_include_tag "jquery" %>
    <%= javascript_include_tag "jquery-ui" %>
    <%= javascript_include_tag "import_csv" %>
    <%= javascript_include_tag "jquery.form" %>
    <%= javascript_include_tag "jquery.multiselect2side" %>
    <%= javascript_include_tag "jquery.simplemodal.1.4.4.min" %>
    <%= javascript_include_tag "jquery.uploadfile" %>
    <%= javascript_include_tag "jquery.validationEngine" %>
    <%= javascript_include_tag "jquery.ui.datepicker-ja" %>
    <%= javascript_include_tag "jquery-ui.timepicker-addon" %>
    <%= javascript_include_tag "jquery-ui.timepicker-ja" %>
    <%= javascript_include_tag "deco" %>
  </head>
  <body>
    <div id="header">
      <%= link_to image_tag('common/deco_logo01.jpg', :alt => "DECO Drive", :border => 0), root_path %>
    </div>

    <div id="status"  style="margin: 20px 0px 0px 8px;">
      <%= t('views.login_state.src_ip_address') %>:<%= @access_ip %>
      <%- unless session[:site_category] -%>
        <% if session[:user_id] -%>
          ( <%= t('views.login_state.userid') %>: <%= current_user.login %> )
          <%= link_to "[#{t('views.login_state.top')}]", root_path -%>
          <%= link_to "[#{t('views.login_state.logout')}]", :controller => :sessions, :action => :destroy, :id => nil -%>
        <%- end -%>
      <%- end -%>
    </div>

    <div id="main">
      <div id="um-main" style="">
        <div id="um-menu" style="">
          <div class="um-leftmenu">
            <%= link_to t('views.user_menu.user_management'), user_management_index_path, {:id => 'menuitem_user_management', :class => 'menuitem'} %>
            <%= link_to t('views.user_menu.user_environment'), user_environment_index_path, {:id => 'menuitem_user_environment',:class => 'menuitem'} %>
            <%= link_to t('views.user_menu.address_books'), address_books_path, {:id => 'menuitem_address_books',:class => 'menuitem'} %>
            <a id="menuitem_user_log" class="menuitem submenuheader" href="javascript:void(0);" data-submenuheader_visible='true'>
              <%= t('views.user_menu.user_log') %>
              <span class="accordsuffix">
                <%= image_tag "m/plus.gif", :class => 'icon_plus statusicon' %>
                <%= image_tag "m/minus.gif", :class => 'icon_minus statusicon', :style => 'display:none;' %>
              </span>
            </a>
            <div class="submenu">
              <ul>
                <li><%= link_to  t('views.user_menu.user_log_send'), user_log_index_path %></li>
                <li><%= link_to  t('views.user_menu.user_log_request'), index_request_user_log_index_path %></li>
              </ul>
            </div>
          </div>
        </div>

        <div id="sys-cont">
          <% if flash.now[:error] -%>
            <div id="err-sys">
              <%= flash.now[:error] %>
            </div>
          <% end -%>
          <% if flash.now[:notice] -%>
            <div id="hint-sys">
              <%= flash.now[:notice] %>
            </div>
          <% end -%>
          <%= yield %>
        </div>
      </div>
    </div>

    <script type="text/javascript">
    document.addEventListener('DOMContentLoaded', function() {
      document.getElementById("menuitem_<%= params[:controller] %>").style.background = "url(<%= asset_path "common/but01_f_m.gif" %>) no-repeat";
    });

    document.addEventListener('DOMContentLoaded', function(){
        var submenuheader = document.querySelector('.submenuheader');
        var submenu = document.querySelector('.submenu');
        submenuheader.addEventListener('click', function() {
            $('.submenu').slideToggle();
            var isVisible = submenuheader.getAttribute('data-submenuheader_visible') === 'false';
            submenuheader.setAttribute('data-submenuheader_visible', isVisible);
            fetch('/sessions/change_parameter', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
                'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content
            },
            body: 'submenuheader_visible=' + submenuheader.getAttribute('data-submenuheader_visible')
        });
            if (submenuheader.getAttribute('data-submenuheader_visible') === 'false') {
                // 非表示中の処理
                document.querySelectorAll(".icon_plus").forEach(function(el) { el.style.display = 'none'; });
                document.querySelectorAll(".icon_minus").forEach(function(el) { el.style.display = 'block'; });
            } else {
                // 表示中の処理
                document.querySelectorAll(".icon_plus").forEach(function(el) { el.style.display = 'block'; });
                document.querySelectorAll(".icon_minus").forEach(function(el) { el.style.display = 'none'; });
            }
        });
    });
    </script>
    <%= raw "<script>document.addEventListener('DOMContentLoaded', function(){ document.querySelector('.submenu').style.display='none'; document.querySelector('.submenuheader').setAttribute('data-submenuheader_visible', 'false'); document.querySelectorAll('.icon_plus').forEach(function(el){el.style.display='none';}); document.querySelectorAll('.icon_minus').forEach(function(el){el.style.display='block';}); })</script>" if session[:submenuheader_visible].present? && session[:submenuheader_visible].to_s == 'false' %>
  </body>
</html>
