{function name=do_td}
    {if isset($orig) && $orig !== '' && $orig != $new}
        <div>{$orig}</div>
        <hr />
        <div>{$new}</div>
    {/if}
{/function}
{function name=build_addi_table}
    {if $data !== FALSE && $data !== NULL}   
        <h3 style="margin-top:10px">{$title}</h3>
        <table>
            <thead>
                <tr>             
                    {foreach item="addi_field" from=$data.addi_fields name="addi_field"}
                    <th>{$addi_field->name}</th>
                    {/foreach}
                </tr>
            </thead> 
            <tbody> 
            {if count($data.values) > $srp_limit}
                {$for = $srp_limit-1}
            {else}
                {$for = count($data.values)-1}
            {/if}
            {for $k=0 to $for}           
                {$addi = $data.values.$k}
                <tr class="{if $k % 2 == 0}even{/if}"> 
                {foreach item="addi_field" from=$data.addi_fields name="addi_field"}
                {assign var='addi_key' value=$addi_field->field}
                {assign var="replaced_key" value="{$addi_key}__replaced"}                
                <td>
                    {do_td orig=$addi->$addi_key new=$addi->$replaced_key}
                </td>                       
                {/foreach}
                </tr>
            {/for}
            {if count($data.values) > $srp_limit}
                <tr class="{if count($data.values) % 2 != 0}even{/if}">
                    <td colspan={count($data.addi_fields)} style="color:red">{sprintf($i.projectadmin_cannot_show_too_many, $srp_limit, $srp_limit)}</td>
                </tr>
            {/if}             
            </tbody>
        </table>
    {/if}  
{/function}

