
<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("views.right_panel.detail.promotion") %></li>
    <span class="float-right">
      <%= link_to t('.back', :default => t("views.btn.back")), dashboard_path %>
    </span>
  </ol>
</div>

<div class="row">
  <div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
    <div class="m-b-10 clearfix">
      <%= link_to t("views.btn.new"),new_settings_promotion_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.promotion_code") %></th>
            <th><%= t("views.right_panel.detail.start_date") %></th>
            <th><%= t("views.right_panel.detail.end_date") %></th>
            <th><%= t("views.right_panel.detail.start_time") %></th>
            <th><%= t("views.right_panel.detail.end_time") %></th>
            <th><%= t("views.right_panel.detail.promotion_day") %></th>
            <th><%= t("views.right_panel.detail.original_product") %></th>
            <th><%= t("views.right_panel.detail.created_by") %></th>
            <th><%= t("views.right_panel.detail.created_at") %></th>
            <th><%= t("views.right_panel.detail.actions") %></th>
          </tr>
        </thead>

        <tbody>
          <% @promotions.each do |pro| %>
          <tr>
            <td><%= link_to pro.promo_code, settings_promotion_path(pro) %></td>
            <td><%= pro.promo_start_date %></td>
            <td><%= pro.promo_end_date %></td>
            <td><%= pro.promo_start_hour.utc.strftime("%I:%M %P") rescue "-" %></td>
            <td><%= pro.promo_end_hour.utc.strftime("%I:%M %P") rescue "-" %></td>
            <td><%= pro.promo_day %></td>
            <td>
              <% item = MenuItemInstance.find_by_item_instance_code(pro.original_product)%>
              <% if item.nil? %>
                <%= Product.find_by_item_code(pro.original_product).name rescue "-" %>
              <% else %>
                <%= item.menu_item.name rescue "-" %>
                - <%= item.item_instance_name rescue "-" %>
              <% end %>
            </td>
            <td style="padding: 2px">
              <% if Employee.exists?(pro.created_by) %>
                <%= Employee.find(pro.created_by).name %>
              <% else %>
                <%= pro.created_by %>
              <% end %>
            </td>
            <td><%= pro.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
            <td><%= link_to t("views.btn.edit"), edit_settings_promotion_path(pro),:class => 'btn btn-primary btn-sm waves-effect' %>
            </td>
          </tr>
          <% end %>
        </tbody>
      </table>
    </div>
  </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.promotion_code") %> - <%= t("views.right_panel.detail.promotion_code_txt") %> <%= t("views.right_panel.detail.promotion_txt2") %> <%= t("views.right_panel.detail.promotion_txt") %> <br>
        2) <%= t("views.right_panel.detail.start_date") %> - <%= t("views.right_panel.detail.start_date_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.promotion_txt") %> <br>
        3) <%= t("views.right_panel.detail.end_date") %> - <%= t("views.right_panel.detail.end_date_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.promotion_txt") %> <br>
        4) <%= t("views.right_panel.detail.start_time") %> - <%= t("views.right_panel.detail.start_time_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.promotion_txt") %> <br>
        5) <%= t("views.right_panel.detail.end_time") %> - <%= t("views.right_panel.detail.end_time_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.promotion_txt") %> <br>
        6) <%= t("views.right_panel.detail.promotion_day") %> - <%= t("views.right_panel.detail.promotion_day_txt") %> <br>
        7) <%= t("views.right_panel.detail.original_product") %> - <%= t("views.right_panel.detail.original_product_txt") %> <br>
        8) <%= t("views.right_panel.detail.created_by") %> - <%= t("views.right_panel.detail.created_by_txt") %> <%= t("views.right_panel.detail.promotion_txt") %> <br>
        9) <%= t("views.right_panel.detail.created_at") %> - <%= t("views.right_panel.detail.created_at_txt") %> <%= t("views.right_panel.detail.promotion_txt") %> <br>
        10) <%= t("views.right_panel.detail.actions") %> - <%= t("views.right_panel.detail.actions_txt3") %> <%= t("views.right_panel.detail.promotion_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.promotion_txt") %> <br>
        2) <%= t("views.right_panel.button.edit") %> - <%= t("views.right_panel.detail.edit_btn_txt") %> <%= t("views.right_panel.detail.promotion_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.back_txt") %> <%= t("views.right_panel.detail.dashboard_txt") %> <br>
        </p>
      </div>
    </div>  
  </div>
</div>

