<div class="buttons">

    <a href="/admin/create/money_deposit" class="addbutton add-big">Új befizetés</a>
    <a href="/admin/balance_list" class="addbutton add-big">Egyenleg lista</a>
    <a href="/admin/lease" class="addbutton add-big">Bérlettípusok</a>
    <a href="/admin/expire_check" class="addbutton flag-big">Frissítés</a>

</div>

<div class="list half_width">
    {foreach $mod_array as $mod}

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

    {if $mod@first || $mod_array[$mod@index]->get_mod_money_income()->get_mi_date()|substr:5:2 != $mod_array[$mod@index-1]->get_mod_money_income()->get_mi_date()|substr:5:2}
        <span onclick="block_action('block_{$mod->get_mod_money_income()->get_mi_date()|substr:0:4}{$mod->get_mod_money_income()->get_mi_date()|substr:5:2}');" class="date_separator clickable">{$mod_array[$mod@index]->get_mod_money_income()->get_mi_date()|substr:0:4}.
            {$months[$mod_array[$mod@index]->get_mod_money_income()->get_mi_date()|substr:5:2]}
            <img src="/_image/open_folder.png">
            {assign var="sum" value=money_deposit::get_month_mod_sum($mod_array[$mod@index]->get_mod_money_income()->get_mi_date()|substr:0:4, $mod_array[$mod@index]->get_mod_money_income()->get_mi_date()|substr:5:2)}
            <span class="mod_sum">{if sum != null}{$sum|number_format:0:'':' '}{else}0{/if} Ft</span>
        </span>
        <div id="block_{$mod->get_mod_money_income()->get_mi_date()|substr:0:4}{$mod->get_mod_money_income()->get_mi_date()|substr:5:2}" class="month_block">

    {/if}
    <a href="{if $mod->is_expired()}#{else}/admin/money_deposit/{$mod->get_mod_id()}{/if}">
        <div class="list_item">
            <table class="money{if $mod->is_expired()} expired{/if}">
                <tr>
                    <td class="icon">
                        {if $mod->get_mod_money_income()->get_mi_payment_type_pt_id() == 1}
                            <img src="/_image/deposit.png">
                        {else}
                            <img src="/_image/transaction.png">
                        {/if}
                    </td>
                    <td>
                        {$mod->get_mod_user_kid()->get_uk_name()} {if $mod->is_expired()}(Lejárt: {$mod->get_mod_expire_date()}){/if}
                    </td>
                    <td class="date">
                        {$mod->get_mod_money_income()->get_mi_date(true)}
                    </td>
                    <td class="sum">
                        {$mod->get_mod_money_income()->get_mi_sum()|number_format:0:'':' '} Ft
                    </td>
                </tr>

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

    {if $mod@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>
