
<div class="page-header">
 <ul class="breadcrumb">
  <li><a href="<%=  %>">Home</a></li>
  <li><a href="<%= settings_menu_category_simple_menu_items_path(@category) %>">Menu Category</a></li>

  <li>Menu Item</li>

  <span style="float: right">
  </span>
 </ul>
</div>

<div class="card">
  <div class="card-block">
    <h4 class="card-title">Menu Item </h4>
    <table class="table">
      <thead>
        <tr>
          <th>Item code</th>
          <th>Name</th>
          <th>Alt name</th>
          <th>Type</th>
          <th>Accout</th>
          <th>Menu category</th>
          <th>Menu item</th>
          <th>Min qty</th>
          <th>Min selectable item</th>
          <th>Max selectable item</th>
          <th>Created At</th>
          <th>Action</th>
        </tr>
      </thead>

      <tbody>
        <tr>
          <td><%= @settings_menu_item.item_code %></td>
          <td><%= @settings_menu_item.name  rescue "-" %></td>
          <td><%= @settings_menu_item.alt_name %></td>
          <td><%= @settings_menu_item.type %></td>
          <td><%= @settings_menu_item.account.title %></td>
          <td><%= @settings_menu_item.menu_category_id %></td>
          <td><%= @settings_menu_item.menu_item_id %></td>
          <td><%= @settings_menu_item.min_qty %></td>
          <td><%= @settings_menu_item.min_selectable_item %></td>
          <td><%= @settings_menu_item.max_selectable_item %></td>

          <td><%= @settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p")  %></td>

          <td><%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@category, @settings_menu_item) %></td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

<% if @sub_menu.count > 0 %>

<br>
<div class="card">
  <div class="card-block">
    <h4 class="card-title">Sub Menu Items </h4>
    <table class="table">
      <thead>
        <tr>
          <th>Item code</th>
          <th>Name</th>
          <th>Alt name</th>
          <th>Type</th>
          <th>Parent Item</th>
          <th>Created by</th>
          <th>Created at</th>

          <th colspan="3"></th>
        </tr>
      </thead>

      <tbody>
        <% @sub_menu.each do |settings_menu_item| %>
          <tr>
            <td><%= settings_menu_item.item_code %></td>
            <td><%= settings_menu_item.name %></td>
            <td><%= settings_menu_item.alt_name %></td>
            <td><%= settings_menu_item.type %></td>
            <td><%= settings_menu_item.parent.name rescue "-" %></td>
            <td><%= settings_menu_item.created_by %></td>

            <td><%= settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p")  %></td>


            <% if settings_menu_item.type == "SimpleMenuItem" %>
            <td><%= link_to 'Show', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ) %></td>
            <td><%= link_to 'Edit', edit_settings_menu_category_simple_menu_item_path(@category, settings_menu_item) %></td>
            <td><%= link_to 'Destroy', settings_menu_category_simple_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %></td>
            <% else %>
            <td><%= link_to 'Show', settings_menu_category_set_menu_item_path(@category, settings_menu_item ) %></td>
            <td><%= link_to 'Edit', edit_settings_menu_category_set_menu_item_path(@category, settings_menu_item) %></td>
            <td><%= link_to 'Destroy', settings_menu_category_set_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %></td>
            <% end %>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>
 <%= paginate @sub_menu, param_name: :page, :outer_window => 3 %>

<% end %>

 <br>
<div class="card">
  <div class="card-block">
    <h4 class="card-title">Menu Item Instances
      <span style="float: right">

        <%= link_to t('.new', :default => t("helpers.links.new")),new_settings_simple_menu_item_menu_item_instance_path(@settings_menu_item),:class => 'btn btn-primary btn-sm' %>
      </span>

    </h4>
    <table class="table">
      <thead>
        <tr>
          <!-- <th>Menu Item Id</th> -->
          <th>item_instance_code</th>
          <th>Instances Name</th>
          <th>item_attributes</th>
          <th>price</th>
          <th>is_on_promotion</th>
          <th>promotion_price</th>
          <th>Created at</th>


          <th colspan="3"></th>
        </tr>
      </thead>

      <tbody>
        <% @menu_item_instance.each do |settings_menu_item| %>
          <tr>

            <td><%= settings_menu_item.item_instance_code %></td>
            <td><%= settings_menu_item.item_instance_name %></td>
            <td><%= settings_menu_item.item_attributes %></td>
            <td><%= settings_menu_item.price %></td>
            <td><%= settings_menu_item.is_on_promotion %></td>
            <td><%= settings_menu_item.promotion_price %></td>

            <td><%= settings_menu_item.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p")  %></td>

            <td><%= link_to 'Show', settings_simple_menu_item_menu_item_instance_path(@settings_menu_item, settings_menu_item ) %></td>
            <td><%= link_to 'Edit', edit_settings_simple_menu_item_menu_item_instance_path(@settings_menu_item, settings_menu_item) %></td>
            <td><%= link_to 'Destroy', settings_simple_menu_item_menu_item_instance_path(@settings_menu_item, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' } %></td>

          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>
</div>