{if $result_found === FALSE}
    {$i.basic_no_result1}
{/if}
{if $result_project !== FALSE}
<h3 style="margin-top:10px">{$i.projectadmin_paths}</h3>    
<table>
    {if count($result_project) > $srp_project_limit}
        {$for = $srp_project_limit-1}
    {else}
        {$for = count($result_project)-1}
    {/if}
    {for $k=0 to $for}
        {$project_paths = $result_project.$k}
        {if $k === 0}{*}SET HEADER{*}
            <thead>
                <tr>
                    <th>{$i.projectadmin_project}</th>
                    {if isset($project_paths->orig_translated_structure_tree_root_node)}<th>{$i.projectadmin_path_main}</th>{/if}
                    {if isset($project_paths->path_correspondence)}<th>{$i.projectadmin_path_correspondence}</th>{/if}
                    {if isset($project_paths->path_inbox)}<th>{$i.projectadmin_path_inbox}</th>{/if}
                    {if isset($project_paths->path_outbox)}<th>{$i.projectadmin_path_outbox}</th>{/if}
                    {if isset($project_paths->path_drawings)}<th>{$i.projectadmin_path_drawings}</th>{/if}
                </tr>
            </thead>
            <tbody>
        {/if}
        <tr class="{if $k % 2 == 0}even{/if}">
            <td>
                {$project_paths->project}
            </td>            
            {if isset($project_paths->orig_translated_structure_tree_root_node)}
                <td>{do_td orig=$project_paths->orig_translated_structure_tree_root_node new= $project_paths->orig_translated_structure_tree_root_node__replaced}</td>
            {/if}
            {if isset($project_paths->path_correspondence)}
                <td>{do_td orig=$project_paths->path_correspondence new= $project_paths->path_correspondence__replaced}</td>
            {/if}  
            {if isset($project_paths->path_inbox)}
                <td>{do_td orig=$project_paths->path_inbox new= $project_paths->path_inbox__replaced}</td>
            {/if}   
            {if isset($project_paths->path_outbox)}
                <td>{do_td orig=$project_paths->path_outbox new= $project_paths->path_outbox__replaced}</td>
            {/if}     
            {if isset($project_paths->path_drawings)}
                <td>{do_td orig=$project_paths->path_drawings new= $project_paths->path_drawings__replaced}</td>
            {/if}              
        </tr>        
    {/for}
    {if count($result_project) > $srp_project_limit}
        <tr class="{if count($result_project) % 2 != 0}even{/if}">
            <td colspan="7" style="color:red">{sprintf($i.projectadmin_cannot_show_too_many, $srp_project_limit, $srp_project_limit)}</td>
        </tr>
    {/if}        
            </tbody>
    </table>
{/if}
{if $result_offer !== FALSE}
    <h3 style="margin-top:10px">{$i.offers_management_project_offers}</h3>
    <table>
        {if count($result_offer) > $srp_limit}
            {$for = $srp_limit-1}
        {else}
            {$for = count($result_offer)-1}
        {/if}
        {for $k=0 to $for}
            {$offer_paths = $result_offer.$k}        
            {if $k === 0}{*}SET HEADER{*}        
            <thead>
                <tr>  
                    <th>{$i.projectadmin_project}</th>
                    <th>{$i.offers_management_offer_no}</th>
                    <th>{$i.offers_management_date}</th>
                    <th>{$i.projectadmin_path_offers}</th>
                </tr>
            </thead> 
            <tbody>
            {/if}
            <tr class="{if $k % 2 == 0}even{/if}">
                {assign var='pid' value=$offer_paths->project_id} 
                <td>{$projects_list.$pid}</td>  
                <td>{$offer_paths->offer_no}</td>       
                <td>{$offer_paths->date->us_date()}</td>                 
                <td>{do_td orig=$offer_paths->file new= $offer_paths->file__replaced}</td>                
            </tr>   
        {/for}
        {if count($result_offer) > $srp_limit}
            <tr class="{if count($result_offer) % 2 != 0}even{/if}">
                <td colspan="4" style="color:red">{sprintf($i.projectadmin_cannot_show_too_many, $srp_limit, $srp_limit)}</td>
            </tr>
        {/if}             
        </tbody>
    </table>
{/if}
{if $result_corr_attach !== FALSE}
    <h3 style="margin-top:10px">{$i.basic_corr_attachments}</h3>
    <table>
        {if count($result_corr_attach) > $srp_limit}
            {$for = $srp_limit-1}
        {else}
            {$for = count($result_corr_attach)-1}
        {/if}
        {for $k=0 to $for}
            {$corr_attach_paths = $result_corr_attach.$k}        
            {if $k === 0}{*}SET HEADER{*}
            <thead>
                <tr>                      
                    <th>{$i.correspondence_file}</th>
                    <th>{$i.correspondence_date}</th>
                    <th>{$i.basic_path}</th>
                </tr>
            </thead> 
            <tbody>
            {/if}
            <tr class="{if $k % 2 == 0}even{/if}">
                <td>{if isset($corr_attach_paths->correspondence_subject)}{$corr_attach_paths->correspondence_subject|truncate:60:"..."}{/if}</td>
                <td>{if isset($corr_attach_paths->correspondence_date)}{$corr_attach_paths->correspondence_date->us_date()}{/if}</td>                 
                <td>{do_td orig=$corr_attach_paths->path new=$corr_attach_paths->path__replaced}</td>                
            </tr>   
        {/for}
        {if count($result_corr_attach) > $srp_limit}
            <tr class="{if count($result_corr_attach) % 2 != 0}even{/if}">
                <td colspan="3" style="color:red">{sprintf($i.projectadmin_cannot_show_too_many, $srp_limit, $srp_limit)}</td>
            </tr>
        {/if}             
        </tbody>
    </table>
{/if}
{if $result_drawings_cad !== FALSE}
    <h3 style="margin-top:10px">{$i.basic_drawings_cad}</h3>
    <table>
        {if count($result_drawings_cad) > $srp_limit}
            {$for = $srp_limit-1}
        {else}
            {$for = count($result_drawings_cad)-1}
        {/if}
        {for $k=0 to $for}
            {$drawings_cad_paths = $result_drawings_cad.$k}        
            {if $k === 0}{*}SET HEADER{*}        
            <thead>
                <tr>                      
                    <th>{$i.drawings_project}</th>
                    <th>{$i.drawings_plan_no}</th>
                    <th>{$i.drawings_date}</th>
                    <th>{$i.basic_path}</th>
                </tr>
            </thead> 
            <tbody>
            {/if}
            <tr class="{if $k % 2 == 0}even{/if}">
                {assign var='pid' value=$drawings_cad_paths->project_id} 
                <td>{$projects_list.$pid}</td>                 
                <td>{$drawings_cad_paths->plan_no}</td>   
                <td>{$drawings_cad_paths->date->us_date()}</td>   
                <td>{do_td orig=$drawings_cad_paths->cad_file new=$drawings_cad_paths->cad_file__replaced}</td>                
            </tr>   
        {/for}
        {if count($result_drawings_cad) > $srp_limit}
            <tr class="{if count($result_drawings_cad) % 2 != 0}even{/if}">
                <td colspan="4" style="color:red">{sprintf($i.projectadmin_cannot_show_too_many, $srp_limit, $srp_limit)}</td>
            </tr>
        {/if}            
        </tbody>
    </table>
{/if}
{if $result_drawings_plot !== FALSE}
    <h3 style="margin-top:10px">{$i.basic_drawings_plot}</h3>
    <table>
        {if count($result_drawings_plot) > $srp_limit}
            {$for = $srp_limit-1}
        {else}
            {$for = count($result_drawings_plot)-1}
        {/if}
        {for $k=0 to $for}
            {$drawings_plot_paths = $result_drawings_plot.$k}        
            {if $k === 0}{*}SET HEADER{*}  
            <thead>
                <tr>                      
                    <th>{$i.drawings_project}</th>
                    <th>{$i.drawings_plan_no}</th>
                    <th>{$i.drawings_date}</th>
                    <th>{$i.basic_path}</th>
                </tr>
            </thead> 
            <tbody>
            {/if}
            <tr class="{if $k % 2 == 0}even{/if}">
                {assign var='pid' value=$drawings_plot_paths->project_id} 
                <td>{$projects_list.$pid}</td>   
                <td>{$drawings_plot_paths->plan_no}</td>   
                <td>{$drawings_plot_paths->date->us_date()}</td>   
                <td>{do_td orig=$drawings_plot_paths->plot_file new=$drawings_plot_paths->plot_file__replaced}</td>                
            </tr>   
        {/for}
        {if count($result_drawings_plot) > $srp_limit}
            <tr class="{if count($result_drawings_plot) % 2 != 0}even{/if}">
                <td colspan="4" style="color:red">{sprintf($i.projectadmin_cannot_show_too_many, $srp_limit, $srp_limit)}</td>
            </tr>
        {/if}               
        </tbody>
    </table>
{/if}
{if $result_mail_attach !== FALSE}
    <h3 style="margin-top:10px">{$i.basic_mail_attachments}</h3>
    <table>
        {if count($result_mail_attach) > $srp_limit}
            {$for = $srp_limit-1}
        {else}
            {$for = count($result_mail_attach)-1}
        {/if}
        {for $k=0 to $for}
            {$mail_attach_paths = $result_mail_attach.$k}        
            {if $k === 0}{*}SET HEADER{*}                      
            <thead>
                <tr>                      
                    <th>{$i.projectadmin_project}</th>
                    <th>{$i.inoutbox_no}</th>
                    <th>{$i.inoutbox_date}</th>
                    <th>{$i.basic_path}</th>
                </tr>
            </thead> 
            <tbody>
            {/if}
            <tr class="{if $k % 2 == 0}even{/if}">
                {assign var='pid' value=$mail_attach_paths->project_id} 
                <td>{$projects_list.$pid}</td>  
                <td>{if isset($mail_attach_paths->outbox_no)}{$mail_attach_paths->outbox_no}{/if}</td>
                <td>{if isset($mail_attach_paths->outbox_date)}{$mail_attach_paths->outbox_date->us_date()}{/if}</td>                 
                <td>{do_td orig=$mail_attach_paths->path new=$mail_attach_paths->path__replaced}</td>                
            </tr>   
        {/for}
        {if count($result_mail_attach) > $srp_limit}
            <tr class="{if count($result_mail_attach) % 2 != 0}even{/if}">
                <td colspan="4" style="color:red">{sprintf($i.projectadmin_cannot_show_too_many, $srp_limit, $srp_limit)}</td>
            </tr>
        {/if}              
        </tbody>
    </table>
{/if}  
{if $result_addresses_files !== FALSE}
    <h3 style="margin-top:10px">{$i.basic_addressesfiles}</h3>
    <table>
        {if count($result_addresses_files) > $srp_limit}
            {$for = $srp_limit-1}
        {else}
            {$for = count($result_addresses_files)-1}
        {/if}
        {for $k=0 to $for}
            {$addresses_files = $result_addresses_files.$k}        
            {if $k === 0}{*}SET HEADER{*}                       
            <thead>
                <tr>                      
                    <th>{$i.inoutbox_no}</th>
                    <th>{$i.inoutbox_date}</th>
                    <th>{$i.basic_path}</th>
                </tr>
            </thead> 
            <tbody>
            {/if}
            <tr class="{if $k % 2 == 0}even{/if}">
                <td>{if isset($addresses_files->address_name)}{$addresses_files->address_name}{/if}</td>
                <td>{if isset($addresses_files->description)}{$addresses_files->description|truncate:40:"..."}{/if}</td>
                <td>{do_td orig=$addresses_files->file new=$addresses_files->file__replaced}</td>                
            </tr>   
        {/for}
        {if count($result_addresses_files) > $srp_limit}
            <tr class="{if count($result_addresses_files) % 2 != 0}even{/if}">
                <td colspan="3" style="color:red">{sprintf($i.projectadmin_cannot_show_too_many, $srp_limit, $srp_limit)}</td>
            </tr>
        {/if}                
        </tbody>
    </table>
{/if}   
{if $result_data_files !== FALSE}
    <h3 style="margin-top:10px">{$i.basic_dataadmin}</h3>
    <table>
        {if count($result_data_files) > $srp_limit}
            {$for = $srp_limit-1}
        {else}
            {$for = count($result_data_files)-1}
        {/if}
        {for $k=0 to $for}
            {$data_files = $result_data_files.$k}        
            {if $k === 0}{*}SET HEADER{*}                       
            <thead>
                <tr>                      
                    <th>{$i.files_purpose}</th>
                    <th>{$i.basic_path}</th>
                </tr>
            </thead> 
            <tbody>
            {/if}
            <tr class="{if $k % 2 == 0}even{/if}">
                <td>{if isset($data_files->purpose)}{$data_files->purpose}{/if}</td>
                <td>{do_td orig=$data_files->path new=$data_files->path__replaced}</td>                
            </tr>   
        {/for}
        {if count($result_data_files) > $srp_limit}
            <tr class="{if count($result_data_files) % 2 != 0}even{/if}">
                <td colspan="2" style="color:red">{sprintf($i.projectadmin_cannot_show_too_many, $srp_limit, $srp_limit)}</td>
            </tr>
        {/if}                 
        </tbody>
    </table>
{/if}         
{if $result_wiw_files !== FALSE}
    <h3 style="margin-top:10px">{$i.basic_whatiswhere}</h3>
    <table>
        {if count($result_wiw_files) > $srp_limit}
            {$for = $srp_limit-1}
        {else}
            {$for = count($result_wiw_files)-1}
        {/if}
        {for $k=0 to $for}
            {$wiw_files = $result_wiw_files.$k}        
            {if $k === 0}{*}SET HEADER{*}                      
            <thead>
                <tr>                      
                    <th>{$i.whatiswhere_title}</th>
                    <th>{$i.basic_path}</th>
                </tr>
            </thead> 
            <tbody>
            {/if}
            <tr class="{if $k % 2 == 0}even{/if}">
                <td>{if isset($wiw_files->title)}{$wiw_files->title}{/if}</td>
                <td>{do_td orig=$wiw_files->file new=$wiw_files->file__replaced}</td>                
            </tr>   
        {/for}
        {if count($result_wiw_files) > $srp_limit}
            <tr class="{if count($result_wiw_files) % 2 != 0}even{/if}">
                <td colspan="2" style="color:red">{sprintf($i.projectadmin_cannot_show_too_many, $srp_limit, $srp_limit)}</td>
            </tr>
        {/if}               
        </tbody>
    </table>
{/if}     
    
