<% if vehicles.present? %>

  <% vehicles.each do |vehicle| %>
    <div class="row">

      <div class="container">

        <% if show_checkbox %>
          <%= check_box_tag "vehicle_ids[]", vehicle.id, false,  onchange: "updateLink()", data: { url: vehicle_path(vehicle).html_safe, text: vehicle.to_s }, class: "vehicle-checkbox appointment checkbox" %>
        <% else %>
          <div class='checkbox'>
          </div>
        <% end %>

        <div class='label-main'>
          <%= link_to vehicle.to_s, vehicle_path(vehicle) %>
        </div>

        <div class="label-sub">
          <div onclick="handleCopy(event)"><%= vehicle.vin.scan(/.{1,9}/)[0] if vehicle.vin %><b><%=vehicle.vin.scan(/.{1,9}/)[1] if vehicle.vin%></b></div>
          <% if show_customer %>
            <%= vehicle.customer %>
          <% end %>

           <% 
            mileage = vehicle.last_service_mileage
          %>

          <% if mileage %>
            <br/>
            <b><%= t(:label_last_service) %></b> <%= vehicle.last_service_date %>
            at <%= mileage %> <%= t(:label_miles) %>
          <% end %>

        </div>
        <br/>
      
      </div>

    </div>
  <% end %>

  <div class="actions">
    <%= will_paginate vehicles %>
  </div>

<%=t(:label_matching)%> <%=vehicles.count%> <%=t(:field_vehicles) %>

<% else %>
  <p><%=t(:label_no_vehicles)%> <%= params[:search] %>.</p>
<% end %>
