<ensure variable="get.j_ajax_num" value="0"><!--- an arbitrary number used to prevent some ajax moves from getting mixed up --->
<if not (isNumeric(get.j_ajax_num))><var get.j_ajax_num = 0></if>
<!--- what options should the output contain? --->
<if isdefined("att.is_j_service") AND att.is_j_service EQ 1>
<ensure variable="get.j_options" value="">
<ensure variable="att.options" value="#get.j_options#">
<else>
<if find("@",att.j) GT 0>
<!--- special case: no need for options if this is a particular
user's set of data. --->
<ensure variable="att.options" value="none">
<else>
<ensure variable="att.options" value="">
</if>
</if>
<if NOT isQuery(att.set) OR (_single EQ 0 AND get.j_filter NEQ "")>
<!--- get the records --->
<var _extra = "">
<if trim(get.j_filter) NEQ "">
<if find('"',get.j_filter) GT 0>
<var _extra = _extra & ":'" & get.j_filter & "'">
<else>
<var _extra = _extra & ':"' & get.j_filter & '"'>
</if>
</if>
<var _jparse = jParse("#att.j##_extra#")>
<var _orderby = "#_jparse.orb#.so_lastupdated DESC">
<if att.orderby EQ "insert">
<var _orderby = "#_jparse.orb#.so_dateinserted DESC">
</if>
<var _where = "">
<if _jparse.where NEQ "">
<var _where = "(#_jparse.where#)">
</if>
<if _jparse.orb NEQ "site" AND site_id NEQ 593 AND site_id NEQ 528>
<!--- only ccsd and joelie can show ccs data --->
<if _where NEQ "">
<var _where = _where & " AND ">
</if>
<var _where = _where & "#_jparse.orb#.site_id NOT IN(593,334,222)">
</if>
<set orb="#_jparse.orb#"
select="#_jparse.select#"
where="#_where#"
tbl="#_jparse.otype#"
id="#_jparse.idnum#"
orderby="#_orderby#"
maxrows="#get.start+get.per#">
<var att.set = set>
</set>
</if>