<div class="buttons">

	<a href="/admin/create/money_income" class="addbutton add-big">Új bevétel</a>
	<a href="/admin/money_income_category" class="addbutton add-big">Bevétel kategóriák kezelése</a>

</div>

<div class="list full_width">
	{foreach $mi_array as $mi}

	{if !$mi@first && $mi_array[$mi@index]->get_mi_date()|substr:5:2 != $mi_array[$mi@index-1]->get_mi_date()|substr:5:2}
		</div>
	{/if}

	{if $mi@first || $mi_array[$mi@index]->get_mi_date()|substr:5:2 != $mi_array[$mi@index-1]->get_mi_date()|substr:5:2}
		<span onclick="block_action('block_{$mi->get_mi_date()|substr:0:4}{$mi->get_mi_date()|substr:5:2}');" class="date_separator clickable">{$mi_array[$mi@index]->get_mi_date()|substr:0:4}.
			{$months[$mi_array[$mi@index]->get_mi_date()|substr:5:2]}
			<img src="/_image/open_folder.png">
		</span>
		<div id="block_{$mi->get_mi_date()|substr:0:4}{$mi->get_mi_date()|substr:5:2}" class="month_block">

	{/if}
	<a href="/admin/money_income/{$mi->get_mi_id()}">
		<div class="list_item">
			<table class="money">
				<tr>
					<td class="icon">
						{if $mi->get_mi_payment_type_pt_id() == 1}
							<img src="/_image/income.png">
						{else}
							<img src="/_image/transaction.png">
						{/if}
					</td>
					<td class="quarter_width">
						{$mi->get_mi_date()}
					</td>
					<td class="no_mobile_show quarter_width">
						{if $mi->get_mi_money_income_category_mic_id()}{$mi->get_mi_mic()->get_mic_name()}{else}<span class="italic">nincs megadva</span>{/if}
					</td>
					<td class="quarter_width">
						{$mi->get_mi_item()}
					</td>
					<td class="sum">
						{$mi->get_mi_sum()|number_format:0:'':' '} Ft
					</td>
				</tr>

			</table>
		</div>
	</a>

	{if $mi@last}
	</div>
	{/if}

	{/foreach}

</div>


<script>

function open_block(block_id) {
	$("#"+block_id).slideDown("slow");
}

function close_block(block_id) {
	$("#"+block_id).slideUp("slow");
}

function block_action(block_id) {
	if ($("#"+block_id).is(':hidden')) {
		open_block(block_id);
	}
	else {
		close_block(block_id);
	}
}


$( document ).ready(function() {
    var divs = $( "div[class=month_block]" );
	$( ".list" ).find( divs ).hide();
	var div_list = $( ".list" ).find( divs );

	open_block(div_list[0].id);

});


</script>
