 <div class="row">
  <!-- Column One -->
  <div class="col-lg-6 col-md-6 col-sm-6">

    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
    <li class="nav-item">
        <a class="nav-link" data-toggle="tab" href="#Completed" role="tab">Completed</a>
      </li>
      <li class="nav-item">
        <a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Tables</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" data-toggle="tab" href="#rooms" role="tab">Rooms</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" data-toggle="tab" href="#orders" role="tab">Orders</a>
      </li>
    </ul>
    <!-- Nav tabs - End -->

    <div class="tab-content" style="max-height:670px; overflow:auto">
      <!--- Panel 0 - Completed Orders -->
      <div class="tab-pane" id="Completed" role="tabpanel">
        <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
          <%
            @completed_orders.each do |cpo|
              # ToDo no need check new
              # Assigned Id for new Order? Sale?
              unique_id = ""
              customer_id = ""

              # For CSS- Class for Order? Sale?
              # sale_status=""
              # if cpo.order_status == 'new'
              #   unique_id=cpo.booking_id

              #   customer_id=cpo.order_customer_id
              #   # check selected item and assign
              #   if @selected_item_type == "Sale"
              #     if cpo.order_id == @selected_item.order_id
              #       sale_status = sale_status + " selected-item"
              #     end
              #   end
              # else
              unique_id=cpo.sale_id
              customer_id=cpo.sale_customer_id
              sale_status="paid"
              # check selected item and assign
              if @selected_item != nil
                if unique_id == @selected_item.sale_id
                  sale_status = sale_status + " selected-item"
                end
              end
              # end
          %>
          <div class="card orders <%= sale_status  %>">
            <div class="card-block">

              <p class="hidden orders-id"><%= unique_id  %></p>
              <p class="hidden customer-id"><%= customer_id  %></p>
              <p class="hidden order-cid"><%= cpo.order_id  %></p>
              <h4 class="card-title orders-table"><%= cpo.table_name %></h4>
              <p class="card-text">
                Receipt No :
                <span class="orders-receipt-no">
                  <%= cpo.receipt_no %>
                </span>
              </p>
              <p class="card-text">
                Order Status :
                <span class="orders-order-status"><%= cpo.sale_status %></span>
                </small>
              </p>
            </div>
          </div>
          <%
            end
          %>
        </div>
      </div>

      <!--- Panel 1 - Table Orders -->
      <div class="tab-pane active" id="tables" role="tabpanel">
        <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
          <%
            @booking_orders.each do |bko|
              # No Show completed
              if bko.sale_status == 'completed'
                next
              end

              # Assigned Id for new Order? Sale?
              unique_id=""
              customer_id=""
              # For CSS- Class for Order? Sale?
              sale_status=""
              if bko.order_status == 'new'
                unique_id=bko.booking_id
                customer_id=bko.order_customer_id
                # check selected item and assign
                # if @selected_item != nil
                #   if bko.order_id == @selected_item.order_id
                #     sale_status = sale_status + " selected-item"
                #   end
                # end
              else
                unique_id=bko.sale_id
                customer_id=bko.sale_customer_id
                sale_status="sold"
                # check selected item and assign
                if @selected_item != nil
                  if unique_id == @selected_item.sale_id
                    sale_status = sale_status + " selected-item"
                  end
                end
              end
          %>
          <div class="card orders <%= sale_status  %>">
            <div class="card-block">
              <p class="hidden orders-id"><%= unique_id  %></p>
              <p class="hidden customer-id"><%= customer_id  %></p>
              <p class="hidden order-cid"><%= bko.order_id  %></p>
              <h4 class="card-title orders-table"><%= bko.table_name %></h4>
              <p class="card-text">
                Receipt No :
                <span class="orders-receipt-no">
                  <%= bko.receipt_no %>
                </span>
              </p>
              <p class="card-text">
                Order Status :
                <span class="orders-order-status"><%= bko.order_status %></span>
                </small>
              </p>
            </div>
          </div>
          <%
            end
          %>
        </div>
      </div>

      <!--- Panel 2 - Room Orders -->
      <div class="tab-pane" id="rooms" role="tabpanel">
        <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
          <%
            @booking_rooms.each do |rmo|
              # No Show completed
              if rmo.sale_status == 'completed'
                next
              end

              # Assigned Id for new Order? Sale?
              unique_id=""
              customer_id=""
              # For CSS- Class for Order? Sale?
              sale_status=""

              if rmo.order_status == 'new'
                unique_id=rmo.booking_id
                customer_id=rmo.order_customer_id
                # check selected item and assign
                # if @selected_item != nil
                #   if rmo.order_id == @selected_item.order_id
                #     sale_status = sale_status + " selected-item"
                #   end
                # end
              else
                unique_id=rmo.sale_id
                customer_id=rmo.sale_customer_id
                sale_status="sold"
                 # check selected item and assign
                if @selected_item != nil
                  if unique_id == @selected_item.sale_id
                    sale_status = sale_status + " selected-item"
                  end
                end
              end
          %>
          <div class="card orders <%= sale_status  %>">
            <div class="card-block">
              <p class="hidden orders-id"><%= unique_id  %></p>
              <p class="hidden customer-id"><%= customer_id  %></p>
              <p class="hidden order-cid"><%= rmo.order_id  %></p>
              <h4 class="card-title orders-table"><%= rmo.room_name %></h4>
              <p class="card-text">
                Receipt No :
                <span class="orders-receipt-no">
                  <%= rmo.receipt_no %>
                </span>
              </p>
              <p class="card-text">
                Order Status :
                <span class="orders-order-status"><%= rmo.order_status %></span>
                </small>
              </p>
            </div>
          </div>
          <%
            end
          %>
        </div>
      </div>

      <!--- Panel 3 - Orders -->
      <div class="tab-pane" id="orders" role="tabpanel">
        <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
          <%
            @orders.each do |odr|
              # No Show completed
              if odr.sale_status == 'completed'
                next
              end
              # Assigned Id for new Order? Sale?
              unique_id=""
              customer_id=""
              # For CSS- Class for Order? Sale?
              sale_status=""

              if odr.order_status == 'new'
                unique_id=odr.booking_id
                customer_id = odr.order_customer_id
                # if @selected_item != nil
                #   if odr.order_id == @selected_item.order_id
                #     sale_status = sale_status + " selected-item"
                #   end
                # end
              else
                unique_id=odr.sale_id
                customer_id = odr.sale_customer_id
                sale_status="sold"
                # check selected item and assign
                if @selected_item != nil
                  if unique_id == @selected_item.sale_id
                    sale_status = sale_status + " selected-item"
                  end
                end
              end
          %>
          <div class="card orders <%= sale_status  %>">
            <div class="card-block">
              <p class="hidden orders-id"><%= unique_id  %></p>
              <p class="hidden customer-id"><%= customer_id  %></p>
              <p class="hidden order-cid"><%= odr.order_id  %></p>
              <h4 class="card-title orders-table"><%= odr.table_name %></h4
               <p class="card-text">
                Receipt No :
                <span class="orders-receipt-no">
                  <%= odr.receipt_no %>
                </span>
              </p>
              <p class="card-text">
                Order Status :
                <span class="orders-order-status"><%= odr.order_status %></span>
                </small>
              </p>
            </div>
          </div>
          <%
            end
          %>
        </div>

      </div>
    </div>
    <!-- tabs - End -->
  </div>
  <!-- Column One -->

  <!-- Column Two -->
   <div class="col-lg-5 col-md-5 col-sm-5">
      <div class="card"  >
        <div class="card-header">
          <div><strong id="order-title">ORDER DETAILS -</strong></div>
        </div>
        <div class="card-block">
          <div class="card-title row">
            <div class="col-lg-6 col-md-6 col-sm-6">
              <p>Receipt No: <span id="receipt_no"><%=@selected_item.receipt_no rescue ' '%></span></p>
              <!-- <p>Cashier:  <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p> -->
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 text-right">
              <p>Date:  <span id="receipt_date"><%=@selected_item.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
            </div>
          </div>
          <div class="card-title row customer_detail hide">
            <div class="col-lg-6 col-md-6 col-sm-6">
              <p>Customer : <span id="customer_name"></span></p>

            </div>

          </div>
          <div class="card-text">
            <table class="table table-striped" id="order-items-table">
              <thead>
                <tr>
                  <th class="item-name">Items</th>
                  <th class="item-attr">QTY</td>
                  <th class="item-attr">Price</td>
                </tr>
              </thead>
              <tbody>
                <%
                  # For Sale Items
                  sub_total = 0
                  if @selected_item_type == "Sale"
                    @selected_item.sale_items.each do |sale_item|
                      sub_total = sub_total + sale_item.price
                %>
                <tr>
                  <td class='item-name'><%= sale_item.product_name %></td>
                  <td class='item-attr'><%= sale_item.qty %></td>
                  <td class='item-attr'><%= sale_item.price %></td>
                </tr>
                <%
                    end
                  end
                %>

                <%
                  # For Order Items
                  if @selected_item_type == "Order"
                    @selected_item.order_items.each do |order_item|
                      sub_total = sub_total + (order_item.qty*order_item.price)
                %>
                <tr>
                  <td class='item-name'><%= order_item.item_name %></td>
                  <td class='item-attr'><%= order_item.qty %></td>
                  <td class='item-attr'><%= order_item.qty*order_item.price %></td>
                </tr>
                <%
                    end
                  end
                %>
              </tbody>
            </table>
          </div>
          <div class="card-footer">
            <table class="table" id="order-charges-table" border="0">
              <tr>
                <td class="charges-name"><strong>Sub Total:</strong></td>
                <td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
              </tr>
              <!-- <tr>
                <td class="charges-name"><strong>Food:</strong></td>
                <td class="item-attr"><strong id="order-food"></strong></td>
              </tr>
              <tr>
                <td class="charges-name"><strong>Beverage:</strong></td>
                <td class="item-attr"><strong id="order-beverage"></strong></td>
              </tr> -->
              <tr>
                <td class="charges-name"><strong>Discount:</strong></td>
                <td class="item-attr"><strong id="order-discount">(<%=@selected_item.total_discount rescue 0%>)</strong></td>
              </tr>

              <!-- <tr>
                <td class="charges-name"><strong>Tax:</strong></td>
                <td class="item-attr"><strong id="order-Tax"><%=@selected_item.total_tax rescue 0%></strong></td>
              </tr>
              <tr>
                <td class="charges-name"><strong>Grand Total:</strong></td>
                <td class="item-attr"><strong id="order-grand-total"><%=@selected_item.grand_total rescue 0%></strong></td>
              </tr> -->

               <tr class="rebate_amount"></tr>
            </table>
          </div>
        </div>
      </div>
   </div>

  <!-- Column Three -->
  <div class="col-lg-1 col-md-1 col-sm-1">
    <!-- Waiter Buttons -->
    <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Add Order</button>
    <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button>
    <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button>
    <button type="button" id="customer" class="btn btn-primary btn-lg btn-block">Customer</button>
    <button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block">Req.Bill</button>
    <!-- Cashier Buttons -->
    <button type="button" id="discount" class="btn btn-primary btn-lg btn-block">Discount</button>
    <!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> -->
    <button type="button" id="pay-bill" class="btn btn-primary btn-lg btn-block">Pay</button>
    <button type="button" id="re-print" class="btn btn-primary btn-lg btn-block">Re.Print</button>
  </div>
</div>
