<form id="projectadmin_budget_plan_form" style=""
    action=""  method="POST" enctype="multipart/form-data"
    onsubmit="budget_plan.save(); return false;">
    <input type="submit" style="display:none;visibility:hidden;" />
    <fieldset class="noborder">

    {include file='r/hidden.tpl' name="budget_plan_project_id" default=$project_id}
    {if $is_project_archiv_active}  
    <div style="margin-bottom: 5px; text-align: right;">
            {$i.projectadmin_archive_valid_until}:   
            {include file='r/table_select.tpl' name="budget_plan_history" default=$history_id
                list=$history_list id="id" text="valid_to_date" class="" noempty=TRUE script="onchange='budget_plan.load_other_archiv_history({$project_id});'"
                add_icons_file="basic_icon" add_icons_onclick="budget_plan.delete_archiv({$history_id});" add_icons_class="dialog_make_btn16 delete"}
    </div>           
    {/if}           
        <table style="width:100%; margin: 0px">
            <thead>
            <tr>
                <th>{$i.projectadmin_work_area}</th>
                <th>{$i.projectadmin_proportion_in_percent}</th>
                <th>{$i.projectadmin_start_date}</th>
                <th>{$i.projectadmin_planned_costs}</th>
                <th>{$i.projectadmin_planned_hours}</th>
                <th>{$i.projectadmin_end_date}</th>
                <th>{$i.projectadmin_last_change}</th>
                <th>{include file='r/checkbox-only.tpl' name="budget_plan_is_threshold" default=$is_threshold}&nbsp;{$i.projectadmin_threshold}</th>
            </tr>
            </thead>
            <tbody>
        {foreach item="item" from=$budget_plan_list}
            {assign var="proportion_name" value="budget_plan_proportion_`$item->area_id`"}
            {assign var="start_date_name" value="budget_plan_start_date_`$item->area_id`"}
            {assign var="end_date_name" value="budget_plan_end_date_`$item->area_id`"}
            {assign var="planned_costs_name" value="budget_plan_planned_costs_`$item->area_id`"}
            {assign var="planned_hours_name" value="budget_plan_planned_hours_`$item->area_id`"}
            {assign var="threshold_name" value="budget_plan_threshold_`$item->area_id`"}
            {assign var="last_changed_date_name" value="budget_plan_last_changed_date_`$item->area_id`"}
            
            {assign var="row_css" value=""}
            {if $item->fee_area_allocation_status == 10 || $item->fee_area_allocation_status == 30}
                {$row_css = 'currently_inactive_state'}
            {else if $item->fee_area_allocation_status == 40}
                {$row_css = 'inactive_state'}
            {/if}    

            <tr class="{$row_css}">
                <td>{$item->area_name}</td>
                <td style="white-space: nowrap; text-align:center;">{include file='r/table_input.tpl' name={$proportion_name} class="numberi18n t-smaller" default="{if isset($item->proportion)}{islongfloat value={$item->proportion*100}}{else}{islongfloat value={0}}{/if}" add_icons_file='warning' past_span_text='%'}</td>
                <td style="white-space: nowrap; text-align:center;">{include file='r/date.tpl' name={$start_date_name} default={$item->start_date->us_date()} title="" collapse='white-space: nowrap' class="dateUS t-small"}</td>
                <td style="white-space: nowrap; text-align:center;">{include file='r/table_input.tpl' name={$planned_costs_name} class="numberi18n" default="{if isset($item->planned_costs)}{islongfloat value={$item->planned_costs}}{else}{islongfloat value={0}}{/if}"}</td>
                <td style="white-space: nowrap; text-align:center;">{include file='r/table_input.tpl' name={$planned_hours_name} class="numberi18n t-small" default="{if isset($item->planned_hours)}{islongfloat value={$item->planned_hours}}{else}{islongfloat value={0}}{/if}"}</td>
                <td style="white-space: nowrap; text-align:center;">{include file='r/date.tpl' name={$end_date_name} default={$item->end_date->us_date()} title="" collapse='white-space: nowrap' class="dateUS t-small"}</td>
                <td style="white-space: nowrap; text-align:center;">{include file='r/date.tpl' name={$last_changed_date_name} default={$item->last_changed_date->us_date()} title="" collapse='white-space: nowrap' class="dateUS t-small"}</td>
                <td style="white-space: nowrap; text-align:center;"><span>{include file='r/table_input.tpl' name={$threshold_name} class="numberi18n t-smaller" default="{if isset($item->threshold)}{$item->threshold*100}{else}0{/if}" add_icons_file='warning' past_span_text='%'}</span></td>
            </tr>
        {/foreach}

        {assign var="first_item" value=$budget_plan_list.0}
        <tr><td colspan="8">&nbsp;</td></tr>

        <tr>
            <td>&nbsp;</td>
            <td style="white-space: nowrap">{include file='r/table_input.tpl' name="budget_plan_sum_allocated_proportion" class="numberi18n t-smaller" add_icons_file='warning' past_span_text='%' readonly=TRUE
                default="{if isset($first_item->sum_allocated_proportion)}{islongfloat value=$first_item->sum_allocated_proportion*100}{/if}"}</td>
            <td style="text-align:center">{$i.projectadmin_assigned}</td>
            <td style="text-align:center">{include file='r/table_input.tpl' name="budget_plan_allocated_planned_costs" class="numberi18n" readonly=TRUE
                default="{if isset($first_item->sum_allocated_planned_costs)}{islongfloat value=$first_item->sum_allocated_planned_costs}{/if}"}</td>
            <td style="text-align:center">{include file='r/table_input.tpl' name="budget_plan_allocated_planned_hours" class="numberi18n t-small" readonly=TRUE
                default="{if isset($first_item->sum_allocated_planned_hours)}{islongfloat value=$first_item->sum_allocated_planned_hours}{/if}"}</td>
            <td rowspan="2" style="text-align:center">
                <a id="budget_plan_allocate_automatically" style="text-align:center" class="dialog_make_text_btn ui-corner-all">
                    {$i.projectadmin_allocate_automatically}
                </a>
            </td>
            <td colspan="2"  rowspan="2">
                {include file='r/checkbox-only.tpl' name="budget_plan_is_budget_not_bound" default=$is_budget_not_bound}&nbsp;{$i.projectadmin_no_dependency_costs_hours}
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td style="white-space: nowrap">{include file='r/table_input.tpl' name="budget_plan_available_proportion" class="numberi18n t-smaller" default={islongfloat value={100}} add_icons_file='warning' past_span_text='%' readonly=TRUE}</td>
            <td style="text-align:center">{$i.projectadmin_to_assign}</td>
            <td style="text-align:center">{include file='r/table_input.tpl' name="budget_plan_available_planned_costs" class="numberi18n" readonly=TRUE
                 default="{islongfloat value=$sum_available->costs}"}</td>
            <td style="text-align:center">{include file='r/table_input.tpl' name="budget_plan_available_planned_hours" class="numberi18n t-small" readonly=TRUE
                default="{islongfloat value=$sum_available->hours}"}</td>
        </tr>
            </tbody>
        </table>
        {if $history_item->comment !== null && $history_item->comment !== ''}
            <div style="">
                {include file='r/view.tpl' title="projectadmin_remark" default=$history_item->comment}
            </div>           
        {/if}         
    </fieldset>

</form>

<div class="warningsmall ui-corner-all">{$i.projectadmin_to_assign_info}</div>