<ul>
    {if empty($correspondence->file_path) && (!isset($correspondence->object_is_editable) || $correspondence->object_is_editable)}
        {* Document has no file *}
        <li>{$i.correspondence_file_missing}</li>
    {else if $corr_locked_by===false || $corr_locked_by->session_uniqid===$curr_unique_id}
        {* Document is available *}
        {if !isset($correspondence->object_is_editable) || $correspondence->object_is_editable}
            {if $action_edit neq false}
                {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_edit_document
                    icon='open_win' action=$action_edit}
            {elseif $is_test_system}
                <li style="font-size:70%; color:#CC0000; text-align:right;">TEST INFO: edit</li>
            {/if}
            {if $action_print_preview neq false}
                {include file="r_basic/functionmenuitem.tpl" title=$i.basic_print_preview
                    icon='open_printpreview' action=$action_print_preview}
            {elseif $is_test_system}
                <li style="font-size:70%; color:#CC0000; text-align:right;">TEST INFO: print_preview</li>
            {/if}
            {if $action_print neq false}
                {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_print
                    icon='print' action=$action_print}
            {elseif $is_test_system}
                <li style="font-size:70%; color:#CC0000; text-align:right;">TEST INFO: print</li>
            {/if}
            {if $action_print_dbg neq false}
                {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_print_dbg
                    class="user_debug_mode_item" action=$action_print_dbg}
            {/if}
            {if $action_change_security neq false}
                {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_change_security
                    action=$action_change_security}
            {elseif $is_test_system}
                <li style="font-size:70%; color:#CC0000; text-align:right;">TEST INFO: change_security</li>
            {/if}
            {if $action_send_simple neq false}
                {if $correspondence->is_serial}
                    {include file="r_basic/functionmenuitem.tpl" title="`$i.correspondence_send_simple` `$i.correspondence_send_simple_warn`"
                        icon="email" action=$action_send_simple}
                {else}
                    {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_send_simple
                        icon="email" action=$action_send_simple}
                {/if}
            {elseif $is_test_system}
                <li style="font-size:70%; color:#CC0000; text-align:right;">TEST INFO: send_simple</li>
            {/if}
            {if $correspondence->is_serial}
                <li style="padding-left:10px;">
                    <ul>
                        {if $action_send_pers neq false}
                            {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_send_pers
                                icon="email2" action=$action_send_pers}
                        {elseif $is_test_system}
                            <li style="font-size:70%; color:#CC0000; text-align:right;">TEST INFO: send_pers</li>
                        {/if}
                        {if $action_send_cc neq false}
                            {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_send_cc
                                icon="email2" action=$action_send_cc}
                        {elseif $is_test_system}
                            <li style="font-size:70%; color:#CC0000; text-align:right;">TEST INFO: send_cc</li>
                        {/if}
                        {if $action_send_bcc neq false}
                            {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_send_bcc
                                icon="email2" action=$action_send_bcc}
                        {elseif $is_test_system}
                            <li style="font-size:70%; color:#CC0000; text-align:right;">TEST INFO: send_bcc</li>
                        {/if}
                    </ul>
                </li>
            {/if}
            {if $action_download neq false}
                {include file="r_basic/functionmenuitem.tpl" title=$i.basic_download
                    icon='open_download' action=$action_download}
            {elseif $is_test_system}
                <li style="font-size:70%; color:#CC0000; text-align:right;">TEST INFO: download</li>
            {/if}
            {if $corr_use_dokspace}
                {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_dokspace_upload
                    icon="web_call" action=$action_dokspace_upload}
            {/if}
            {if $user_can_edit && $correspondence->is_valid_file_type}
                {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_attachments
                    icon="" action="correspondence.attachment.open('{$correspondence->id}')"}
                {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_duplicate_document
                    icon="copy" action="correspondence.duplicate_document('{$correspondence->id}')"}
                {if $action_update_fulltext neq false}
                    {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_update_fulltext
                        action=$action_update_fulltext}
                {elseif $is_test_system}
                    <li style="font-size:70%; color:#CC0000; text-align:right;">TEST INFO: update_fulltext</li>
                {/if}
            {/if}
        {/if}
        {if $can_export_to_fees}
            {if isset($is_q_plan) && $is_q_plan}
                {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_corr2fee
                    icon="fees" action="qplan.correspondence.open_corr2fee('`$correspondence->id`');"}
            {else}
                {include file="r_basic/functionmenuhrefitem.tpl" title=$i.correspondence_corr2fee
                    icon="fees" action={site_url url="start/open/feeadmin/index/`$xjxcookie`/corr2fee/`$correspondence->id`"}}
            {/if}
        {/if}
        {include file="r_basic/functionmenuhrefitem.tpl" title=$i.correspondence_corr2outbox
            icon="inoutbox" action={site_url url="start/open/mailinboxandoutbox/index/`$xjxcookie`/corr2outbox/`$correspondence->id`"}}
    {/if}
    {if $corr_locked_by!==false}
        {if (!isset($correspondence->object_is_editable) || $correspondence->object_is_editable)}
            {if $curr_user_id eq $corr_locked_by->staff_id}
                {* Document is locked by current user *}
                {include file="r_basic/functionmenuitem.tpl" title="{$i.correspondence_rem_lock_self} ({$i.correspondence_rem_lock_self1})"
                    icon="cancel_2d" action="correspondence.rem_lock_do('{$correspondence->id}');"}
            {else}
                {* Document is locked by a different user *}
                {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_rem_lock
                    icon="cancel_2d" action="correspondence.rem_lock('{$correspondence->id}', '{$corr_locked_by->staff_name|escape:'quotes'}');"}
            {/if}
        {/if}
    {/if}
    {include file="r_basic/functionmenuhrefitem.tpl" title=$i.correspondence_add_task icon="opentasks"
    action={site_url url="start/open/opentasks/index/`$xjxcookie`/add_for_correspondence/`$correspondence->id`"}}
    {if $action_change_security_mode!==false}<!-- Change to new security mode -->
        {include file="r_basic/functionmenuitem.tpl" title=$i.correspondence_change_security_mode
            icon="update" action="{$action_change_security_mode};"}
    {/if}
</ul>