<div class="page-header">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
    <li class="breadcrumb-item active"><%= t("en.menus") %></li>
    <span class="float-right">
      <%= link_to 'Back', dashboard_path %>
    </span>
  </ol>
</div>
<div class="row">
  <div class="col-xs-12 col-sm-12 col-md-2 col-lg-2">
   <br><br>
   <div class="card">
    <ul class="list-group">
     <li class="list-group-item"><%= link_to (t :accounts), settings_accounts_path %></li>
     <li class="list-group-item"><%= link_to 'Menu ', settings_menus_path %></li> 
     <li class="list-group-item"><%= link_to 'Menu Categories', settings_menu_categories_path %></li>
     <!-- <li class="list-group-item"><%= link_to 'Menu Item', dashboard_path %></li> -->
     <li class="list-group-item"><%= link_to 'Item Set', settings_item_sets_path %></li>
     <li class="list-group-item"><%= link_to 'Items Attributes', settings_menu_item_attributes_path %></li>
     <li class="list-group-item"><%= link_to 'Items Options', settings_menu_item_options_path %></li>
   </ul>
  </div>
</div>
<div class="col-xs-12 col-sm-12 col-md-7 col-lg-7">
  <div class="m-b-10 clearfix">
    <div class="float-left">
      <%= form_tag import_settings_menus_path,class:"col-md-", multipart:true  do%>
      <%=file_field_tag :file, :class => "img-thumbnail col-md-7" %>
      <%=submit_tag "Import",:class => 'btn btn-primary btn-lg waves-effect' %>
    <%end%> 
    </div>
    <%= link_to t("views.btn.new"),new_settings_menu_path,:class => 'btn btn-primary btn-lg float-right waves-effect"' %>

  </div>
  <div class="card">
    <table class="table table-striped">
      <thead>
        <tr>
          <th><%= t("views.right_panel.detail.name") %></th>
          <th><%= t("views.right_panel.detail.valid_days") %></th>
          <th><%= t("views.right_panel.detail.valid_from") %></th>
          <th><%= t("views.right_panel.detail.valid_to") %></th>
          <th><%= t("views.right_panel.detail.is_active") %></th>
            <!-- <th>Created By</th>
            <th>Created At</th> -->

            <th><%= t("views.right_panel.detail.actions") %></th>
          </tr>
        </thead>

        <tbody>
          <% @settings_menus.each do |settings_menu| %>
          <tr>
            <td><%= link_to settings_menu.name, settings_menu_path(settings_menu)%></td>
            <td><%= settings_menu.valid_days %></td>
            <td><%= settings_menu.valid_time_from.strftime("%H:%M") rescue "-" %></td>
            <td><%= settings_menu.valid_time_to.strftime("%H:%M") rescue "-" %></td>
            <td><%= settings_menu.is_active %></td>
            <!-- <td><%= settings_menu.created_by %></td> -->
            <!-- <td><%= settings_menu.created_at %></td> -->
            <!-- <td><%= settings_menu.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td> -->
            <td>
              <%= link_to t("views.btn.edit"), edit_settings_menu_path(settings_menu),:class => 'btn btn-info btn-sm waves-effect' %>
              <a href="#" id="export-xlsx" data-attr="<%= settings_menu.id %>" class="export-xlsx btn btn-primary btn-sm waves-effect" style="height: 33px;">
                <i class="material-icons" style="top: 0px;">backup</i>
              </a>
            </td>
          </tr>
          <% end %>
          </tbody>
        </table>
      </div>
      <%= paginate @settings_menus, param_name: :page, :outer_window => 3 %> 
    </div>
    <div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
      <div class="card">
        <div class="body">
          <h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
          <p>
          1) <%= t("views.right_panel.detail.name") %> -  <%= t("views.right_panel.detail.menu_txt") %> <%= t("views.right_panel.detail.name_txt") %> <%= t("views.right_panel.detail.menu_txt") %> <br>
          2) <%= t("views.right_panel.detail.valid_days") %> - <%= t("views.right_panel.detail.valid_days_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.menu_txt") %><br>
          3) <%= t("views.right_panel.detail.valid_from") %> - <%= t("views.right_panel.detail.valid_from_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.menu_txt") %><br>
          4) <%= t("views.right_panel.detail.valid_to") %> - <%= t("views.right_panel.detail.valid_to_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.menu_txt") %><br>
          5) <%= t("views.right_panel.detail.actions") %> - <%= t("views.right_panel.detail.actions_txt3") %> <%= t("views.right_panel.detail.menu_txt") %> <br>
          </p>
          <h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
          <p>
          1) <%= t("views.right_panel.button.new") %> - <%= t("views.right_panel.detail.new_btn_txt") %> <%= t("views.right_panel.detail.menu_txt") %> <br>
          2) <%= t("views.right_panel.button.edit") %> - <%= t("views.right_panel.detail.edit_btn_txt") %> <%= t("views.right_panel.detail.menu_txt") %> <br>
          </p>
          <h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
          <p>
            1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
            2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
            3) <%= t("en.accounts") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.accounts_txt") %><br>
            4) <%= t("views.right_panel.button.menu") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.menu_txt") %><br>
            5) <%= t("views.right_panel.button.menu_categories") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.menu_categories_txt") %><br>
            6) <%= t("views.right_panel.button.item_set") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.item_set_txt") %> <br>
            7) <%= t("views.right_panel.button.item_attributes") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.item_attributes_txt") %> <br>
            8) <%= t("views.right_panel.button.item_options") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.item_options_txt") %> <br>
          </p>
        </div>
      </div>  
    </div>
  </div>

  <script type="text/javascript">
    $(document).ready(function(){
      $(".export-xlsx").on('click', function(){
        var menu_id= $(this).attr('data-attr');
        
        $.ajax({
          type: "GET",
          url: "/settings/menus/" + menu_id + "/export",
          success: function(result){
            if(result.status){
              location.href = result.path.substring(6);
              // swal("Success", "Export Success...", "success");
            }
          }
        });
      });
    });
  </script>
