Commit d0bbfdf4 by Kim Gyeongeun

#56952 設問設定機能追加

parent 16e32420
......@@ -9,6 +9,17 @@ import java.util.List;
import javax.mail.MessagingException;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.util.TokenProcessor;
import org.seasar.framework.util.StringUtil;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;
import org.seasar.struts.util.RequestUtil;
import jp.agentec.sinaburocast.action.AbstractAction;
import jp.agentec.sinaburocast.action.admin.enquete.EnqueteRegistAction;
import jp.agentec.sinaburocast.action.batch.EnqueteSumBatchAction;
......@@ -41,17 +52,6 @@ import jp.agentec.sinaburocast.service.ReplyService;
import jp.agentec.sinaburocast.service.TemplateService;
import jp.agentec.sinaburocast.vo.EnqueteKey;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.util.TokenProcessor;
import org.seasar.framework.util.StringUtil;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;
import org.seasar.struts.util.RequestUtil;
/**
* アンケート処理
*
......@@ -77,7 +77,7 @@ public class EnqueteAction extends AbstractAction {
//団体寄付用
public PointDonationService pointDonationService;
/**
* アンケート通知メールから来た場合の情報設定
* @throws Exception
......@@ -193,12 +193,13 @@ public class EnqueteAction extends AbstractAction {
}
}
ArrayList<Question> questionList = questionService.findAllOrderByEnqueteId(enqueteForm.eid);
for (Question question : questionList) {
if(StringUtil.equals("6", question.controlId+"") ){
enqueteForm.organizationListFor1Percent = organizationService.findAllOrderByNo();
}
}
//条件付必須チェック(初期画面表示・非表示セット)
questionService.setQuestionDisable(questionList);
//予約語を変更する。
if(enquete.enqueteType ==SinaburoConstant.EnqueteType.PUBLIC_COMMENT
......
......@@ -644,7 +644,11 @@ public interface SinaburoConstant {
String ICHICO_HIDE_DATE = "2023/09/21";
String MEMBER_CARD_RECEIPT_HIDE_DATE = "2023/09/11";
}
interface initDisable {
short YES = 1;
short NO = 0;
}
}
......@@ -14,6 +14,8 @@ import javax.persistence.Transient;
import org.apache.commons.lang.builder.StandardToStringStyle;
import org.apache.commons.lang.builder.ToStringBuilder;
import jp.agentec.sinaburocast.common.SinaburoConstant;
@Entity
@Table(name="m_answer")
public class Answer extends AbstractEntity {
......@@ -54,6 +56,9 @@ public class Answer extends AbstractEntity {
@Column(name = "default_flg")
public int defaultFlg;
@Transient
public short answerInitDisable = SinaburoConstant.initDisable.NO;
/** MEnquete関連プロパティ */
@ManyToOne
......
......@@ -4,7 +4,6 @@ import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
......@@ -14,6 +13,8 @@ import javax.persistence.Transient;
import org.apache.commons.lang.StringUtils;
import jp.agentec.sinaburocast.common.SinaburoConstant;
@Entity
@Table(name="m_question")
public class Question extends AbstractEntity {
......@@ -117,6 +118,9 @@ public class Question extends AbstractEntity {
@Transient
public Integer answerCount;
@Transient
public short questionInitDisable = SinaburoConstant.initDisable.NO;
public String getYearRange() {
StringBuffer sb = new StringBuffer();
if (StringUtils.isEmpty(startymd)) {
......
package jp.agentec.sinaburocast.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.seasar.extension.jdbc.where.SimpleWhere;
import org.seasar.framework.container.annotation.tiger.Component;
import org.seasar.framework.container.annotation.tiger.InstanceType;
import org.seasar.framework.util.IntegerConversionUtil;
import jp.agentec.sinaburocast.common.SinaburoConstant;
import jp.agentec.sinaburocast.entity.AdminUser;
......@@ -286,7 +290,40 @@ public class QuestionService extends AbstractService<Question> {
}
}
}
/**
* 条件付必須チェック(初期画面表示・非表示セット)
*
* @param questionList
* @return
*/
public void setQuestionDisable(List<Question> questionList) {
HashMap<Integer, Integer> requiredQuestionInfo = new HashMap<Integer, Integer>();
//初期表示情報セット
for (Question question : questionList) {
for (Answer answer : question.answerList) {
if (question.condRequiredQuestionNo != null && question.condRequiredQuestionNo == 0
&& answer.defaultFlg == 1 && requiredQuestionInfo.get(answer.answerId) == null) {
requiredQuestionInfo.put(answer.answerId, answer.defaultFlg);
}
}
}
for (Question question : questionList) {
//条件付必須チェック(初期画面表示・非表示セット)
for (Answer answer : question.answerList) {
if (question.condRequiredQuestionNo != null && question.condRequiredQuestionNo != 0
&& StringUtils.isNotBlank(question.condRequiredAnswer)) {
List<String> requiredAnswerIdList = new ArrayList<String>(Arrays.asList(question.condRequiredAnswer.split(",")));
for (String requiredAnswerId : requiredAnswerIdList) {
if (requiredQuestionInfo.get(IntegerConversionUtil.toInteger(requiredAnswerId)) == null) {
question.questionInitDisable = SinaburoConstant.initDisable.YES;
answer.answerInitDisable = SinaburoConstant.initDisable.YES;
break;
}
}
}
}
}
}
/**
......
......@@ -9,23 +9,58 @@
#set($dateIndex=0)
#foreach($question in $!enqueteForm.questionList)
#if($question.controlId == 5)
#set($dateIndex = $dateIndex+1)
<script language="javascript" type="text/javascript" charset="utf-8">
console.log("${question.questionId}");
console.log("${question.condRequiredQuestionNo}");
console.log("${question.condRequiredAnswer}");
<!--
$(function() {
//開始日
$("#enqStartFrom${dateIndex}").datepick({showTrigger: "#enqFrom${dateIndex}",
yearRange: "$question.yearRange",
minDate: "$question.startymd",
maxDate: "$question.endymd"});
});
//-->
</script>
#if($question.controlId == 5)
#set($dateIndex = $dateIndex+1)
#end
#end
#foreach($question in $!enqueteForm.questionList)
#foreach($answer in $question.answerList)
<script language="javascript" type="text/javascript" charset="utf-8">
<!--
//開始日
$(function() {
$("#enqStartFrom${dateIndex}").datepick({showTrigger: "#enqFrom${dateIndex}",
yearRange: "$question.yearRange",
minDate: "$question.startymd",
maxDate: "$question.endymd"});
});
// -->
<!--
$(function() {
//条件付必須チェック
$("input[type=radio], input[type=checkbox], input[type=select]").click(function () {
var thisQuestionId = $(this).attr("class");
var thisAnswerId = $(this).attr("id");
//表示、非表示対象
if (${question.condRequiredQuestionNo} && ${question.condRequiredQuestionNo} == thisQuestionId) {
if ("${question.condRequiredAnswer}".split(",").indexOf(thisAnswerId) < 0) {
if ("${question.controlId}" == "0" || "${question.controlId}" == "1") {
$("#${answer.answerId}").attr("checked", false);
$("#${answer.answerId}").attr("disabled", true);
} else if ("${question.controlId}" == "2" || "${question.controlId}" == "3" || "${question.controlId}" == "4") {
$("#${question.questionId}").val("");
$("#${question.questionId}").attr("disabled", true);
} else if ("${question.controlId}" == "5") {
$(".${question.questionId}").val("");
$(".${question.questionId}").attr("disabled", true);
$(".${question.questionId}").next().hide();
}
} else {
if ("${question.controlId}" == "0" || "${question.controlId}" == "1") {
$("#${answer.answerId}").attr("disabled", false);
} else if ("${question.controlId}" == "2" || "${question.controlId}" == "3" || "${question.controlId}" == "4") {
$("#${question.questionId}").attr("disabled", false);
} else if ("${question.controlId}" == "5") {
$(".${question.questionId}").attr("disabled", false);
$(".${question.questionId}").next().show();
}
}
}
});
});
// -->
</script>
#end
#end
......@@ -187,7 +222,7 @@ $tools.getMsg("errorheader")
#if($!question.controlId == "2")
<td width="$tdWidthPercent%" valign = "top" >
#set($answerIdValueName = "questionList[$questionIndex].answerList[0].answerIdValue")
<select name="$answerIdValueName" #if($!question.condRequiredQuestionNo != "0") disabled="disabled" #end>
<select name="$answerIdValueName" id="#he($!question.questionId)" #if($!question.questionInitDisable == "1") disabled #end>
#foreach($selectAnswer in $question.answerList)
<option value="$!selectAnswer.answerId" #if($enqueteForm.initCount =="2" && $!selectAnswer.answerId == $!selectAnswer.answerIdValue) selected #elseif($!selectAnswer.defaultFlg == "1" && $enqueteForm.initCount!="2") selected #end >$!escape.html($!selectAnswer.answer)</option>
<!-- <option value="$!selectAnswer.answerId" #if($enqueteForm.initCount =="2" && $!selectAnswer.answerId == $!selectAnswer.answerIdValue) selected $!selectAnswer.answerId , $!selectAnswer.answerIdValue #elseif($!selectAnswer.defaultFlg == "1" ) selected $!selectAnswer.answerId , $!selectAnswer.answerIdValue #end >$!escape.html($!selectAnswer.answer)</option> -->
......@@ -217,41 +252,39 @@ $tools.getMsg("errorheader")
<!-- 0:RADIO インデクスを値にする。 -->
#if($!question.controlId == "0")
##if($!answer.freeTextFlg != "1" && $!answer.freeTextFlg != "2")
<input type="radio" name="$!answerIdValueRadioName" value="$velocityCount" #if($!answer.answerIdValue == $velocityCount.toString() && $enqueteForm.initCount =="2") checked #{end}
#if($!answer.defaultFlg == 1 && $enqueteForm.initCount =="1") checked #end
#if($!question.condRequiredQuestionNo != "0") disabled="disabled" #end> $!escape.html($!answer.answer)
<input type="radio" class="#he($!question.questionId)" id="#he($!answer.answerId)" name="$!answerIdValueRadioName" value="$velocityCount" #if($!answer.answerIdValue == $velocityCount.toString() && $enqueteForm.initCount =="2") checked #end
#if($!answer.defaultFlg == 1 && $enqueteForm.initCount =="1") checked #end #if($!answer.answerInitDisable == "1") disabled #end> $!escape.html($!answer.answer)
##end
##<!-- 自由入力欄。freeTextFlg=1(あり)、2(必須) -->
#if($!answer.freeTextFlg == "1" || $!answer.freeTextFlg == "2")
<input type="text" name="$answerValue" size="$!answer.freeTextColWidth" value="$!escape.html($!answer.answerValue)" />
<input type="text" class="#he($!question.questionId)" id="#he($!answer.answerId)" name="$answerValue" size="$!answer.freeTextColWidth" value="$!escape.html($!answer.answerValue)" />
#end
##<!-- 1:CHECKBOX answer.answerNo値を値にする。-->
#elseif($!question.controlId == "1")
##if($!answer.freeTextFlg != "1" && $!answer.freeTextFlg != "2")
<input type="checkbox" name="$answerIdValueName" value="$!escape.html($!answer.answerNo)" #if($answer.answerIdValue != "" && $enqueteForm.initCount =="2") checked #end
#if($!answer.defaultFlg == 1 && $enqueteForm.initCount =="1") checked #end
#if($!question.condRequiredQuestionNo != "0") disabled="disabled" #end> $!escape.html($!answer.answer)
<input type="checkbox" class="#he($!question.questionId)" id="#he($!answer.answerId)" name="$answerIdValueName" value="$!escape.html($!answer.answerNo)" #if($answer.answerIdValue != "" && $enqueteForm.initCount =="2") checked #end
#if($!answer.defaultFlg == 1 && $enqueteForm.initCount =="1") checked #end #if($!answer.answerInitDisable == "1") disabled #end> $!escape.html($!answer.answer)
##end
##<!-- 自由入力欄。freeTextFlg=1(あり)、2(必須) -->
#if($!answer.freeTextFlg == "1" || $!answer.freeTextFlg == "2")
<input type="text" name="$answerValue" size="$!answer.freeTextColWidth" value="$!escape.html($!answer.answerValue)"/>
<input type="text" class="#he($!question.questionId)" id="#he($!answer.answerId)" name="$answerValue" size="$!answer.freeTextColWidth" value="$!escape.html($!answer.answerValue)" #if($!question.questionInitDisable == "1") disabled #end/>
#end
##<!-- 3:TEXTAREA ユーザー入力値を値にする。-->
#elseif($!question.controlId == "3")
<textArea type="text" name="$answerIdValueName" cols="$!question.dispWitdth" rows="$!question.rowCount">$!answer.answerIdValue</textarea>
<textArea type="text" id="#he($!question.questionId)" name="$answerIdValueName" cols="$!question.dispWitdth" rows="$!question.rowCount" #if($!question.questionInitDisable == "1") disabled #end>$!answer.answerIdValue</textarea>
##<!-- 4:TEXTFIELD ユーザー入力値を値にする。-->
#elseif($!question.controlId == "4")
<input type="text" name="$answerIdValueName" value="$!escape.html($!answer.answerIdValue)" size="$!question.dispWitdth"/>
<input type="text" id="#he($!question.questionId)" name="$answerIdValueName" value="$!escape.html($!answer.answerIdValue)" size="$!question.dispWitdth" #if($!question.questionInitDisable == "1") disabled #end />
##<!-- 5:日付入力 ユーザー入力値を値にする。-->
#elseif($!question.controlId == "5")
#set($dateIndex = $dateIndex+1)
<input name="$answerValue" id="enqStartFrom${dateIndex}" type="text" class="w100 mgl10" value="$!escape.html($!answer.answerValue)" >
<div style="display: none;"><img id="enqFrom${dateIndex}" src="/em/images/icon_cal.gif" style="padding-left:5px;padding-right:5px; vertical-align: middle;"></div>
<input name="$answerValue" id="enqStartFrom${dateIndex}" type="text" class="w100 mgl10 #he($!question.questionId)" value="$!escape.html($!answer.answerValue)" #if($!question.questionInitDisable == "1") disabled #end>
<div style="display: none;"><img id="enqFrom${dateIndex}" src="/em/images/icon_cal.gif" style="padding-left:5px;padding-right:5px; vertical-align: middle; #if($!question.questionInitDisable == '1') display: none; #end" ></div>
<input type="hidden" name="$answerIdValueName" value="$!answer.answerId" />
#elseif($!question.controlId == "6")
<select name="$answerIdValueName">
<select name="$answerIdValueName" id="#he($!question.questionId)" #if($!question.questionInitDisable == "1") disabled #end>
<option value="" >下記より選択してください</option>
#foreach($pecent1 in $enqueteForm.organizationListFor1Percent)
<option value="$!pecent1.organizationId" #if($!answer.answerIdValue == $!pecent1.organizationId) selected #end>$!{pecent1.organizationNo} : $!escape.html($!{pecent1.organizationName})</option>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment