<tal:comment>
This macro uses the following variables:
- records
- sort_on
- sort_order
- map_url
- map_ob
- edit_mode: bool - enable/disable delete and edit
- sortable: add links that sort the table in its header
- first_letter
</tal:comment>
<table metal:define-macro="main" width="90%" class="datatable">
	<thead>
		<tr>
			<th tal:condition="edit_mode" width="1%">
				<input type="checkbox" onclick="javascript: toggleSelect(this, 'locations:list')" />
			</th>
			<th scope="col" class="scope-col" i18n:translate="">Category</th>
			<tal:block tal:condition="python:sort_on=='title'">
				<tal:block tal:condition="python:sort_order==''">
					<th scope="col" class="scope-col">
						<a tal:attributes="href string:${base_link_url}sort_on=title&amp;sort_order=reverse&amp;first_letter=${first_letter}">
							<span i18n:translate="">Title</span>
						</a>
					</th>
				</tal:block>
				<tal:block tal:condition="python:sort_order=='reverse'">
					<th scope="col" class="scope-col">
						<a tal:attributes="href string:${base_link_url}sort_on=title&amp;first_letter=${first_letter}">
							<span i18n:translate="">Title</span>
						</a>
					</th>
				</tal:block>
			</tal:block>
			<tal:block tal:condition="python:sort_on!='title'">
				<th scope="col" class="scope-col">
					<a tal:omit-tag="not: sortable" tal:attributes="href string:${base_link_url}sort_on=title&amp;first_letter=${first_letter}" i18n:translate="">Title</a>
				</th>
			</tal:block>
			<tal:block tal:condition="python:sort_on=='geo_address'">
				<tal:block tal:condition="python:sort_order==''">
					<th scope="col" class="scope-col">
						<a tal:attributes="href string:${base_link_url}sort_on=geo_address&amp;sort_order=reverse&amp;first_letter=${first_letter}">
							<span i18n:translate="">Address</span>
						</a>
					</th>
				</tal:block>
				<tal:block tal:condition="python:sort_order=='reverse'">
					<th scope="col" class="scope-col">
						<a tal:attributes="href string:${base_link_url}sort_on=geo_address&amp;first_letter=${first_letter}">
							<span i18n:translate="">Address</span>
						</a>
					</th>
				</tal:block>
			</tal:block>
			<tal:block tal:condition="python:sort_on!='geo_address'">
				<th scope="col" class="scope-col">
					<a tal:omit-tag="not: sortable" tal:attributes="href string:${base_link_url}sort_on=geo_address&amp;first_letter=${first_letter}" i18n:translate="">Address</a>
				</th>
			</tal:block>
			<tal:block tal:condition="python:sort_on=='geo_latitude'">
				<tal:block tal:condition="python:sort_order==''">
					<th scope="col" class="scope-col">
						<a tal:attributes="href string:${base_link_url}sort_on=geo_latitude&amp;sort_order=reverse&amp;first_letter=${first_letter}">
							<span i18n:translate="">Latitude</span>
						</a>
					</th>
				</tal:block>
				<tal:block tal:condition="python:sort_order=='reverse'">
					<th scope="col" class="scope-col">
						<a tal:attributes="href string:${base_link_url}sort_on=geo_latitude&amp;first_letter=${first_letter}">
							<span i18n:translate="">Latitude</span>
						</a>
					</th>
				</tal:block>
			</tal:block>
			<tal:block tal:condition="python:sort_on!='geo_latitude'">
				<th scope="col" class="scope-col">
					<a tal:omit-tag="not: sortable" tal:attributes="href string:${base_link_url}sort_on=geo_latitude&amp;first_letter=${first_letter}" i18n:translate="">Latitude</a>
				</th>
			</tal:block>
			<tal:block tal:condition="python:sort_on=='geo_longitude'">
				<tal:block tal:condition="python:sort_order==''">
					<th scope="col" class="scope-col">
						<a tal:attributes="href string:${base_link_url}sort_on=geo_longitude&amp;sort_order=reverse&amp;first_letter=${first_letter}">
							<span i18n:translate="">Longitude</span>
						</a>
					</th>
				</tal:block>
				<tal:block tal:condition="python:sort_order=='reverse'">
					<th scope="col" class="scope-col">
						<a tal:attributes="href string:${base_link_url}sort_on=geo_longitude&amp;first_letter=${first_letter}">
							<span i18n:translate="">Longitude</span>
						</a>
					</th>
				</tal:block>
			</tal:block>
			<tal:block tal:condition="python:sort_on!='geo_longitude'">
				<th scope="col" class="scope-col">
					<a tal:omit-tag="not: sortable" tal:attributes="href string:${base_link_url}sort_on=geo_longitude&amp;first_letter=${first_letter}" i18n:translate="">Longitude</a>
				</th>
			</tal:block>
			<th tal:condition="edit_mode">&nbsp;</th>
		</tr>
	</thead>
	<tbody tal:define="records python:test(records != None, records, map_ob.search_geo_objects());">
		<tr tal:condition="not:records">
			<td colspan="7" i18n:translate="">No locations found</td>
		</tr>
		<tr tal:repeat="record records" tal:condition="records">
			<td tal:condition="edit_mode"><input type="checkbox" name="locations:list" tal:attributes="value python:record.absolute_url(1)" /></td>
			<td>
				<img tal:attributes="src string:${map_url}/getSymbolPicture?id=${record/geo_type};
				                     alt python:map_ob.getSymbolTitle(record.geo_type);
				                     title python:map_ob.getSymbolTitle(record.geo_type);" />
			</td>
			<td><a tal:attributes="href string:${record/absolute_url}" tal:content="record/title_or_id" /></td>
			<td tal:content="record/geo_location/address" />
			<td tal:content="record/geo_location/lat" />
			<td tal:content="record/geo_location/lon" />
			<td tal:condition="edit_mode"><a tal:attributes="href string:${record/absolute_url}/edit_html" title="Edit location" i18n:translate="" i18n:attributes="title">edit</a></td>
		</tr>
		<tr tal:condition="python: edit_mode and records">
			<td></td>
			<td colspan="7"><input type="submit" name="delete" value="Delete" i18n:attributes="value" /></td>
		</tr>
	</tbody>
</table>
