From 8a0f5b3998278a16ebb9d55d975ab2f1a7c2d202 Mon Sep 17 00:00:00 2001 From: zero Date: Fri, 6 Apr 2007 08:17:54 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@1008 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- common/js/xml_js_filter.js | 2 +- .../components/poll_maker/tpl/popup.html | 4 - modules/poll/conf/module.xml | 1 + modules/poll/lang/ko.lang.php | 4 + modules/poll/poll.controller.php | 56 +++++++++++++ modules/poll/poll.model.php | 36 ++++---- modules/poll/queries/getPollLog.xml | 6 +- modules/poll/queries/insertPollItem.xml | 1 + modules/poll/schemas/poll_item.xml | 1 + modules/poll/tpl/css/poll.css | 11 +++ modules/poll/tpl/filter/poll.xml | 4 +- modules/poll/tpl/form.html | 84 +++++++++++-------- modules/poll/tpl/js/poll.js | 44 +++++++++- modules/poll/tpl/result.html | 35 +++++++- 14 files changed, 226 insertions(+), 63 deletions(-) diff --git a/common/js/xml_js_filter.js b/common/js/xml_js_filter.js index f92c628a4..130ca56fd 100644 --- a/common/js/xml_js_filter.js +++ b/common/js/xml_js_filter.js @@ -98,7 +98,7 @@ function XmlJsFilterGetValue(target_name) { switch(type) { case 'checkbox' : if(length>0) { - value_list = new Array(); + var value_list = new Array(); for(var i=0;i -
-
{$lang->poll_item} 3
-
-
diff --git a/modules/poll/conf/module.xml b/modules/poll/conf/module.xml index a015bc5c9..24f7226a3 100644 --- a/modules/poll/conf/module.xml +++ b/modules/poll/conf/module.xml @@ -4,5 +4,6 @@ + diff --git a/modules/poll/lang/ko.lang.php b/modules/poll/lang/ko.lang.php index da63a9c8e..29d041a45 100644 --- a/modules/poll/lang/ko.lang.php +++ b/modules/poll/lang/ko.lang.php @@ -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다시 설정해주세요"; diff --git a/modules/poll/poll.controller.php b/modules/poll/poll.controller.php index e234936b7..172911203 100644 --- a/modules/poll/poll.controller.php +++ b/modules/poll/poll.controller.php @@ -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;$iisPolled($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'); + } + } ?> diff --git a/modules/poll/poll.model.php b/modules/poll/poll.model.php index fc2449b82..641d5a06f 100644 --- a/modules/poll/poll.model.php +++ b/modules/poll/poll.model.php @@ -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(); diff --git a/modules/poll/queries/getPollLog.xml b/modules/poll/queries/getPollLog.xml index a6e7f38ee..3398cd9b8 100644 --- a/modules/poll/queries/getPollLog.xml +++ b/modules/poll/queries/getPollLog.xml @@ -3,11 +3,11 @@ - + - - + + diff --git a/modules/poll/queries/insertPollItem.xml b/modules/poll/queries/insertPollItem.xml index ee8093bc7..b3e4204b5 100644 --- a/modules/poll/queries/insertPollItem.xml +++ b/modules/poll/queries/insertPollItem.xml @@ -3,6 +3,7 @@
+ diff --git a/modules/poll/schemas/poll_item.xml b/modules/poll/schemas/poll_item.xml index e1c9247cd..ff84be882 100644 --- a/modules/poll/schemas/poll_item.xml +++ b/modules/poll/schemas/poll_item.xml @@ -1,4 +1,5 @@
+ diff --git a/modules/poll/tpl/css/poll.css b/modules/poll/tpl/css/poll.css index 10af0175b..930c13ec4 100644 --- a/modules/poll/tpl/css/poll.css +++ b/modules/poll/tpl/css/poll.css @@ -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; } diff --git a/modules/poll/tpl/filter/poll.xml b/modules/poll/tpl/filter/poll.xml index 7c3453fcb..2639e3195 100644 --- a/modules/poll/tpl/filter/poll.xml +++ b/modules/poll/tpl/filter/poll.xml @@ -1,8 +1,10 @@
- + + +
diff --git a/modules/poll/tpl/form.html b/modules/poll/tpl/form.html index 591c3d3df..5de8756d8 100644 --- a/modules/poll/tpl/form.html +++ b/modules/poll/tpl/form.html @@ -2,49 +2,61 @@ -
+ - +
-
-
- {$lang->poll_total_count} : {number_format($poll->poll_count)} -
-
- {$lang->poll_stop_date} : {zdate($poll->stop_date, "Y-m-d H:i")} -
-
+
- + -
-
{$poll_srl_index}. {$val->title} ({$val->poll_count})
- - {@$_idx = $poll->poll_srl.'_'.$poll_srl_index.'_'.$item_srl} + + + +
+
+ {$lang->poll_total_count} : {number_format($poll->poll_count)} +
+
+ {$lang->poll_stop_date} : {zdate($poll->stop_date, "Y-m-d H:i")} +
+
+ + + + +
+
{$poll_srl_index}. {$val->title} ({$val->poll_count})
+ + {@$_idx = $poll->poll_srl.'_'.$poll_srl_index.'_'.$item_srl} + +
+ + + + + + +
+ + + +
+ {$lang->poll_check_count} : {$val->checkcount} +
+ +
-
- - - - - -
- - -
- {$lang->poll_check_count} : {$val->checkcount} -
- +
+ +
+ + +
- - -
- -
- - -
diff --git a/modules/poll/tpl/js/poll.js b/modules/poll/tpl/js/poll.js index c653f716b..a88dfcfe5 100644 --- a/modules/poll/tpl/js/poll.js +++ b/modules/poll/tpl/js/poll.js @@ -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-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); +} diff --git a/modules/poll/tpl/result.html b/modules/poll/tpl/result.html index 623d98c32..904af046e 100644 --- a/modules/poll/tpl/result.html +++ b/modules/poll/tpl/result.html @@ -1 +1,34 @@ -hihi + + +
+ +
+
+ {$lang->poll_total_count} : {number_format($poll->poll_count)} +
+
+ {$lang->poll_stop_date} : {zdate($poll->stop_date, "Y-m-d H:i")} +
+
+ + +
+
{$poll_srl_index}. {$val->title} ({$val->poll_count})
+ + {@$per = (int)(( $item->poll_count / $val->poll_count)*100) } + +
+ {$item->title} : {$item->poll_count} ({$per}%) +
+ +
+ +
+ + + +
+ + + +