<?xml version="1.0" encoding="UTF-8" ?>
<jsp:root
	xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:og="hybs-taglib.tld"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	version="2.0">
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8" />

<!-- Required Parameter : CDANK(String) -->
<!-- Optional Parameter : UVIEW(boolean) -->

<og:value command="SQL">
	select A.USERID, A.NMANK, A.SMANK, A.FGSHUBETSU
	from AN01 A
	where A.CDANK = '{@CDANK}'
	and A.FGJ = '1'
</og:value>

<og:value command="SQL">
	select count(*) KCNT, avg(SUSPOINT) AVGPNT
	from AN11 A
	where A.CDANK = '{@CDANK}'
	and A.FGJ = '1'
</og:value>

<fieldset>
<table style="margin:10px;">
	<tr>
		<og:column name="NMANK" writable="false" />
	</tr>
	<tr>
		<og:column name="KCNT" writable="false" />
		<og:equals val1="{@FGSHUBETSU}" val2="2">
			<og:column name="AVGPNT" writable="false" />
		</og:equals>
	</tr>
	<og:equals val1="{@SMANK}" nullCheck="true" notEquals="true">
		<tr><td colspan="2"><hr width="95%" /></td></tr>
		<tr>
			<og:column name="SMANK" writable="false" renderer="PRE" />
		</tr>
	</og:equals>
</table>
</fieldset>

<og:equals val1="{@UVIEW}" nullCheck="true">
	<og:equals val1="{@USERID}" val2="{@USER.ID}">
		<og:value command="SET" key="DVIEW" value="true" />
	</og:equals>
</og:equals>

<og:value command="SET" key="CDSITSU_PARA" value="{@CDSITSU}" />

<!-- 繧ｨ繝ｩ繝ｼ繝√ぉ繝?け(縺薙％縺ｾ縺ｧ) -->
<og:query command="NEW" displayMsg="" scope="request">
	select B.UNIQ AN02_UNIQS
	from AN01 A inner join AN02 B
	on A.USERID = B.USERID
	and A.CDANK = B.CDANK
	and B.FGJ in ('0','1')
	where A.CDANK = '{@CDANK}'
	<og:equals val1="{@CDSITSU_PARA}" nullCheck="true" notEquals="true">
	and B.CDSITSU = '{@CDSITSU_PARA}'
	</og:equals>
	and A.FGJ in ('0','1')
	order by B.SEQNO
</og:query>

<og:value command="SETTBL" action="ALL_APPEND" key="AN02_UNIQS" tblScope="request" />

