-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
reports/reports_for_prebuilt_forms/location_details/location_data.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<report | ||
title="Location data for location details" | ||
description="Report used to retrieve details of a location excluding custom attributes for the location details prebuilt form." | ||
> | ||
<query website_filter_field="" training_filter_field=""> | ||
select #columns# | ||
from locations l | ||
join users u on u.id=l.created_by_id | ||
join people p on p.id=u.person_id | ||
left join locations_websites lw on lw.location_id=l.id and lw.deleted=false | ||
#agreements_join# | ||
#joins# | ||
where #sharing_filter# | ||
and (lw.website_id in (#website_ids#) or l.public=true) | ||
</query> | ||
<params> | ||
<param name="location_id" display="Location ID" description="ID of the location to load" datatype="integer"> | ||
<where>l.id=#location_id#</where> | ||
</param> | ||
<param name="parent_location_id" display="Parent location ID" description="ID of the parent location to load subsites for" datatype="integer" default=""> | ||
<where>l.parent_id=#parent_location_id#</where> | ||
</param> | ||
</params> | ||
<columns> | ||
<column name="location_id" sql="l.id" /> | ||
<column name="location_external_key" sql="l.external_key" /> | ||
<column name="name" sql="l.name" /> | ||
<column name="code" sql="l.code" /> | ||
<column name="inputter" sql="p.surname || case when p.first_name is null or p.first_name='' then '' else ', ' || p.first_name end" /> | ||
<column name="centroid_sref" sql="l.centroid_sref" /> | ||
<column name="comment" sql="l.comment" /> | ||
<column name="geom" sql="st_astext(coalesce(l.boundary_geom, l.centroid_geom))" /> | ||
<column name="lat" sql="st_y(st_transform(st_centroid(coalesce(l.boundary_geom, l.centroid_geom)), 4326))" /> | ||
<column name="long" sql="st_x(st_transform(st_centroid(coalesce(l.boundary_geom, l.centroid_geom)), 4326))" /> | ||
<column name="boundary_geom" sql="st_astext(coalesce(l.boundary_geom, l.centroid_geom))" mappable="true" /> | ||
<column name="created_by_id" sql="l.created_by_id" /> | ||
<column name="website_id" sql="lw.website_id" /> | ||
<column name="created_on" sql="l.created_on" /> | ||
<column name="updated_on" sql="l.updated_on" /> | ||
</columns> | ||
</report> |
66 changes: 66 additions & 0 deletions
66
...rts/reports_for_prebuilt_forms/location_details/location_data_attributes_with_hiddens.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<report | ||
title="Location attribute values" | ||
description="Report used to retrieve custom attribute values of a location which are not included in a list of attributes to ignore." | ||
> | ||
<query website_filter_field=""> | ||
select | ||
'Location' as attribute_type, a.system_function, a.id as attr_id, aw.weight as w1, fsb1.weight as w2, fsb2.weight as w3, | ||
CASE a.data_type | ||
WHEN 'T' THEN 'Text' | ||
WHEN 'L' THEN 'Lookup List' | ||
WHEN 'I' THEN 'Integer' | ||
WHEN 'B' THEN 'Boolean' | ||
WHEN 'F' THEN 'Float' | ||
WHEN 'D' THEN 'Specific Date' | ||
WHEN 'V' THEN 'Vague Date' | ||
ELSE a.data_type | ||
END AS data_type, | ||
CASE '#language#' WHEN '' THEN a.caption ELSE COALESCE(TRIM(BOTH '"' FROM (a.caption_i18n->'#language#')::varchar), a.caption) END AS caption, | ||
STRING_AGG(CASE a.data_type | ||
WHEN 'T' THEN CASE WHEN substring(a.caption from (char_length(a.caption)-5) for 4) = 'link' AND substring(av.text_value from 0 for 4) = 'http' THEN | ||
'<a href="' || av.text_value || '">' || av.text_value || '</a>' | ||
ELSE | ||
av.text_value END | ||
WHEN 'L' THEN lookup.term::text | ||
WHEN 'I' THEN av.int_value::varchar | ||
WHEN 'B' THEN av.int_value::varchar | ||
WHEN 'F' THEN av.float_value::varchar | ||
WHEN 'D' THEN av.date_start_value::varchar | ||
WHEN 'V' THEN (av.date_start_value::varchar || ' - '::text) || av.date_end_value::varchar | ||
ELSE NULL::text | ||
END || CASE WHEN a.data_type IN ('I', 'F') AND a.allow_ranges=true THEN COALESCE(' - ' || av.upper_value::text, '') ELSE '' END, '; ') AS value, | ||
STRING_AGG(CASE a.data_type | ||
WHEN 'T' THEN av.text_value | ||
WHEN 'L' THEN av.int_value::varchar | ||
WHEN 'I' THEN av.int_value::varchar | ||
WHEN 'B' THEN av.int_value::varchar | ||
WHEN 'F' THEN av.float_value::varchar | ||
WHEN 'D' THEN av.date_start_value::varchar | ||
WHEN 'V' THEN (av.date_start_value::varchar || ' - '::text) || av.date_end_value::varchar | ||
ELSE NULL::text | ||
END, '; ') AS raw_value, | ||
STRING_AGG(CASE WHEN a.data_type IN ('I', 'F') AND a.allow_ranges=true THEN av.upper_value::text ELSE null::text END, '; ') AS upper_value | ||
from locations l | ||
join location_attribute_values av on av.location_id=l.id and av.deleted=false | ||
join location_attributes a on a.id=av.location_attribute_id and a.deleted=false | ||
left join cache_termlists_terms lookup on a.data_type='L' and lookup.id=av.int_value | ||
left join location_attributes_websites aw on aw.location_attribute_id=a.id and aw.deleted=false | ||
left join form_structure_blocks fsb1 on fsb1.id=aw.form_structure_block_id | ||
left join form_structure_blocks fsb2 on fsb2.id=fsb1.parent_id | ||
where l.id=#location_id# | ||
and l.deleted=false | ||
and lower(a.caption) #operator# (#attrs#) | ||
group by a.system_function, a.id, aw.weight, fsb1.weight, fsb2.weight, a.data_type, a.caption | ||
</query> | ||
<order_bys> | ||
<order_by>w3, w2, w1, attr_id</order_by> | ||
</order_bys> | ||
<params> | ||
<param name='location_id' display='Location ID' description='ID of the location to load' datatype='integer' /> | ||
<param name='attrs' display='Attributes' description='CSV list of attributes to include or exclude. Lowercase.' datatype='text[]' /> | ||
<param name='operator' display='Include or exclude' description="Do you want to include only the list of attributes you've defined, or exclude them?" | ||
datatype='lookup' lookup_values='in:Include,not in:Exclude' /> | ||
<param name='language' display='Language' description="ISO 3 letter code of language to use for captions if available." | ||
datatype='text' default='' /> | ||
</params> | ||
</report> |