RSS Git Download  Clone
Raw Blame History
<!-- BEGIN [% template.name %] -->
    [% SET skip_wrappers = 1 IF c.stash.skip_wrapper # shared between resource & popup %]

    [% IF ! location_type %]
        <h2>Referrers &amp; Referral Sources</h2>
        <p class="info">Choose a resource type to search:</p>
    [% END %]
    
    [% BLOCK row %]        
        [ <a href="[% app_url %]/referral-source/[% IF c.stash.skip_wrapper # set flag:
                %]select/[% END %]?lookup=[% t %]">
            [% t %]
        </a> ]
    [% END %]

	<p>Search:
        [%
            places = [ 'hospital' 'practice' 'independant' 'prison' 'clinician'
                'GP' ];
            FOREACH entry IN places;
                INCLUDE row t = entry;
            END;
        %]
	<p>

<!-- // ajax method too slow
    <script type="text/javascript" src="/js/prototype.js"></script>
    <script type="text/javascript" src="/js/autocomplete.js"></script>

<div>
    <textarea rows="4" cols="50" id="display"
        onFocus="javascript: var options = {
                    script: function (string) {
                        return ('[% app_url %]/referral-source/lookup?type=[% location_type %];string='+string);
                    },
                    minchars: 3,
                    maxentries: 20,
                    timeout: 5000,
                }; var xml=new AutoComplete('display',options); return true;"></textarea>
</div>

<span id='xml_info'></span>
-->

[% IF location_type %]
	<h2>Lookup new [% location_type %]:</h2>

	<form method="get" action="[% app_url %]/referral-source/lookup">
		<input type="hidden" name="type" value="[% location_type %]">
        <input type="hidden" name="skip_wrapper" value="[% c.stash.skip_wrapper %]">
        <p>Containing:
			<input type="text" name="string" value="" size="40">
			[% site.html.submit %]
		</p>
	</form>
[% END %]

[% IF c.query.param('string') %]
    [% IF matches.size %]
        <p class="bold">Found [% matches.size %] [% location_type %]s matching "[%
                c.query.param('string') %]":</p>
			[% IF file_data;
				age = file_data.age;
				   IF age >= 12; class = 'error';
				ELSIF age >= 6;  class = 'warning';
				ELSE; class = 'info';
				END;
			%]
		<p class="indent">
			<i>source file: [% file_data.filename %].csv; status:
				<span class="[% class %]">updated [% file_data.age %] months ago</span>
			</i>
			[% #IF age <= 6 # need to modified template - no headers & incr. width %]
				<!--[ <a href="[% app_url %]/resources/data_file">update files</a> ]-->
			[% #END %]
		</p>
		[% END %]

        <table>
            <tr>
                <td>&nbsp;</td>
                <th><span class="acronym" title="national code">Code</span></th>
                <th>Details</th>
            </tr>
            [% FOREACH location IN matches %]
                [% SET class = location.code.length == 3 ? 'bold' : 'normal' %]
            <tr class="[% class %]">
                <td>[% loop.count %]</td>
                <td>
                [% IF class.match('bold') %]
                    <a href="[% app_url %]/referral-source/lookup?type=[% location_type
                            %];string=[% location.code %]">
                        [% location.code %]</a>
                [% ELSE %]
                    [% location.code %]
                [% END %]
                </td>
                <td>[% location.display %]</td>
            </tr>
            [% END %]
        </table>
    [% ELSE %]
        <p class="bold">No matches found for "[% c.query.param('string') %]"</p>
    [% END %]
[% END %]
<!-- END [% template.name %] -->