<og:equals val1="{@AN02_UNIQS}" nullCheck="true" notEquals="true">
<ol>
	<c:forTokens items="${AN02_UNIQS}" delims="," var="AN02_UNIQ" varStatus="sitsustatus">

		<og:value command="REMOVE" key="IMGNAI" />
		<og:value command="REMOVE" key="SITSUGRP" />
		<og:value command="REMOVE" key="SITSUSGRP" />
		<og:value command="REMOVE" key="ISKEY" />
		<og:value command="REMOVE" key="KNOTE" />
		<og:value command="REMOVE" key="FGIMGS" />
		<og:value command="SQL">
			select A.CDSITSU,A.NAIYO,A.IMGNAI,A.SITSUGRP,A.SITSUSGRP,A.SEQNO
					,case when A.FGKEY = '1' then 'checked' else '' end ISKEY
					,A.KBUNRUI,A.KNOTE
					,case when A.IMGNAI like '%.png' or A.IMGNAI like '%.PNG'
						or A.IMGNAI like '%.jpg' or A.IMGNAI like '%.JPG'
						or A.IMGNAI like '%.jpeg' or A.IMGNAI like '%.JPEG'
						or A.IMGNAI like '%.gif' or A.IMGNAI like '%.GIF'
						or A.IMGNAI like '%.bmp' or A.IMGNAI like '%.BMP' then '1' else '0' end FGIMGS
			from AN02 A
			where UNIQ = '{@AN02_UNIQ}'
		</og:value>

		<!-- 詳細画面で、グループを出力するため、自身を基点とした最も近い質問グループを取得する -->
		<og:equals val1="{@CDSITSU_PARA}" nullCheck="true" notEquals="true">
			<og:equals val1="{@SITSUGRP}" nullCheck="true">
				<og:value command="SQL">
					select SITSUGRP
					from AN02 A
					where A.CDANK = '{@CDANK}'
					and A.SEQNO &lt;= {@SEQNO}
					and A.SITSUGRP is not null and A.SITSUGRP != coalesce('',' ')
					and A.FGJ in ('0','1')
					order by A.SEQNO desc
				</og:value>
			</og:equals>
			<og:equals val1="{@SITSUSGRP}" nullCheck="true">
				<og:value command="SQL">
					select SITSUSGRP
					from AN02 A
					where A.CDANK = '{@CDANK}'
					and A.SEQNO &lt;= {@SEQNO}
					and (	( A.SITSUGRP is not null and A.SITSUGRP != coalesce('',' ') )
						or	( A.SITSUSGRP is not null and A.SITSUSGRP != coalesce('',' ') ) )
					and A.FGJ in ('0','1')
					order by A.SEQNO desc
				</og:value>
			</og:equals>
		</og:equals>

		<og:equals val1="{@SITSUGRP}" nullCheck="true" notEquals="true">
			<og:equals val1="{@SITSUGRP}" val2="{@SITSUGRP_OLD}" notEquals="true">
				<li style="list-style-type:none;">
					<p class="sitsuGrp">
						<b><og:text>{@SITSUGRP}</og:text></b>
					</p>
				</li>
				<og:value command="SET" key="SITSUGRP_OLD" value="{@SITSUGRP}" />
			</og:equals>
		</og:equals>

		<og:equals val1="{@SITSUSGRP}" nullCheck="true" notEquals="true">
			<og:equals val1="{@SITSUSGRP}" val2="{@SITSUSGRP_OLD}" notEquals="true">
				<li style="list-style-type:none;">
					<p class="sitsuSGrp">
						<b><og:text>{@SITSUSGRP}</og:text></b>
					</p>
				</li>
				<og:value command="SET" key="SITSUSGRP_OLD" value="{@SITSUSGRP}" />
			</og:equals>
		</og:equals>

		<og:value command="SQL">
			select count(*) KSCNT, floor(count(*)*100/{@KCNT}) KRITSU
			from AN12 A
			where A.CDANK = '{@CDANK}'
			and A.CDSITSU = '{@CDSITSU}'
			and A.KVAL is not null and A.KVAL != coalesce('',' ')
			and A.FGOTHER = '0'
			and A.FGJ = '1'
		</og:value>

		<li value="${sitsustatus.count}" style="margin-top:10px;">
			<div>
			<og:equals val1="{@DVIEW}" val2="true">
				<og:equals val1="CHBOX|RADIO" val2="{@KBUNRUI}" contains="true">
					<og:input type="checkbox" name="FGKEY" value="{@CDSITSU}" td="false" optionAttributes="{@ISKEY}" />
				</og:equals>
				<og:link href="detail.jsp" useGamenId="false" keys="command,CDANK,CDSITSU,KEY,BACK_GAMENID" vals="NEW,{@CDANK},{@CDSITSU},{@KEY},{@BACK_GAMENID}">{@NAIYO}</og:link>
			</og:equals>
			<og:equals val1="{@DVIEW}" val2="true" notEquals="true">
				<og:text>{@NAIYO}</og:text>
			</og:equals>

			<og:equals val1="{@IMGNAI}" nullCheck="true" notEquals="true">
				<og:text>
				<a href="/{@SYS.CONTEXT_NAME}/ankimages/{@IMGNAI}" target="IMAGE">
					<og:equals val1="{@FGIMGS}" val2="1">
						<img src="/{@SYS.CONTEXT_NAME}/ankimages/{@IMGNAI}" width="50px" height="50px" />
					</og:equals>
					<og:equals val1="{@FGIMGS}" val2="0">
						<img src="/{@SYS.CONTEXT_NAME}/jsp/image/text.gif" width="30px" height="30px" />
					</og:equals>
				</a>
				</og:text>
			</og:equals>

			<og:equals val1="{@KNOTE}" nullCheck="true" notEquals="true">
				<og:equals val1="{@KBUNRUI}" val2="SCALE" notEquals="true">
					<br />&amp;nbsp&amp;nbsp;<og:text>{@KNOTE}</og:text>
				</og:equals>
			</og:equals>

			&amp;nbsp&amp;nbsp
			(<og:text>
			{@LBL.KCNT}:<og:column name="KCNT" value="{@KSCNT}" td="false" writable="false" />
			&amp;nbsp
			{@LBL.KRITSU}:<og:column name="KRITSU" value="{@KRITSU}" td="false" writable="false" />%
			</og:text>
			<og:equals val1="{@FGSHUBETSU}" val2="2">
				<og:value command="SQL">
					select floor( count(*)*100/{@KCNT} ) KCRRITSU
					from AN12 A
					where A.CDANK = '{@CDANK}'
					and A.CDSITSU = '{@CDSITSU}'
					and A.FGCORRECT = '1'
					and A.FGJ = '1'
				</og:value>
				<og:text>
				&amp;nbsp
				{@LBL.KCRRITSU}:<og:column name="KCRRITSU" value="{@KCRRITSU}" td="false" writable="false" />%
				</og:text>
			</og:equals>
			)
			</div>

			<ul style="list-style-type:none; margin-top:5px; margin-right:10px; width:370px; float:left">
				<og:value command="SET" key="DISABLE" value="true" />
				<jsp:directive.include file="/jsp/customan/ankKomoku.jsp" />
			</ul>

			<div>
				<og:equals val1="CHBOX|RADIO" val2="{@KBUNRUI}" contains="true">
					<og:chartCreate
						width		= "450"
						height		= "250">
						<og:chartDataset chartType="Pie">
							select A.KNAME||'('||count(*)||')('||floor(count(*)*100/{@KCNT})||'%)',count(*) KCNT
							from AN12 A
							where A.CDANK = '{@CDANK}'
							and A.CDSITSU = '{@CDSITSU}'
							and A.FGOTHER = '0'
							group by A.KVAL, A.KNAME
							order by count(*) desc, A.KVAL
						</og:chartDataset>
					</og:chartCreate>
				</og:equals>

				<og:equals val1="MENU" val2="{@KBUNRUI}">
					<og:chartCreate
						width		= "450"
						height		= "250">
						<og:chartDataset chartType="HybsBar" baseLegend="false" tickSize="10" valueLabel="%">
							select A.KNAME||'('||count(*)||')('||floor(count(*)*100/{@KCNT})||'%)',floor(count(*)*100/{@KCNT}) KRITSU
							from AN12 A
							where A.CDANK = '{@CDANK}'
							and A.CDSITSU = '{@CDSITSU}'
							and A.FGOTHER = '0'
							group by A.KVAL, A.KNAME
							order by count(*) desc, A.KVAL
						</og:chartDataset>
					</og:chartCreate>
				</og:equals>

				<og:equals val1="YMD|YM" val2="{@KBUNRUI}" contains="true">
					<og:chartCreate
						width		= "450"
						height		= "250">
						<og:chartDataset chartType="HybsBar" baseLegend="false" tickSize="10" valueLabel="%">
							select {@DBF.SUBSTR}(A.KVAL,1,4)||'/'||{@DBF.SUBSTR}(A.KVAL,5,2)||'('||count(*)||')('||floor(count(*)*100/{@KCNT})||'%)',floor(count(*)*100/{@KCNT}) KRITSU
							from AN12 A
							where A.CDANK = '{@CDANK}'
							and A.CDSITSU = '{@CDSITSU}'
							and A.FGOTHER = '0'
							group by {@DBF.SUBSTR}(A.KVAL,1,4)||'/'||{@DBF.SUBSTR}(A.KVAL,5,2)
							order by {@DBF.SUBSTR}(A.KVAL,1,4)||'/'||{@DBF.SUBSTR}(A.KVAL,5,2)
						</og:chartDataset>
					</og:chartCreate>
