<form id="correspondence_delivery_note_select_form" onsubmit="return false;" action="">
    {include file='r/hidden.tpl' name="correspondence_delivery_note_select_delivery_note_id" default=$delivery_note_info->id}
    <fieldset class="borderbottom sepnext">
        {include file='r/input-corresondence_type.tpl' name="correspondence_delivery_note_select_type" title="correspondence_type" class="required" list=$correspondence_types_delivery_notes}
        {include file='r/radio.tpl' name="correspondence_delivery_note_select_multi_mode" title="correspondence_delivery_note_multi_mode" class="required"
            list=$correspondence_multi_modes id="id" text="title" default=0}
    </fieldset>
    <fieldset class="noborder sepnext">
        <legend>{$i.correspondence_delivery_note_select_files}:</legend>
        <table>
            <thead>
                <tr>
                    <th scope="col" style="min-width:20%;">{$i.drawings_inout_drawing_id}</th>
                    <th scope="col" style="min-width:80px;">
                        {$i.drawings_cad_file}<br />
                        <span class="smallbtns dialog_make_btn16 add ui-corner-all" title="{$i.basic_all_selection}"
                              onclick="correspondence.set_delivery_note_select_checkboxes(true, 2);"></span>
                        <span class="smallbtns dialog_make_btn16 delete ui-corner-all" title="{$i.basic_reset_selection}"
                              onclick="correspondence.set_delivery_note_select_checkboxes(false, 2);"></span>
                    </th>
                    <th scope="col" style="min-width:80px;">
                        {$i.drawings_plot_file}<br />
                        <span class="smallbtns dialog_make_btn16 add ui-corner-all" title="{$i.basic_all_selection}"
                              onclick="correspondence.set_delivery_note_select_checkboxes(true, 3);"></span>
                        <span class="smallbtns dialog_make_btn16 delete ui-corner-all" title="{$i.basic_reset_selection}"
                              onclick="correspondence.set_delivery_note_select_checkboxes(false, 3);"></span>
                    </th>
                    {$index_pos=4}
                    {foreach $drawings_addi_fields as $drawings_addi_field}
                        {if $drawings_addi_field->maintype eq US_exmodel::T_DOCUMENT}
                            <th scope="col" style="min-width:80px;">
                                {$drawings_addi_field->name|escape:'html'}<br />
                                <span class="smallbtns dialog_make_btn16 add ui-corner-all" title="{$i.basic_all_selection}"
                                      onclick="correspondence.set_delivery_note_select_checkboxes(true, {$index_pos});"></span>
                                <span class="smallbtns dialog_make_btn16 delete ui-corner-all" title="{$i.basic_reset_selection}"
                                      onclick="correspondence.set_delivery_note_select_checkboxes(false, {$index_pos++});"></span>
                            </th>
                        {/if}
                    {/foreach}
                </tr>
            </thead>
            <tbody>
                {foreach from=$delivery_note_info->drawings item=drawing}
                    {$default_cad=false}
                    {if empty($drawing->drawing_plot_file)}
                        {$default_cad=true}
                    {/if}
                    <tr>
                        <td title="{$drawing->drawing_plan_info|escape:'html'} ({$drawing->drawing_type_name|escape:'html'})">
                            {$drawing->drawing_plan_info|truncate:50|escape:'html'|table_header_names:20}
                        </td>
                        <td title="{$drawing->drawing_cad_file_path|escape:'html'}">
                            {if !empty($drawing->drawing_cad_file)}
                                {include file='r/checkbox-only.tpl' name="correspondence_delivery_note_select_file" multiple=true value="`$drawing->drawing_id`_cad"
                                    default=$default_cad class="cad_file_checkbox"}
                                <label for="correspondence_delivery_note_select_file__{$drawing->drawing_id}_cad">
                                    {$drawing->drawing_cad_file|truncate:100|escape:'html'|table_header_names:20}
                                </label>
                            {/if}
                        </td>
                        <td title="{$drawing->drawing_plot_file_path|escape:'html'}">
                            {if !empty($drawing->drawing_plot_file)}
                                {include file='r/checkbox-only.tpl' name="correspondence_delivery_note_select_file" multiple=true value="`$drawing->drawing_id`_plot"
                                    default=!$default_cad class="plot_file_checkbox"}
                                <label for="correspondence_delivery_note_select_file__{$drawing->drawing_id}_plot">
                                    {$drawing->drawing_plot_file|truncate:100|escape:'html'|table_header_names:20}
                                </label>
                            {else}
                                -
                            {/if}
                        </td>
                        {foreach from=$drawings_addi_fields item=drawings_addi_field}
                            {if $drawings_addi_field->maintype eq US_exmodel::T_DOCUMENT}
                                {$drawing_addi_field=$drawings_addi_field->field}
                                <td title="{$drawing->$drawing_addi_field|escape:'html'}">
                                    {if !empty($drawing->$drawing_addi_field)}
                                        {include file='r/checkbox-only.tpl' name="correspondence_delivery_note_select_file" multiple=true value="`$drawing->drawing_id`_`$drawing_addi_field`"
                                            default=true}
                                        <label for="correspondence_delivery_note_select_file__{$drawing->drawing_id}_{$drawing_addi_field}">
                                            {$drawing->$drawing_addi_field|truncate:100|escape:'html'|table_header_names:20}
                                        </label>
                                    {else}
                                        -
                                    {/if}
                                </td>
                            {/if}
                        {/foreach}
                    </tr>
                {foreachelse}
                    <tr>
                        <td colspan="5">{$i.basic_no_result1}</td>
                    </tr>
                {/foreach}
            </tbody>                
        </table>
    </fieldset>
    <fieldset class="noborder">
        <a onclick="correspondence.set_delivery_note_select_checkboxes(true);" class="dialog_make_text_btn ui-corner-all">
            <span class="dialog_make_btn16 add ui-corner-all"></span>{$i.basic_all_selection}
        </a>
        <a onclick="correspondence.set_delivery_note_select_checkboxes(false);" class="dialog_make_text_btn ui-corner-all">
            <span class="dialog_make_btn16 delete ui-corner-all"></span>{$i.basic_reset_selection}
        </a>
    </fieldset>
</form>
