<div class="modal fade" id="list_geofence_modal" tabindex="-1" role="dialog"
     aria-labelledby="exampleModalLabel"
     aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header" style="border-bottom: 1px solid #cfcfcf;">
        <h5 class="modal-title" id="exampleModalLabel"><%= _("Geocercas assigned by item:") %> <%= Vehicle.find_by(tc_device_id: @device.id).try(:name) %></h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">×</span>
        </button>
      </div>
      <div class="modal-body">
        <div class="content-assign p-12">
          <div style="float: right;">
            <%= link_to t("add"), assign_geofences_to_device_post_geofences_path(@device) + '?url_refresh=' + site_user_site_user_geofences_url + '&' + request.query_parameters.to_query, remote: true, class: "btn-filter btn btn-light btn-sm fuse-ripple-ready btn-create", style: "margin-bottom: 10px;" if current_user.user_admin %>
          </div>

          <table id="content-geofences-assign" style="margin-top: 10px;" class="table table-hover table-striped">
            <thead>
              <tr>
                <th></th>
                <th><%= _("Geofence") %></th>
                <th><%= _("Action") %></th>
                <th><%= _("Time start") %></th>
                <th><%= _("Time end") %></th>
                <th><%= _("Min speed(Km/h)") %></th>
                <th><%= _("Max speed(Km/h)") %></th>
                <th><%= _("Days") %></th>
              </tr>
            </thead>
            <tbody>
              <% @device.device_geofences.each do |device_geofence| %>
                <tr>
                  <td>
                    <%= link_to '<i class="icon icon-trash"></i>'.html_safe, delete_assign_to_device_geofences_path + '?i=' + device_geofence.id.to_s + "&" + request.query_parameters.to_query, remote: true, method: :delete, data: { confirm: _("Are you sure?") }, class: "icon-opt button-delete" if current_user.user_admin %>
                    <%= link_to '<i class="icon icon-pencil"></i>'.html_safe, edit_assign_to_device_geofence_path(device_geofence.geofence) + '?i=' + device_geofence.id.to_s + "&" + request.query_parameters.to_query, remote: true, class: "icon-opt button-edit" if current_user.user_admin %>
                  </td>
                  <td><%= device_geofence.geofence.name %></td>
                  <td><%= device_geofence.action %></td>
                  <td><%= device_geofence.time_in %></td>
                  <td><%= device_geofence.time_out %></td>
                  <td><%= (device_geofence.min_speed*1.852).round(2) %></td>
                  <td><%= (device_geofence.max_speed*1.852).round(2) %></td>
                  <td><%= device_geofence.get_days_name %></td>
                </tr>
              <% end %>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>
