RSS Git Download  Clone
Raw Blame History
<!-- BEGIN site/report_link_options.tt -->
    [% # set Report link:
        specimen = specimen_map.item(data.id).sample_code.join(' ');
        report_link = specimen.match('CMP') AND c.cfg('settings').have_outreach
            ? 'outreach' : 'report';
    %]
    
    [%
        IF # unscreened:
            NOT has_optional.initial_screen
            AND c.user_can('screen');
                url = app_url _ '/screen/=/' _ data.id;
                link = c.html_link(url, 'Screen');
                all_links.push(link);
        
        ELSIF # outreach case & user can report or edit outreach:
            report_link == 'outreach'
            AND ( c.user_can('report') OR c.user_can('edit_outreach_data') );
                url = app_url _ '/report/outreach/' _ data.id;
                link = c.html_link(url, 'Outreach');
                all_links.push(link);

        ELSIF # screened but not reported:
            has_optional.initial_screen
            AND c.user_can('report')
            AND NOT history.reported.user;
                url = app_url _ '/' _ report_link _ '/=/' _ data.id;
                title = report_link | ucfirst;
                link = c.html_link(url, title);
                all_links.push(link);
    
        ELSIF # reported but not authorised (if 'authorise' option active):
            has_optional.report 
            AND c.user_can('report') 
            AND NOT history.authorised.user
            AND NOT data.status_option.description.match('complete')
            AND status_options.authorised.is_active.match('yes');
                IF history.reported.user.username == c.authen.username;
                    url = app_url _ '/report/=/' _ data.id;
                    link = c.html_link(url, 'Report'); # allow edit own report
                ELSE;
                    url = app_url _ '/report/authorise/' _ data.id;
                    link = c.html_link(url, 'Authorise');
                END;
                all_links.push(link);

        ELSIF # reported & authorised but still incomplete:
            has_optional.report 
            AND c.user_can('report')
            AND history.authorised.user
            # AND NOT data.status_option.description.match('complete')
            AND NOT is_locked;
                url = app_url _ '/' _ report_link _ '/=/' _ data.id;
                title = report_link | ucfirst;
                link = c.html_link(url, title);
                all_links.push(link);

        ELSE; 
            # all_links.push('Report'); # don't really need it 
        END;
    %]
<!-- END site/report_link_options.tt -->