{if isset($fee)}
    <table class="col2btn">
        <tr><!-- Required -->
            <td>{$i.fees_project}</td>
            <td>{$fee->project}</td>
        </tr>
        <tr><!-- Required -->
            <td>{$i.fees_fee_date}</td>
            <td>{$fee->fee_date->us_date()}</td>
        </tr>
        <tr><!-- Required -->
            <td>{$i.fees_fee_no}</td>
            <td>{$fee->fee_no}</td>
        </tr>
        <tr><!-- Required -->
            <td>{$i.fees_value}</td>
            <td title="value">{isfloat value=$fee->value} {$project_global_currency}</td>
        </tr>
        {if $fee->turnover_rate neq 0}
            <tr>
                <td>{$i.fees_value_pre_tax}</td>
                <td title="value_pre_tax">{isfloat value=$fee->value_pre_tax} {$project_global_currency}</td>
            </tr>
        {/if}
        <tr>
            <td>{$i.fees_turnover_rate}</td>
            <td title="turnover_rate">{isturnover_rate value=$fee->turnover_rate add_percent_sign=true}</td>
        </tr>
        {if $project_use_currency && $fee->value_otcurr!=null}
            <tr>
                <td style="background:rgba(210, 220, 255, 0.3);">{$fee->currency_name} {$i.fees_value}</td>
                <td title="value_otcurr">{isfloat value=$fee->value_otcurr} {$fee->currency_abbreviation}</td>
            </tr>
            <tr>
                <td style="background:rgba(210, 220, 255, 0.3);">{$fee->currency_name} {$i.fees_value_pre_tax}</td>
                <td title="value_otcurr_pre_tax">{isfloat value=$fee->value_otcurr_pre_tax} {$fee->currency_abbreviation}</td>
            </tr> 
            <tr>
                <td style="background:rgba(210, 220, 255, 0.3);">{$i.fees_exchange_rate}</td>
                <td title="value/value_otcurr">
                    {if $fee->value_otcurr!=0}
                        {isfloat value=$fee->value/$fee->value_otcurr maxf=4}
                    {else}
                        0
                    {/if}
                </td>
            </tr> 
        {/if}
        {if $fee->purpose neq ''}
            <tr>
                <td>{$i.fees_purpose}</td>
                <td>{$fee->purpose}</td>
            </tr>   
        {/if}
        {if $fee->is_invoiced == false}
            <tr>
                <td>{$i.fees_is_transfered}</td>
                <td>{boolview value=$fee->is_transfered}</td>
            </tr>
        {/if}
        <tr>
            <td colspan="2"></td>
        </tr>
        <tr>
            <td>{$i.fees_is_done}</td>
            <td title="is_done">{boolview value=$fee->is_done}</td>
        </tr>
        {if !empty($fee->done_date) && !$fee->done_date->is_null()}
            <tr>
                <td>{$i.fees_done_date}</td>
                <td>{$fee->done_date->us_date()}</td>
            </tr>
        {/if}
        {if $fee->remited neq 0}
            <tr>
                <td>{$i.fees_remited}</td>
                <td title="remited">{isfloat value=$fee->remited}</td>
            </tr>
        {/if}
        {if $project_use_currency && $fee->remited_otcurr!=null}
            {if $fee->remited_otcurr neq 0}
                <tr>
                    <td style="background:rgba(210, 220, 255, 0.3);">{$fee->currency_name} {$i.fees_remited}</td>
                    <td title="remited_otcurr">{isfloat value=$fee->remited_otcurr} {$fee->currency_abbreviation}</td>
                </tr>
                <tr>
                    <td style="background:rgba(210, 220, 255, 0.3);">{$i.fees_exchange_rate}</td>
                    <td title="remited/remited_otcurr">{isfloat value=$fee->remited/$fee->remited_otcurr maxf=4}</td>
                </tr> 
            {/if}
        {/if}
        {if $fee->remit_purpose neq ''}
            <tr>
                <td>{$i.fees_remit_purpose}</td>
                <td>{$fee->remit_purpose|truncate:120:"..."}</td>
            </tr>
        {/if}
        {if !empty($fee->due_date) && !$fee->due_date->is_null()}
            <tr>
                <td>{$i.fees_due_date}</td>
                <td>{$fee->due_date->us_date()}</td>
            </tr>
        {/if}
        {if $fee->reminder_level neq 0}
            <tr>
                <td>{$i.fees_reminder_level}</td>
                <td>{$fee->reminder_level} <div class="dialog_make_btn14 urgent1_warn ui-corner-all"></div></td>
            </tr>
        {/if}
        {if !empty($fee->last_reminder_date) && !$fee->last_reminder_date->is_null()}
            <tr>
                <td>{$i.fees_last_reminder_date}</td>
                <td>{$fee->last_reminder_date->us_date()}</td>
            </tr>
        {/if}
        {if $fee->deduction neq 0}
            <tr>
                <td>{$i.fees_deduction}</td>
                <td title="deduction">{isfloat value=$fee->deduction}</td>
            </tr>
            {if $project_use_currency && $fee->deduction_otcurr!=null && !$fee->is_percentage}
                <tr>
                    <td style="background:rgba(210, 220, 255, 0.3);">{$fee->currency_name} {$i.fees_deduction}</td>
                    <td title="deduction_otcurr">{isfloat value=$fee->deduction_otcurr} {$fee->currency_abbreviation}</td>
                </tr>
            {/if}
            <tr>
                <td>{$i.fees_is_percentage}</td>
                <td title="is_percentage">{boolview value=$fee->is_percentage}</td>
            </tr>
        {/if}
        <tr>
            <td>{$i.fees_diff_pre_tax}</td>
            <td>{isfloat value=$fee->diff_pre_tax}</td>
        </tr>
        <tr>
            <td colspan="2"></td>
        </tr>
        <tr>
            <td>{$i.fees_fee_account_bank_code}</td>
            <td>{$fee->fee_account_bank_code}</td>
        </tr>
        <tr>
            <td>{$i.fees_fee_account_bank}</td>
            <td>{$fee->fee_account_bank}</td>
        </tr>
        <tr>
            <td>{$i.fees_fee_account_account_number}</td>
            <td>{$fee->fee_account_account_number}</td>
        </tr>
        <tr>
            <td>{$i.fees_fee_account_account_designation}</td>
            <td>{$fee->fee_account_account_designation|truncate:120:"..."}</td>
        </tr>
        <tr>
            <td colspan="2"></td>
        </tr>
        {if $fee->cost_centre_name neq ''}
            <tr>
                <td>{$i.fees_cost_centre_name}</td>
                <td>{$fee->cost_centre_name}</td>
            </tr>
        {/if}
        {if $fee->fee_category_name neq ''}
            <tr>
                <td>{$i.fees_fee_category_name}</td>
                <td>{$fee->fee_category_name}</td>
            </tr>
        {/if}
        {if $fee->project_phase_name neq ''}
            <tr>
                <td>{$i.fees_phase_name}</td>
                <td>{$fee->project_phase_name}</td>
            </tr>
        {/if}
        {if $fee->discount neq 0}
            <tr>
                <td>{$i.fees_discount}</td>
                <td>{$fee->discount*100}%</td>
            </tr>
            <tr>
                <td>{$i.fees_discount_date}</td>
                <td>{$fee->discount_date->us_date()}</td>
            </tr>
        {/if}
        {if !$fee->to_date->is_null()}
            <tr>
                <th></th>
                <th><h6>{$i.fees_fee_period}</h6></th>
            </tr>
            <tr title="{$i.fees_fee_period}">
                <td>{$i.filter_from_date}</td>
                <td>{$fee->from_date->us_date()}</td>
            </tr>
            <tr title="{$i.fees_fee_period}">
                <td>{$i.filter_to_date}</td>
                <td>{$fee->to_date->us_date()}</td>
            </tr>
        {/if}
        {if $fee->has_document}
            <tr>
                <td>{$i.fees_has_document}</td>
                <td>
                        {if empty($fee->correspondence)}
                            {boolview value=true}
                        {else}
                            <a href="{site_url url="start/open/correspondence/index/$xjxcookie/view/{$fee->correspondence->id}/"}"
                               onclick="window.open(this.href); return false;"
                               class="dialog_make_btn16 correspondence smallbtns ui-corner-all frstbtn" title="{$i.basic_correspondence}"></a>

                            {additional_button type="correspondence_edit_document" value=$fee->correspondence}
                            {$fee->correspondence->subject|truncate:50:"..."}
                        {/if}
                </td>
            </tr>        
        {/if}
        {if $fee->collective_ids}
            <tr>
                <td>{$i.fees_has_collective_bill}</td>
                <td>
                    <div class="many" id="inforight_collective_bills">
                        {foreach from=$fee->collective_bill_correspondences item=collective_bill}
                            <p>
                                {if empty($collective_bill)}
                                    x
                                {else}
                                    <a href="{site_url url="start/open/correspondence/index/$xjxcookie/view/{$collective_bill->id}/"}"
                                       onclick="window.open(this.href); return false;"
                                       class="dialog_make_btn16 correspondence smallbtns ui-corner-all frstbtn" title="{$i.basic_correspondence}"></a>

                                    {filelink_html($collective_bill->file_path, 'correspondence', $collective_bill->id, true, $collective_bill)}
                                    {$collective_bill->subject|truncate:50:"..."}
                                {/if}
                            </p>
                        {foreachelse}
                            &nbsp;
                        {/foreach}
                    </div>
                </td>
            </tr>
        {/if}
        {if $fee->is_calcexp}
            <tr>
                <td>{$i.fees_is_calcexp}</td>
                <td>
                    {fees_is_calcexp value=$fee->is_calcexp fee=$fee}
                    {boolview value=true}
                </td>
            </tr>
            {if isset($fee->payment)}
                <tr>
                    <td>{$i.fees_order}</td>
                    <td>
                        {$fee->payment->offer_no}
                        {if !empty($fee->payment->offer_no) && !empty($fee->payment->offer_title)} - {/if}
                        {$fee->payment->offer_title}
                        [{$fee->payment->offer_date->us_date()}]<br />
                        <small style="max-height:100px; overflow:auto; display:block;">{$fee->payment->offer_name|nl2br|truncate:500:"..."}</small>
                    </td>
                </tr>
            {/if}
            {if $fee->retention>0}
                <tr>
                    <td>{$i.fees_retention_title1}</td>
                    <td>
                        {float_to_usnumber($fee->retention)} 
                        {if $fee->retention_type eq 1}
                            %
                        {else}
                            {if $project_use_currency && $fee->value_otcurr!=null}
                                {$fee->currency_abbreviation}
                            {else}
                                {$project_global_currency}
                            {/if}
                        {/if}
                        {if $fee->retention_date>0}
                            {$i.fees_retention_at}
                            {$fee->retention_date->us_date()}
                        {/if}
                    </td>
                </tr>    
            {/if}
        {/if}
        {if $fee->finally_invoiced}
            <tr>
                <td>{$i.fees_finally_invoiced}</td>
                <td>{boolview value=$fee->finally_invoiced}</td>
            </tr>         
        {/if}

        <tr>
            <td colspan="2"></td>
        </tr>
        {foreach from=$fee->addi_fields item=field}
            <tr>
                {if $field->type eq US_exmodel::T_BLOCK}
                    <th colspan="2" style="text-align:center; {if isset($field->color)}background:{$field->color}{/if}">{$field->name}</th>
                {else}
                    <td style="{if isset($field->color)}background:{$field->color}{/if}">{$field->name}</td>
                    <td>
                        {assign var='field_id' value=$field->field}
                        {addiview field=$field value=$fee->$field_id item=$fee}
                    </td>
                {/if}
            </tr>
        {/foreach}
    
        <tr>
            <td>{$i.fees_user_name}</td>
            <td>{$fee->user_name}</td>
        </tr>
        <tr>
            <td>{$i.basic_created_by}</td>
            <td>{$fee->created_by_name}</td>
        </tr>     
        <tr>
            <td>{$i.basic_created_date}</td>
            <td>{$fee->created_date->us_date()}</td>
        </tr>    
        <tr>
            <td>{$i.basic_changed_by}</td>
            <td>{$fee->changed_by_name}</td>
        </tr>      
        <tr>
            <td>{$i.basic_change_date}</td>
            <td>{$fee->change_date->us_date()}</td>
        </tr>
    </table>
{/if}
