<html>
	<head>
		<style>
			{literal}
			.edit tr td{
				vertical-align : middle;
			}

			.money ,.quantity{
				text-align : right;
			}
			table.tablesorter {
				font-family:arial;
				background-color: #CDCDCD;
				margin:10px 0pt 15px;
				font-size: 8pt;
				width: 100%;
				text-align: left;
			}
			table.tablesorter thead tr th, table.tablesorter tfoot tr th {
				background-color: #e6EEEE;
				border: 1px solid #FFF;
				font-size: 8pt;
				padding: 4px;
			}
			table.tablesorter thead tr .header {
				background-image: url(bg.gif);
				background-repeat: no-repeat;
				background-position: center right;
				cursor: pointer;
			}
			table.tablesorter tbody td {
				color: #3D3D3D;
				padding: 4px;
				background-color: #FFF;
				vertical-align: top;
			}
			table.tablesorter tbody tr.odd td {
				background-color:#F0F0F6;
			}
			table.tablesorter thead tr .headerSortUp {
				background-image: url(asc.gif);
			}
			table.tablesorter thead tr .headerSortDown {
				background-image: url(desc.gif);
			}
			table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
			background-color: #8dbdd8;
			}
		{/literal}
		</style>
	</head>
	<body>
		
		<table style="width:100%;font-size:10px">
			<thead>
				<tr>
					<td colspan='4'>
						<p style="font-size:15px"><b>{$MOD.LBL_REPORT_SALES_BY_CONTRACTOR}</b></p>
					</td>
					<td style="text-align:right">
						Data wygenerowania raportu:<br>
						{$smarty.now|date_format:"%d.%m.%Y %H:%M:%S"}
					</td>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>
						{$MOD.LBL_DATE_FROM}: {$date_from_value}<br>
						{$MOD.LBL_DATE_TO}: {$date_to_value}
					</td>
					<td>
						<table>
							<tr>
								<td>
									{$MOD.LBL_DOCUMENT_SALES_TYPE}:
								</td>
								<td>
									{if @count($DOCUMENT_SALES_SELECTED) == 0}
										{foreach from=$MOD.DOCUMENT_SALES_LIST key="key" item="item"}
											{$item}<br>
										{/foreach}
									{else}
										{foreach from=$MOD.DOCUMENT_SALES_LIST key="key" item="item"}
												{if @in_array($key, $DOCUMENT_SALES_SELECTED) } {$item}<br>{/if}
										{/foreach}
									{/if}
								</td>
							</tr>
						</table>
					</td>
					<td>
						<table>
							<tr>
								<td>
									{$MOD.LBL_PRODUCT_GROUP}:
								</td>
								<td>
									{if @count($PRODUCT_GROUP_SELECTED) == 0}
										{foreach from=$APP_LIST_STRINGS.ecmproducts_group_ks_dom key="key" item="item"}
											{$item}<br>
										{/foreach}
									{else}
										{foreach from=$APP_LIST_STRINGS.ecmproducts_group_ks_dom key="key" item="item"}
											{if @in_array($key, $PRODUCT_GROUP_SELECTED) } {$item}<br>{/if}
										{/foreach}
									{/if}
								</td>
							</tr>
						</table>
					</td>
					<td>
						<table>
							<tr>
								<td>
									{$MOD.LBL_STOCK}:
								</td>
								<td>
									{if @count($STOCK_SELECTED) == 0}
										{foreach from=$STOCK_LIST key="key" item="item"}
											{$item}<br>
										{/foreach}
									{else}
										{foreach from=$STOCK_LIST key="key" item="item"}
												{if @in_array($key, $STOCK_SELECTED) } {$item}<br>{/if}
										{/foreach}
									{/if}
								</td>
							</tr>
						</table>
					</td>
					<td>
						{$MOD.LBL_TRADER}: 
						{if $TRADER_SELECTED ==''}
							Wszyscy
						{else}
							{foreach from=$TRADERS_LIST key="key" item="item"}
								{if $key==$TRADER_SELECTED }{$item}{/if}
							{/foreach}
						{/if}
					</td>
				</tr>
			</tbody>
		</table>
		<table id="myTable" class="tablesorter">
			<thead>
				<tr>
					<th>
						{$MOD.LBL_NAME}
					</th>
					<th width="10%">
						{$MOD.LBL_SALES_NETTO}
					</th>
					<th width="10%">
						{$MOD.LBL_COST_PURCHASE}
					</th>
					<th width="10%">
						{$MOD.LBL_INCOME_OVERHEAD}
					</th>
				</tr>
			</thead>
			<tbody>
			{foreach from=$DATA item=item key=item_name}
				<tr>
					<td>
						{$item.name}
					</td>
					<td class="money">
						{$item.total_netto|number_format:2:",":"."}
						{assign var=summary_netto value=$summary_netto+$item.total_netto}
					</td>
					<td class="money">
						{$item.price_purchase|number_format:2:",":"."}
						{assign var=summary_purchase value=$summary_purchase+$item.price_purchase}
					</td>
					<td class="money">
						{$item.total_netto-$item.price_purchase|number_format:2:",":"."}
						{assign var=tmp value=$item.total_netto-$item.price_purchase}
						({$tmp/$item.total_netto*100|number_format:2:",":"."} %)
					</td>
				</tr>
			{/foreach}
			</tbody>
			<tfoot>
				<tr>
					<td colspan="1">
						{$MOD.LBL_SUMMARY}
					</td>
					<td class="money">
						{$summary_netto|number_format:2:",":"."}
					</td>
					<td class="money">
						{$summary_purchase|number_format:2:",":"."}
					</td>
					<td class="money">
						{$summary_netto-$summary_purchase|number_format:2:",":"."}
						{assign var=tmp value=$summary_netto-$summary_purchase}
						({$tmp/$summary_netto*100|number_format:2:",":"."} %)
					</td>
				</tr>
			</tfoot>
		</table>

	</body>
</html>