<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-table/jquery.appendGrid-1.3.1.css"/>
<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-ui/themes/base/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" href="modules/EcmReports/TableSorter/css/theme.blue.css"/>
<link rel="stylesheet" type="text/css" href="modules/EcmReports/TableSorter/css/theme.blue2.css"/>
<style>
{literal}
#MainTable {
  width: 100%;
  font-size: 8pt;
  border-collapse: collapse;
}
  
#MainTable .text-left {
	text-align: left;
}

#MainTable .text-right {
	text-align: right;
}

#MainTable .text-center {
	text-align: center;
}

#MainTable .border-bottom {
	border-collapse: collapse;
	border-bottom: 1px solid black;
}

#MainTable .border-top {
	border-collapse: collapse;
	border-top: 1px solid black;
}

{/literal}
</style>
</head>
<body>
<div>
{assign var=docCount value=$DOCUMENTS|@count}
Pierwsza linia - ilość, druga - wartość.
<table id="MainTable">
	<thead>
		<tr>
			<th class="text-left border-top border-bottom" style="width: 8%;">Indeks</th>
			{if $SHOW_DETAILS=='checked'}
				<th class="text-center border-top border-bottom" style="width: 2%;" data-sorter="false">&nbsp</th>
			{/if}
			<th class="text-right border-top border-bottom" style="width: 8%;">Stan początkowy</th>
			<th class="text-right border-top border-bottom" style="width: 4%;">Rozchody</th>
			<th class="text-right border-top border-bottom" style="width: 4%;">Przychody</th>
			{if $SHOW_DETAILS=='checked'}
				{foreach from=$DOCUMENTS item=i key=k }
					{assign var=tmp value="_"|explode:$k}
					{assign var=key value=$tmp[0]}
					<th class="text-right border-top border-bottom">{$MOD_NAMES.$key}{if $tmp[1]=='0'}+{else}-{/if}</th>
				{/foreach}
			{/if}
			<th class="text-right border-top border-bottom" style="width: 8%;">Stan końcowy</th>
		</tr>
	</thead>
	<tbody>
	{foreach from=$DATA item=row}
	<tr>
		<td class="text-left border-bottom"><a href="index.php?module=EcmProducts&action=DetailView&record={$row.id}" target="_blank">{$row.code}<br>{$row.name}</a></td>
		{if $SHOW_DETAILS=='checked'}
			<td class="text-center border-bottom">
				{if $row.doc_details|@count > 0}
				<img src="modules/EcmReports/mz_tpl/img/down.png" onclick="ShowHideDocDetails('{$row.id}');" style="cursor: pointer;" id="doc_trigger_{$row.id}"/>
				{/if}
			</td>
		{/if}
		<td class="text-right border-bottom">{$row.start_state|number_format:2:",":""}<br>{$row.start_value|number_format:2:",":"."}</td>
		<td class="text-right border-bottom">{$row.in_state|number_format:2:",":""}<br>{$row.in_value|number_format:2:",":"."}</td>
		<td class="text-right border-bottom">{$row.out_state|number_format:2:",":""}<br>{$row.out_value|number_format:2:",":"."}</td>
		{if $SHOW_DETAILS=='checked'}
			{foreach from=$row.op item=i key=k}
				<td class="text-right border-bottom">{$i.qty|number_format:2:",":""}<br>{$i.value|number_format:2:",":"."}</td>
			{/foreach}
		{/if}
		<td class="text-right border-bottom">{$row.end_state|number_format:2:",":""}<br>{$row.end_value|number_format:2:",":"."}</td>
	</tr>
	{if $SHOW_DETAILS=='checked'}
		{foreach from=$row.doc_details item=doc_row}
			<tr class="doc_{$row.id}" style="display: none;">
				<td class="border-bottom">&nbsp;</td>
				<td class="border-bottom">&nbsp;</td>
				<td class="border-bottom">&nbsp;</td>
				{foreach from=$DOCUMENTS item=i key=k }
					{assign var=key value=$k}
					<td class="text-right border-top border-bottom">
						<a target="_blank" href="index.php?module={$doc_row.$key.parent_type}&action=DetailView&record={$doc_row.$key.parent_id}">{$doc_row.$key.parent_name}</a>
					</td>
				{/foreach}
				<td class="border-bottom">&nbsp;</td>
				<td class="border-bottom">&nbsp;</td>
				<td class="border-bottom">&nbsp;</td>
			</tr>
		{/foreach}
	{/if}
	{/foreach}
	<tr>
		<td class="text-left border-bottom">Suma</td>
		{if $SHOW_DETAILS=='checked'}
		<td class="text-center border-bottom">&nbsp;</td>
		{/if}
		<td class="text-right border-bottom">{$sum.sp_qty|number_format:2:",":""}<br>{$sum.sp_val|number_format:2:",":"."}</td>
		<td class="text-right border-bottom">{$sum.in_qty|number_format:2:",":""}<br>{$sum.in_val|number_format:2:",":"."}</td>
		<td class="text-right border-bottom">{$sum.out_qty|number_format:2:",":""}<br>{$sum.out_val|number_format:2:",":"."}</td>
		{if $SHOW_DETAILS=='checked'}
		{foreach from=$DOCUMENTS item=i key=k }
			{assign var=key value=$k}
				<td class="text-right border-bottom">{$doc_sum.$key.qty|number_format:2:",":""}<br>{$doc_sum.$key.val|number_format:2:",":"."}</td>
		{/foreach}
		{/if}
		<td class="text-right border-bottom">{$sum.sk_qty|number_format:2:",":""}<br>{$sum.sk_val|number_format:2:",":"."}</td>
	</tr>
	</tbody>
</table>
</div>
<script type="text/javascript" src="modules/EcmReports/TableSorter/js/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="modules/EcmReports/TableSorter/js/jquery.tablesorter.staticrow.min.js"></script>
<script type="text/javascript" src="modules/EcmReports/TableSorter/js/jquery.tablesorter.widgets.js"></script>
<script type="text/javascript" src="modules/EcmReports/javascript/jquery.blockUI.js"></script>
<script type="text/javascript" src="modules/EcmReports/mz_tpl/StockOperationsCheck/StockOperationsCheck.js"></script>
</body>
</html>