{*}-- ADDI FIELDS ---{*}      
{build_addi_table data=$result_addi_projects title="{$i.basic_addi_fields} - {$i.basic_projectadmin}"}
{build_addi_table data=$result_addi_project_participants title="{$i.basic_addi_fields} - {$i.projectadmin_participants2}"}
{build_addi_table data=$result_addi_staff title="{$i.basic_addi_fields} - {$i.basic_staffadmin}"}
{build_addi_table data=$result_addi_addresses title="{$i.basic_addi_fields} - {$i.basic_addressesandcontacts}"}
{build_addi_table data=$result_addi_fees title="{$i.basic_addi_fields} - {$i.basic_feeadmin}"}
{build_addi_table data=$result_addi_externalexpenses title="{$i.basic_addi_fields} - {$i.basic_externalexpenses}"}
{build_addi_table data=$result_addi_drawings title="{$i.basic_addi_fields} - {$i.basic_drawingandproductdirectory}"}
{build_addi_table data=$result_addi_correspondence title="{$i.basic_addi_fields} - {$i.basic_correspondence}"}
{build_addi_table data=$result_addi_outbox title="{$i.basic_addi_fields} - {$i.basic_mailoutbox}"}
{build_addi_table data=$result_addi_inbox title="{$i.basic_addi_fields} - {$i.basic_mailinbox}"}
{build_addi_table data=$result_addi_opentasks title="{$i.basic_addi_fields} - {$i.basic_opentasks}"}
{build_addi_table data=$result_addi_whatiswhere title="{$i.basic_addi_fields} - {$i.basic_whatiswhere}"}
