<tal:block define="global current_tab_url string:admin_mapduplicatelocations_html" />
<metal:block use-macro="here/admin_pt/macros/page">

<metal:block fill-slot="tab_contents"
		tal:define="map_url here/getGeoMapToolPath;
					portal_map here/getGeoMapTool;
					sort_on python:request.get('sort_on', 'title');
					sort_order python:request.get('sort_order', '');">

<script type="text/javascript">
<!--
	function toggleSelect(caller, name)
	{
		var frm = caller.form;
		for(var i=0; i<frm.elements.length; i++){
			if (frm.elements[i].name != name)
				continue;
			frm.elements[i].checked = caller.checked;
		}
	}
//-->;
</script>


<p i18n:translate="" class="cleaner">
	Showing duplicate locations that share <em i18n:name="all" i18n:translate="">all</em> of the selected criteria:
</p>

<form method="get" tal:define="
  global criteria python:request.get('criteria', ['type', 'latlon', 'address']);
  global criteria_params python:'&amp;'.join('criteria%3Alist=' + c for c in criteria)">
    <tal:block repeat="item python:[
      {'name': 'type', 'label': 'category'},
      {'name': 'title', 'label': 'title'},
      {'name': 'address', 'label': 'address'},
      {'name': 'latlon', 'label': 'coordinates'},
    ]">
        <tal:block define="id string:${item/name}_dupe">
            <label tal:attributes="for id"
              tal:content="item/label" i18n:translate="" />
            <input type="checkbox" tal:attributes="
              id id;
              value item/name;
              name string:criteria:list;
              checked python:test(item['name'] in criteria, 'checked', None)" />
            &nbsp;&nbsp;
        </tal:block>
    </tal:block>

    <input type="submit" value="refresh" />
</form>

<br clear="all" />

<form method="post" name="frmDeleteLocations" id="frmDeleteLocations" action="deleteLocations">
	<tal:block define="
			map_ob portal_map;
			start python:int(request.get('start', '0'));
			step python:int(request.get('step', '50'));
			end python:int(request.get('end', start + step));
			next_start python:end;
			next_end python:end + step;
			prev_start python:start - step;
			prev_end python:end - step;
			records python:here.getDuplicateLocations(criteria=criteria,
				sort_on=sort_on, sort_order=sort_order);
			records_len python:len(records);
			records python:records[start:end];
			edit_mode python:True;
			sortable python:True;
			base_link_url string:${request/ACTUAL_URL}?${criteria_params}&;
			first_letter python:None">
		<a tal:condition="python:prev_start >=0" tal:attributes="href string:./admin_mapduplicatelocations_html?start=${prev_start}&amp;end=${prev_end}&amp;sort_on=${sort_on}&amp;sort_order=${sort_order}&amp;${criteria_params}" i18n:translate=""><<< Prev 50</a>
		<a tal:condition="python:next_start < records_len" tal:attributes="href string:./admin_mapduplicatelocations_html?start=${next_start}&amp;end=${next_end}&amp;sort_on=${sort_on}&amp;sort_order=${sort_order}&amp;${criteria_params}" i18n:translate="">Next 50 >>></a>
		<table metal:use-macro="here/locations_table_html/macros/main">
		</table>
	</tal:block>
</form>

</metal:block>

</metal:block>
