<table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
  <thead>
    <tr>
      <th class="nd_center-cell">Date Added</th>
      <th class="nd_center-cell">MAC Address</th>
      <th class="nd_center-cell">Match OUI</th>
      <th class="nd_center-cell">Enabled</th>
      <th class="nd_center-cell">Reason</th>
      <th class="nd_center-cell">Email</th>
      <th class="nd_center-cell">Action</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td class="nd_center-cell"></td>
      <td class="nd_center-cell"><input data-form="add" name="mac" type="text"></td>
      <td class="nd_center-cell"><input data-form="add" name="matchoui" type="checkbox"></td>
      <td class="nd_center-cell"><input data-form="add" name="active" type="checkbox" checked></td>
      <td class="nd_center-cell"><input data-form="add" name="why" type="text"></td>
      <td class="nd_center-cell"><input data-form="add" name="cc"  type="email"></td>
      <td class="nd_center-cell">
        <button class="btn btn-small nd_adminbutton" name="add" type="submit"><i class="icon-plus-sign"></i> Add</button>
      </td>
    </tr>

    [% SET count = 0 %]
    [% WHILE (row = results.next) %]
    [% SET count = count + 1 %]
    <tr>
      <td class="nd_center-cell">[% row.date | html_entity %]</td>
      <td class="nd_center-cell">
        <input data-form="update" name="mac" type="text" value="[% row.mac | html_entity %]">
      </td>
      <td class="nd_center-cell">
        <input data-form="update" name="matchoui" type="checkbox" [% ' checked="checked"' IF row.matchoui %]>
      </td>
      <td class="nd_center-cell">
        <input data-form="update" name="active" type="checkbox" [% ' checked="checked"' IF row.active %]>
      </td>
      <td class="nd_center-cell">
        <input data-form="update" name="why" type="text" value="[% row.why | html_entity %]">
      </td>
      <td class="nd_center-cell">
        <input data-form="update" name="cc" type="email" value="[% row.cc | html_entity %]">
      </td>

      <td class="nd_center-cell">
        <button class="btn nd_adminbutton" name="update" type="submit"><i class="icon-save text-warning"></i></button>

        <button class="btn" data-toggle="modal"
          data-target="#nd_devdel-[% count | html_entity %]" type="button"><i class="icon-trash text-error"></i></button>

        <div id="nd_devdel-[% count | html_entity %]" class="nd_modal nd_deep-horizon modal hide fade" tabindex="-1"
          role="dialog" aria-labelledby="nd_devdel-label-[% count | html_entity %]" aria-hidden="true">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
            <h3 id="nd_devdel-label-[% count | html_entity %]">Are you sure?</h3>
          </div>
          <div class="modal-body">
            <blockquote>
              <p class="text-info">Monitor for &quot;[% row.mac | html_entity %]&quot; will be removed.</p>
            </blockquote>
            <input data-form="del" name="mac" type="hidden" value="[% row.mac | html_entity %]">
          </div>
          <div class="modal-footer">
            <button class="btn btn-success" data-dismiss="modal" aria-hidden="true">Cancel</button>
            <button class="btn btn-danger nd_adminbutton" name="del" data-dismiss="modal">Confirm</button>
          </div>
        </div>
      </td>
    </tr>
    [% END %]
  </tbody>
</table>

<script>
$(document).ready(function() {
  $('#data-table').dataTable({
    "columnDefs": [ 
      {
        "targets": [ 0, 2, 3, 6 ],
        "searchable": false
      },
      {
        "targets": [ 0, 2, 3, 6 ],
        "orderable": false
      }
    ],
[% INCLUDE 'ajax/datatabledefaults.tt' -%]
  } );
} );
</script>