<!--
					<og:equals val1="YMD" val2="{@KBUNRUI}" contains="true">
						&amp;nbsp;
						<og:chartCreate
							width		= "450"
							height		= "250">
							<og:chartDataset chartType="HybsBar" baseLegend="false" tickSize="10" valueLabel="%">
								select {@DBF.SUBSTR}(A.KVAL,7,2),floor(count(*)*100/{@KCNT}) KRITSU
								from AN12 A
								where A.CDANK = '{@CDANK}'
								and A.CDSITSU = '{@CDSITSU}'
								and A.FGOTHER = '0'
								group by {@DBF.SUBSTR}(A.KVAL,7,2)
								order by {@DBF.SUBSTR}(A.KVAL,7,2)
							</og:chartDataset>
						</og:chartCreate>
					</og:equals>
-->
				</og:equals>

				<og:equals val1="TEXT|XTEXT|TEXTAREA" val2="{@KBUNRUI}" contains="true">
					<og:equals val1="{@CDSITSU_PARA}" nullCheck="true">
						<og:query command="NEW" displayMsg="" notfoundMsg="" scope="request">
							select A.KVAL AN_{@CDANK}_{@CDSITSU}, B.DYKAITO from AN12 A inner join AN11 B
							on A.NOKAITO = B.NOKAITO
							where A.CDANK = '{@CDANK}'
							and A.CDSITSU = '{@CDSITSU}'
							and A.KVAL is not null and A.KVAL != coalesce('',' ')
							order by A.UNIQ DESC
						</og:query>

						<og:columnEditor column="AN_{@CDANK}_{@CDSITSU}" scope="request" label="KNAIYO" parameter="3,40" />

						<og:text>{@LBL.NEWESTTEN}</og:text>
						<og:view
							viewFormType = "HTMLTable"
							command		= "NEW"
							scope		= "request"
							noMessage	= "true"
							useScrollBar= "false"
							pageSize	= "10"
							selectedType= "NONE" />
					</og:equals>
				</og:equals>

				<og:equals val1="SCALE" val2="{@KBUNRUI}" contains="true">
					<br /><br />
					<og:chartCreate
						width		= "450"
						height		= "250">
						<og:chartDataset chartType="SpiderWeb" baseLegend="false" tickSize="1" valueLabel="Scale">
							select A.KNAME||'('||round(sum(A.KVALSCL)/{@KCNT}.0,2)||')',round(sum(A.KVALSCL)/count(*),2) SCALE
							from AN12 A
							inner join AN03 B
							on A.CDANK = B.CDANK
							and A.CDSITSU = B.CDSITSU
							and A.KVAL = B.KVAL
							and B.FGJ = '1'
							where A.CDANK = '{@CDANK}'
							and A.CDSITSU = '{@CDSITSU}'
							and A.FGOTHER = '0'
							group by A.KVAL, A.KNAME
							order by max(B.SEQNO)
						</og:chartDataset>
					</og:chartCreate>
				</og:equals>
			</div>
			<div style="clear:left;" />
		</li>
	</c:forTokens>
</ol>
</og:equals>

</jsp:root>
