mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@1008 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
7766677867
commit
8a0f5b3998
14 changed files with 226 additions and 63 deletions
|
|
@ -4,5 +4,6 @@
|
|||
<actions>
|
||||
<action name="dispPollAdminList" type="view" admin_index="true" standalone="true" />
|
||||
<action name="procInsert" type="controller" standalone="true" />
|
||||
<action name="procPoll" type="controller" standalone="true" />
|
||||
</actions>
|
||||
</module>
|
||||
|
|
|
|||
|
|
@ -12,8 +12,12 @@
|
|||
$lang->cmd_delete_checked_poll = '선택항목 삭제';
|
||||
$lang->cmd_apply_poll = '설문 참여';
|
||||
|
||||
$lang->success_poll = '설문에 응하여 주셔서 감사합니다';
|
||||
|
||||
$lang->msg_already_poll = '이미 설문조사를 하셨습니다';
|
||||
$lang->msg_cart_is_null = '삭제할 글을 선택해주세요';
|
||||
$lang->msg_checked_poll_is_deleted = '%d개의 설문조사가 삭제되었습니다';
|
||||
$lang->msg_check_poll_item = '설문에 응할 항목을 선택하여 주세요. (설문조사 마다 필수 선택항목이 다를 수 있습니다)';
|
||||
|
||||
$lang->cmd_null_item = "설문조사로 등록할 값이 없습니다.\n다시 설정해주세요";
|
||||
|
||||
|
|
|
|||
|
|
@ -114,5 +114,61 @@
|
|||
$this->setMessage('success_registed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 설문 조사에 응함
|
||||
**/
|
||||
function procPoll() {
|
||||
$poll_srl = Context::get('poll_srl');
|
||||
$poll_srl_indexes = Context::get('poll_srl_indexes');
|
||||
$tmp_item_srls = explode(',',$poll_srl_indexes);
|
||||
for($i=0;$i<count($tmp_item_srls);$i++) {
|
||||
$srl = (int)trim($tmp_item_srls[$i]);
|
||||
if(!$srl) continue;
|
||||
$item_srls[] = $srl;
|
||||
}
|
||||
|
||||
// 응답항목이 없으면 오류
|
||||
if(!count($item_srls)) return new Object(-1, 'msg_check_poll_item');
|
||||
// 이미 설문하였는지 조사
|
||||
$oPollModel = &getModel('poll');
|
||||
if($oPollModel->isPolled($poll_srl)) return new Object(-1, 'msg_already_poll');
|
||||
|
||||
$oDB = &DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
// 설문 항목 추가
|
||||
$args->poll_srl = $poll_srl;
|
||||
|
||||
$output = executeQuery('poll.updatePoll', $args);
|
||||
$output = executeQuery('poll.updatePollTitle', $args);
|
||||
if(!$output->toBool()) {
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$args->poll_item_srl = implode(',',$item_srls);
|
||||
$output = executeQuery('poll.updatePollItems', $args);
|
||||
if(!$output->toBool()) {
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// 응답자 정보를 로그로 남김
|
||||
$log_args->poll_srl = $poll_srl;
|
||||
$log_args->member_srl = $member_srl;
|
||||
$log_args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
$output = executeQuery('poll.insertPollLog', $log_args);
|
||||
if(!$output->toBool()) {
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$oDB->commit();
|
||||
|
||||
$this->add('poll_srl', $poll_srl);
|
||||
$this->add('tpl','haha');
|
||||
$this->setMessage('success_poll');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,19 @@
|
|||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 이미 설문 조사를 하였는지 검사하는 함수
|
||||
**/
|
||||
function isPolled($poll_srl) {
|
||||
$logged_info = Context::get('logged_info');
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
$args->poll_srl = $poll_srl;
|
||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
$output = executeQuery('poll.getPollLog', $args);
|
||||
if($output->data->count) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 설문조사의 html데이터를 return
|
||||
* 설문조사에 응하였는지에 대한 체크를 한 후 결과를 return
|
||||
|
|
@ -41,28 +54,19 @@
|
|||
$poll->poll[$val->poll_index_srl]->item[] = $val;
|
||||
}
|
||||
|
||||
$poll->poll_srl = $poll_srl;
|
||||
|
||||
// 종료일이 지났으면 무조건 결과만
|
||||
if($poll->stop_date > date("YmdHis")) {
|
||||
// 현 사용자가 설문조사에 응하였는지 검사
|
||||
$logged_info = Context::get('logged_info');
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
$output = executeQuery('poll.getPollLog', $args);
|
||||
if($output->data->count) $poll->poll_date = $output->data->regdate;
|
||||
else $poll->poll_date = '';
|
||||
Context::set('poll', $poll);
|
||||
|
||||
// 응하였다면 결과 html return
|
||||
if($poll->poll_date) $template_file = "result";
|
||||
|
||||
// 응하지 않았다면 설문 form html return
|
||||
else $template_file = "form";
|
||||
|
||||
if($this->isPolled($poll_srl)) $tpl_file = "result";
|
||||
else $tpl_file = "form";
|
||||
} else {
|
||||
$template_file = "result";
|
||||
$tpl_file = "result";
|
||||
}
|
||||
|
||||
Context::set('poll', $poll);
|
||||
|
||||
$tpl_path = $this->module_path.'tpl';
|
||||
$tpl_file = $template_file;
|
||||
|
||||
require_once("./classes/template/TemplateHandler.class.php");
|
||||
$oTemplate = new TemplateHandler();
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
<table name="poll_log" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="regdate" />
|
||||
<column name="count(*)" alias="count"/>
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="poll_srl" var="poll_srl" />
|
||||
<condition operation="equal" column="member_srl" var="memer_srl" pipe="and" />
|
||||
<condition operation="equal" column="ipaddress" var="ipaddress" default="ipaddress()" pipe="and" />
|
||||
<condition operation="equal" column="member_srl" default="0" var="memer_srl" pipe="and" />
|
||||
<condition operation="equal" column="ipaddress" var="ipaddress" default="ipaddress()" notnull="notnull" pipe="and" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<table name="poll_item" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="poll_item_srl" var="poll_item_srl" filter="number" notnull="notnull" default="sequence()" />
|
||||
<column name="poll_srl" var="poll_srl" filter="number" notnull="notnull" />
|
||||
<column name="poll_index_srl" var="poll_index_srl" filter="number" notnull="notnull" />
|
||||
<column name="poll_count" var="poll_count" default="0" />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<table name="poll_item">
|
||||
<column name="poll_item_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="poll_srl" type="number" size="11" notnull="notnull" index="index_poll_srl" />
|
||||
<column name="poll_index_srl" type="number" size="11" notnull="notnull" index="idx_poll_index_srl" />
|
||||
<column name="title" type="varchar" size="250" notnull="notnull" />
|
||||
|
|
|
|||
|
|
@ -49,6 +49,17 @@
|
|||
padding:5px;
|
||||
}
|
||||
|
||||
.poll_detail_box .text {
|
||||
margin:5px 0px 5px 20px;
|
||||
}
|
||||
|
||||
.poll_detail_box .bar {
|
||||
margin:5px 0px 15px 20px;
|
||||
background-color:#444444;
|
||||
height:5px;
|
||||
}
|
||||
|
||||
|
||||
.poll_button_area {
|
||||
text-align:center;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
<filter name="poll" module="poll" act="procPoll" confirm_msg_code="confirm_poll_submit">
|
||||
<form />
|
||||
<parameter />
|
||||
<response>
|
||||
<response callback_func="completePoll">
|
||||
<tag name="error" />
|
||||
<tag name="message" />
|
||||
<tag name="poll_srl" />
|
||||
<tag name="tpl" />
|
||||
</response>
|
||||
</filter>
|
||||
|
|
|
|||
|
|
@ -2,49 +2,61 @@
|
|||
<!--%import("js/poll.js")-->
|
||||
<!--%import("css/poll.css")-->
|
||||
|
||||
<div class="poll_box" style="{$poll->style}">
|
||||
<script type="text/javascript">
|
||||
var poll_alert_lang = "{$lang->msg_check_poll_item}";
|
||||
</script>
|
||||
|
||||
<form action="./" method="get" onsubmit="return doPoll(this)">
|
||||
<div id="poll_{$poll->poll_srl}">
|
||||
|
||||
<div class="poll_title_box">
|
||||
<div class="poll_total_count">
|
||||
{$lang->poll_total_count} : {number_format($poll->poll_count)}
|
||||
</div>
|
||||
<div class="poll_stop_date">
|
||||
{$lang->poll_stop_date} : {zdate($poll->stop_date, "Y-m-d H:i")}
|
||||
</div>
|
||||
</div>
|
||||
<div class="poll_box" style="{$poll->style}">
|
||||
|
||||
<!--@foreach($poll->poll as $poll_srl_index => $val)-->
|
||||
<form action="./" method="get" onsubmit="return doPoll(this)">
|
||||
|
||||
<div class="poll_detail_box">
|
||||
<div class="title">{$poll_srl_index}. {$val->title} ({$val->poll_count})</div>
|
||||
<!--@foreach($val->item as $item_srl => $item)-->
|
||||
{@$_idx = $poll->poll_srl.'_'.$poll_srl_index.'_'.$item_srl}
|
||||
<input type="hidden" name="poll_srl" value="{$poll->poll_srl}" />
|
||||
<input type="hidden" name="poll_srl_indexes" value="" />
|
||||
|
||||
<div class="poll_title_box">
|
||||
<div class="poll_total_count">
|
||||
{$lang->poll_total_count} : {number_format($poll->poll_count)}
|
||||
</div>
|
||||
<div class="poll_stop_date">
|
||||
{$lang->poll_stop_date} : {zdate($poll->stop_date, "Y-m-d H:i")}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--@foreach($poll->poll as $poll_srl_index => $val)-->
|
||||
<input type="hidden" name="checkcount_{$poll_srl_index}" value="{$val->checkcount}" />
|
||||
|
||||
<div class="poll_detail_box">
|
||||
<div class="title">{$poll_srl_index}. {$val->title} ({$val->poll_count})</div>
|
||||
<!--@foreach($val->item as $item_srl => $item)-->
|
||||
{@$_idx = $poll->poll_srl.'_'.$poll_srl_index.'_'.$item_srl}
|
||||
|
||||
<div class="item">
|
||||
<!--@if($val->checkcount>1)-->
|
||||
<input type="checkbox" name="item_{$poll->poll_srl}_{$poll_srl_index}" value="{$item->poll_item_srl}" id="item_{$item->poll_item_srl}" />
|
||||
<!--@else-->
|
||||
<input type="radio" name="item_{$poll->poll_srl}_{$poll_srl_index}" value="{$item->poll_item_srl}" id="item_{$item->poll_item_srl}" />
|
||||
<!--@end-->
|
||||
<label for="item_{$item->poll_item_srl}">{$item->title} ({$item->poll_count})</label>
|
||||
</div>
|
||||
<!--@end-->
|
||||
|
||||
<!--@if($val->checkcount>1)-->
|
||||
<div class="checkcount">
|
||||
{$lang->poll_check_count} : {$val->checkcount}
|
||||
</div>
|
||||
<!--@end-->
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<!--@if($val->checkcount>1)-->
|
||||
<input type="checkbox" name="item_{$poll->poll_srl}_{$poll_srl_index}" value="{$item_srl}" id="poll_item_{$_idx}" />
|
||||
<!--@else-->
|
||||
<input type="radio" name="item_{$poll->poll_srl}_{$poll_srl_index}" value="{$item_srl}" id="poll_item_{$_idx}" />
|
||||
<!--@end-->
|
||||
<label for="poll_item_{$_idx}">{$item->title} ({$item->poll_count})</label>
|
||||
</div>
|
||||
<!--@end-->
|
||||
|
||||
<!--@if($val->checkcount>1)-->
|
||||
<div class="checkcount">
|
||||
{$lang->poll_check_count} : {$val->checkcount}
|
||||
</div>
|
||||
<!--@end-->
|
||||
<div class="poll_button_area">
|
||||
<input type="submit" value="{$lang->cmd_apply_poll}" class="poll_button" />
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<!--@end-->
|
||||
|
||||
<div class="poll_button_area">
|
||||
<input type="submit" value="{$lang->cmd_apply_poll}" class="poll_button" />
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,49 @@
|
|||
/* 설문 참여 함수 */
|
||||
function doPoll(fo_obj) {
|
||||
|
||||
procFilter(fo_obj, poll);
|
||||
var check_count = new Array();
|
||||
var item = new Array();
|
||||
|
||||
for(var i=0;i<fo_obj.length;i++) {
|
||||
var obj = fo_obj[i];
|
||||
if(obj.nodeName != 'INPUT') continue;
|
||||
|
||||
var name = obj.name;
|
||||
if(name.indexOf('checkcount')>-1) {
|
||||
var t = name.split('_');
|
||||
var poll_srl_index = parseInt(t[1],10);
|
||||
check_count[poll_srl_index] = obj.value;
|
||||
item[poll_srl_index] = new Array();
|
||||
|
||||
} else if(name.indexOf('item_')>-1) {
|
||||
var t = name.split('_');
|
||||
var poll_srl = parseInt(t[1],10);
|
||||
var poll_srl_index = parseInt(t[2],10);
|
||||
if(obj.checked == true) item[poll_srl_index][item[poll_srl_index].length] = obj.value;
|
||||
}
|
||||
}
|
||||
|
||||
var poll_srl_indexes = "";
|
||||
for(var poll_srl_index in check_count) {
|
||||
var count = check_count[poll_srl_index];
|
||||
var items = item[poll_srl_index];
|
||||
if(count > items.length) {
|
||||
alert(poll_alert_lang);
|
||||
return false;
|
||||
}
|
||||
|
||||
poll_srl_indexes += items.join(',')+',';
|
||||
}
|
||||
fo_obj.poll_srl_indexes.value = poll_srl_indexes;
|
||||
|
||||
procFilter(fo_obj, poll);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 설문 조사후 내용을 바꿀 함수 */
|
||||
function completePoll(ret_obj) {
|
||||
alert(ret_obj['message']);
|
||||
var poll_srl = ret_obj['poll_srl'];
|
||||
var tpl = ret_obj['tpl'];
|
||||
xInnerHtml("poll_"+poll_srl, tpl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,34 @@
|
|||
hihi
|
||||
<!--%import("css/poll.css")-->
|
||||
|
||||
<div class="poll_box" style="{$poll->style}">
|
||||
|
||||
<div class="poll_title_box">
|
||||
<div class="poll_total_count">
|
||||
{$lang->poll_total_count} : {number_format($poll->poll_count)}
|
||||
</div>
|
||||
<div class="poll_stop_date">
|
||||
{$lang->poll_stop_date} : {zdate($poll->stop_date, "Y-m-d H:i")}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--@foreach($poll->poll as $poll_srl_index => $val)-->
|
||||
<div class="poll_detail_box">
|
||||
<div class="title">{$poll_srl_index}. {$val->title} ({$val->poll_count})</div>
|
||||
<!--@foreach($val->item as $item_srl => $item)-->
|
||||
{@$per = (int)(( $item->poll_count / $val->poll_count)*100) }
|
||||
|
||||
<div class="text">
|
||||
{$item->title} : {$item->poll_count} ({$per}%)
|
||||
</div>
|
||||
<!--@if($per)-->
|
||||
<div class="bar" style="width:{$per}%;"></div>
|
||||
<!--@else-->
|
||||
<div class="bar" style="width:2px;"></div>
|
||||
<!--@end-->
|
||||
<!--@end-->
|
||||
|
||||
</div>
|
||||
|
||||
<!--@end-->
|
||||
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue