{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!-- $Id$ -->
<h1>{$layout.pagetitle}</h1>
<table class="lmsbox lms-ui-background-cycle">
	<colgroup>
		<col style="width: 1%;">
		{if $divisions}
			<col style="width: 1%;">
			<col style="width: 1%;">
		{/if}
		<col style="width: 93%;">
		<col style="width: 1%;">
		<col style="width: 1%;">
		<col style="width: 1%;">
		<col style="width: 1%;">
	</colgroup>
	<thead>
		<tr>
			<td class="nobr">
				{trans("ID")}
			</td>
			{if $divisions}
				<td class="nobr">
					{icon name="division" class="fa-fw"}
				</td>
				<td class="nobr">
					<strong>{trans("Division")}</strong>
				</td>
			{/if}
			<td class="nobr">
				<strong>{trans("Name")}</strong>
			</td>
			<td class="nobr">
				{trans("Estimated completion date")}
			</td>
			<td class="nobr">
				{trans("Nodes")}
			</td>
			<td class="nobr">
				{trans("Network Device Nodes")}
			</td>
			<td class="nobr">
				{button icon="save" label="Add investment project" href="?m=invprojectadd"}
			</td>
		</tr>
		{if $listdata.total != 0}
			<tr>
				<td class="lms-ui-pagination" colspan="{if $divisions}8{else}6{/if}">
					{include file="scroller.html" loop=$invprojectlist}
				</td>
			</tr>
		{/if}
	</thead>
	<tbody>
		{foreach $invprojectlist as $invproject}
			<tr class="highlight" data-name="{$invproject.name}">
				<td data-target-url="?m=invprojectedit&id={$invproject.id}">
					({$invproject.id|string_format:"#%d"})
				</td>
				{if $divisions}
					<td data-target-url="?m=invprojectedit&id={$invproject.id}" class="nobr">
						{icon name="division" class="fa-fw"}
					</td>
					<td data-target-url="?m=invprojectedit&id={$invproject.id}" class="nobr">
						{foreach $divisions as $division}
							{if $division.id == $invproject.divisionid}<strong>{$division.label|escape}</strong>{/if}
						{/foreach}
					</td>
				{/if}
				<td data-target-url="?m=invprojectedit&id={$invproject.id}" class="nobr">
					<strong>{$invproject.name|escape}</strong>
				</td>
				<td class="text-center{if $invproject.cdate && $invproject.cdate < $smarty.now} red{/if}">
					{if $invproject.cdate}
						<strong>{$invproject.cdate|date_format:"%Y/%m/%d"}</strong>
					{/if}
				</td>
				<td class="text-center nobr" data-target-url="?m=invprojectedit&id={$invproject.id}">
					{$invproject.nodes}
				</td>
				<td class="text-center nobr" data-target-url="?m=invprojectedit&id={$invproject.id}">
					{$invproject.netnodes}
				</td>
				<td class="text-right nobr">
					{button type="link" icon="edit" tip="Edit" href="?m=invprojectedit&id={$invproject.id}"}
					{button type="link" icon="delete" tip="Delete" class="delete-invproject" data_href="?m=invprojectdel&id={$invproject.id}"}
				</td>
			</tr>
		{foreachelse}
			<tr>
				<td colspan="{if $divisions}8{else}6{/if}" class="empty-table">
					{trans("There are no investment project.")}
				</td>
			</tr>
		{/foreach}
	</tbody>
	<tfoot>
		<tr class="dark">
			<td colspan="{if $divisions}8{else}6{/if}" class="text-right">
				{button icon="save" label="Add investment project" href="?m=invprojectadd"}
			</td>
		</tr>
	</tfoot>
</table>

<script>

	$(function() {
		$('.delete-invproject').click(function () {
			var name = $(this).closest('tr').attr('data-name');
			confirmDialog($t("Are you sure, you want to remove investment project '$a'?", name), this).done(function () {
				location.href = $(this).attr('data-href');
			});
			return false;
		});
	});

</script>
{/block}
