RSS Git Download  Clone
Raw Blame History
[% SET skip_wrappers = 1 %]

[% IF ! location_type %]
	<h2>Referrers &amp; Referral Sources</h2>
	<p class="info">Choose a resource type to search:</p>
[% END %]
	<p>Search:
		[ <a href="[% app_url %]/referral-source?lookup=hospital">hospital</a> ]
		[ <a href="[% app_url %]/referral-source?lookup=practice">practice</a> ]
		[ <a href="[% app_url %]/referral-source?lookup=independant">independant</a> ]
		[ <a href="[% app_url %]/referral-source?lookup=prison">prison</a> ]
		[ <a href="[% app_url %]/referral-source?lookup=clinician">clinician</a> ]
		[ <a href="[% app_url %]/referral-source?lookup=GP">GP</a> ]
	<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 %]">
		<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 %]