<% html_title l(:label_customers) %> <% phone = ->(digits) { digits.present? ? number_to_phone(digits.gsub(/\D/, '').to_i, area_code: true) : '' } %>
<% if User.current.allowed_to?(:add_customers, nil, global: true) %> <%= link_to sprite_icon('add', l(:label_new_customer)), new_customer_path, class: 'icon icon-add' %> <% end %> <% if User.current.admin? %> <%= link_to sprite_icon('reload', l(:label_sync)), qbo_sync_path, class: 'icon icon-reload' %> <% end %>

<%= l(:label_customers) %>

<%= form_tag(customers_path, method: :get, id: 'customer-search-form') do %> <% end %> <% if @customers.empty? %>

<%= @search.present? ? l(:label_no_customers, search: @search) : l(:label_no_data) %>

<% else %> <% if @best_first %>

<%= l(:text_customers_best_match, count: @customer_count) %>

<% end %>
<%= sort_header_tag('name', caption: l(:field_name)) %> <%= sort_header_tag('phone', caption: l(:label_primary_phone)) %> <%= sort_header_tag('mobile', caption: l(:label_mobile_phone)) %> <%= sort_header_tag('updated', caption: l(:field_updated_on), default_order: 'desc') %> <% @customers.each do |customer| %> <% end %>
<%= l(:label_issue_plural) %>
<%= link_to customer.name, customer_path(customer.id) %> <%= phone.call(customer.phone_number) %> <%= phone.call(customer.mobile_phone_number) %> <%= @issue_counts[customer.id] || 0 %> <%= format_time(customer.updated_at) if customer.updated_at %>
<%= pagination_links_full @customer_pages, @customer_count %> <% end %>

<%= render partial: 'qbo/stats' %>