1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | require_once("../require.php"); |
---|
8 | |
---|
9 | require_once("../order/index_csv.php"); |
---|
10 | |
---|
11 | $arrCVSCOL = array( |
---|
12 | |
---|
13 | ); |
---|
14 | |
---|
15 | $arrCVSTITLE = array( |
---|
16 | '²óÅúID', |
---|
17 | '¼ÁÌäID', |
---|
18 | '²óÅúÆü»þ', |
---|
19 | '²óÅú̾', |
---|
20 | '¸ÜµÒ̾1', |
---|
21 | '¸ÜµÒ̾2', |
---|
22 | '¸ÜµÒ̾¥«¥Ê1', |
---|
23 | '¸ÜµÒ̾¥«¥Ê2', |
---|
24 | '͹ÊØÈÖ¹æ1', |
---|
25 | '͹ÊØÈÖ¹æ2', |
---|
26 | 'ÅÔÆ»Éܸ©', |
---|
27 | '½»½ê1', |
---|
28 | '½»½ê2', |
---|
29 | 'ÅÅÏÃÈÖ¹æ1', |
---|
30 | 'ÅÅÏÃÈÖ¹æ2', |
---|
31 | 'ÅÅÏÃÈÖ¹æ3', |
---|
32 | '¥á¡¼¥ë¥¢¥É¥ì¥¹', |
---|
33 | '²óÅú1', |
---|
34 | '²óÅú2', |
---|
35 | '²óÅú3', |
---|
36 | '²óÅú4', |
---|
37 | '²óÅú5', |
---|
38 | '²óÅú6' |
---|
39 | ); |
---|
40 | |
---|
41 | |
---|
42 | class LC_Page { |
---|
43 | var $cnt_question; |
---|
44 | |
---|
45 | var $ERROR; |
---|
46 | var $ERROR_COLOR; |
---|
47 | var $MESSAGE; |
---|
48 | |
---|
49 | var $QUESTION_ID; |
---|
50 | |
---|
51 | var $arrActive; |
---|
52 | var $arrQuestion; |
---|
53 | var $arrSession; |
---|
54 | |
---|
55 | function LC_Page() { |
---|
56 | $this->tpl_mainpage = 'contents/inquiry.tpl'; |
---|
57 | $this->tpl_mainno = 'contents'; |
---|
58 | $this->tpl_subnavi = 'contents/subnavi.tpl'; |
---|
59 | $this->tpl_subno = "inquiry"; |
---|
60 | $this->tpl_subtitle = '¥¢¥ó¥±¡¼¥È´ÉÍý'; |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | $conn = new SC_DBConn(); |
---|
65 | $objPage = new LC_Page(); |
---|
66 | $objView = new SC_AdminView(); |
---|
67 | $objSess = new SC_Session(); |
---|
68 | |
---|
69 | // ǧ¾Ú²ÄÈݤÎȽÄê |
---|
70 | sfIsSuccess($objSess); |
---|
71 | |
---|
72 | $arrActive = array( "0"=>"²ÔƯ", "1"=>"Èó²ÔƯ" ); |
---|
73 | $arrQuestion = array( "0"=>"»ÈÍѤ·¤Ê¤¤", "1"=>"¥Æ¥¥¹¥È¥¨¥ê¥¢", "2"=>"¥Æ¥¥¹¥È¥Ü¥Ã¥¯¥¹" |
---|
74 | , "3"=>"¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹", "4"=>"¥é¥¸¥ª¥Ü¥¿¥ó" |
---|
75 | ); |
---|
76 | |
---|
77 | $sql = "SELECT *, cast(substring(create_date, 1, 10) as date) as disp_date FROM dtb_question WHERE del_flg = 0 ORDER BY question_id"; |
---|
78 | $result = $conn->getAll($sql); |
---|
79 | $objPage->list_data = $result; |
---|
80 | |
---|
81 | |
---|
82 | if ( $_GET['mode'] == 'regist' ){ |
---|
83 | |
---|
84 | for ( $i=0; $i<count($_POST["question"]); $i++ ) { |
---|
85 | $_POST['question'][$i]['name'] = mb_convert_kana( trim ( $_POST['question'][$i]['name'] ), "K" ); |
---|
86 | for ( $j=0; $j<count( $_POST['question'][$i]['option'] ); $j++ ){ |
---|
87 | $_POST['question'][$i]['option'][$j] = mb_convert_kana( trim ( $_POST['question'][$i]['option'][$j] ) ); |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | $error = lfErrCheck(); |
---|
92 | |
---|
93 | if ( ! $error ){ |
---|
94 | |
---|
95 | if ( ! is_numeric($_POST['question_id']) ){ |
---|
96 | $objQuery = new SC_Query(); |
---|
97 | |
---|
98 | //ÅÐÏ¿ |
---|
99 | $value = serialize($_POST); |
---|
100 | if (DB_TYPE == "pgsql") { |
---|
101 | $question_id = $objQuery->nextval('dtb_question', 'question_id'); |
---|
102 | } |
---|
103 | |
---|
104 | $sql_val = array( $value, $_POST['title'] ,$question_id ); |
---|
105 | $conn->query("INSERT INTO dtb_question ( question, question_name, question_id, create_date) VALUES (?, ?, ?, now())", $sql_val ); |
---|
106 | $objPage->MESSAGE = "ÅÐÏ¿¤¬´°Î»¤·¤Þ¤·¤¿"; |
---|
107 | |
---|
108 | if (DB_TYPE == "mysql") { |
---|
109 | $question_id = $objQuery->nextval('dtb_question', 'question_id'); |
---|
110 | } |
---|
111 | |
---|
112 | $objPage->QUESTION_ID = $question_id; |
---|
113 | sfReload(); |
---|
114 | } else { |
---|
115 | //ÊÔ½¸ |
---|
116 | $value = serialize($_POST); |
---|
117 | $sql_val = array( $value, $_POST['title'] ,$_POST['question_id'] ); |
---|
118 | $conn->query("UPDATE dtb_question SET question = ?, question_name = ? WHERE question_id = ?", $sql_val ); |
---|
119 | $objPage->MESSAGE = "ÊÔ½¸¤¬´°Î»¤·¤Þ¤·¤¿"; |
---|
120 | $objPage->QUESTION_ID = $_POST['question_id']; |
---|
121 | sfReload(); |
---|
122 | } |
---|
123 | } else { |
---|
124 | |
---|
125 | //¥¨¥é¡¼É½¼¨ |
---|
126 | $objPage->ERROR = $error; |
---|
127 | $objPage->QUESTION_ID = $_REQUEST['question_id']; |
---|
128 | $objPage->ERROR_COLOR = lfGetErrColor($error, ERR_COLOR); |
---|
129 | |
---|
130 | } |
---|
131 | } elseif ( ( $_GET['mode'] == 'delete' ) && ( sfCheckNumLength($_GET['question_id']) ) ){ |
---|
132 | |
---|
133 | $sql = "UPDATE dtb_question SET del_flg = 1 WHERE question_id = ?"; |
---|
134 | $conn->query( $sql, array( $_GET['question_id'] ) ); |
---|
135 | sfReload(); |
---|
136 | |
---|
137 | } elseif ( ( $_GET['mode'] == 'csv' ) && ( sfCheckNumLength($_GET['question_id']) ) ){ |
---|
138 | |
---|
139 | $head = sfGetCSVList($arrCVSTITLE); |
---|
140 | $list_data = $conn->getAll("SELECT result_id,question_id,question_date,question_name,name01,name02,kana01,kana02,zip01,zip02,pref,addr01,addr02,tel01,tel02,tel03,mail01,question01,question02,question03,question04,question05,question06 FROM dtb_question_result WHERE del_flg = 0 ORDER BY result_id ASC"); |
---|
141 | $data = ""; |
---|
142 | for($i = 0; $i < count($list_data); $i++) { |
---|
143 | // ³Æ¹àÌܤòCSV½ÐÎÏÍѤËÊÑ´¹¤¹¤ë¡£ |
---|
144 | $data .= lfMakeCSV($list_data[$i]); |
---|
145 | } |
---|
146 | // CSV¤òÁ÷¿®¤¹¤ë |
---|
147 | sfCSVDownload($head.$data); |
---|
148 | exit; |
---|
149 | |
---|
150 | } else { |
---|
151 | |
---|
152 | if ( is_numeric($_GET['question_id']) ){ |
---|
153 | |
---|
154 | $sql = "SELECT question FROM dtb_question WHERE question_id = ?"; |
---|
155 | $result = $conn->getOne($sql, array($_GET['question_id'])); |
---|
156 | |
---|
157 | if ( $result ){ |
---|
158 | $_POST = unserialize( $result ); |
---|
159 | $objPage->QUESTION_ID = $_GET['question_id']; |
---|
160 | } |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | |
---|
165 | |
---|
166 | |
---|
167 | //³Æ¥Ú¡¼¥¸¶¦ÄÌ |
---|
168 | $objPage->cnt_question = 6; |
---|
169 | $objPage->arrActive = $arrActive; |
---|
170 | $objPage->arrQuestion = $arrQuestion; |
---|
171 | |
---|
172 | |
---|
173 | //----¡¡¥Ú¡¼¥¸É½¼¨ |
---|
174 | $objView->assignobj($objPage); |
---|
175 | $objView->display(MAIN_FRAME); |
---|
176 | |
---|
177 | |
---|
178 | // ------------ ¥¨¥é¡¼¥Á¥§¥Ã¥¯½èÍýÉô ------------ |
---|
179 | |
---|
180 | function lfGetErrColor( $arr, $err_color ){ |
---|
181 | |
---|
182 | foreach ( $arr as $key=>$val ) { |
---|
183 | if ( is_string($val) && strlen($val) > 0 ){ |
---|
184 | $return[$key] = $err_color; |
---|
185 | } elseif ( is_array( $val ) ) { |
---|
186 | $return[$key] = lfGetErrColor ( $val, $err_color); |
---|
187 | } |
---|
188 | } |
---|
189 | return $return; |
---|
190 | } |
---|
191 | |
---|
192 | |
---|
193 | // ------------ ¥¨¥é¡¼¥Á¥§¥Ã¥¯½èÍýÉô ------------ |
---|
194 | |
---|
195 | function lfErrCheck (){ |
---|
196 | |
---|
197 | $objErr = new SC_CheckError(); |
---|
198 | $errMsg = ""; |
---|
199 | |
---|
200 | $objErr->doFunc( array( "²ÔƯ¡¦Èó²ÔƯ", "active" ), array( "SELECT_CHECK" ) ); |
---|
201 | |
---|
202 | $_POST["title"] = mb_convert_kana( trim ( $_POST["title"] ), "K" ); |
---|
203 | $objErr->doFunc( array( "¥¢¥ó¥±¡¼¥È̾", "title" ), array( "EXIST_CHECK" ) ); |
---|
204 | |
---|
205 | $_POST["contents"] = mb_convert_kana( trim ( $_POST["contents"] ), "K" ); |
---|
206 | $objErr->doFunc( array( "¥¢¥ó¥±¡¼¥ÈÆâÍÆ" ,"contents", "3000" ), array( "EXIST_CHECK", "MAX_LENGTH_CHECK" ) ); |
---|
207 | |
---|
208 | |
---|
209 | if ( ! $_POST['question'][0]["name"] ){ |
---|
210 | $objErr->arrErr['question'][0]["name"] = "£±¤Ä¤á¤Î¼ÁÌä̾¤¬ÆþÎϤµ¤ì¤Æ¤¤¤Þ¤»¤ó"; |
---|
211 | } |
---|
212 | |
---|
213 | //¡¡¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¡¢¥é¥¸¥ª¥Ü¥¿¥ó¤òÁªÂò¤·¤¿¾ì¹ç¤ÏºÇÄã1¤Ä°Ê¾å¹àÌܤòµÆþ¤µ¤»¤ë¡£ |
---|
214 | for( $i = 0; $i < count( $_POST["question"] ); $i++ ) { |
---|
215 | |
---|
216 | if ( $_POST["question"][$i]["kind"] ) { |
---|
217 | if (strlen($_POST["question"][$i]["name"]) == 0) { |
---|
218 | $objErr->arrErr["question"][$i]["name"] = "¥¿¥¤¥È¥ë¤òÆþÎϤ·¤Æ²¼¤µ¤¤¡£"; |
---|
219 | } else if ( strlen($_POST["question"][$i]["name"]) > STEXT_LEN ) { |
---|
220 | $objErr->arrErr["question"][$i]["name"] = "¥¿¥¤¥È¥ë¤Ï". STEXT_LEN ."»ú°ÊÆâ¤ÇÆþÎϤ·¤Æ²¼¤µ¤¤¡£"; |
---|
221 | } |
---|
222 | } |
---|
223 | |
---|
224 | if( $_POST["question"][$i]["kind"] == 3 || $_POST["question"][$i]["kind"] == 4 ) { |
---|
225 | |
---|
226 | $temp_data = array(); |
---|
227 | for( $j = 0; $j < count( $_POST["question"][$i]["option"] ); $j++ ) { |
---|
228 | |
---|
229 | // ¹àÌܴ֡ʥƥ¥¹¥È¥Ü¥Ã¥¯¥¹¡Ë¤¬¤¢¤¤¤Æ¤¤¤¿¤éµÍ¤á¤Æ¤¤¤¯ |
---|
230 | if( strlen( $_POST["question"][$i]["option"][$j] ) > 0 ) $temp_data[] = mb_convert_kana( trim ( $_POST["question"][$i]["option"][$j] ), "asKVn" ); |
---|
231 | |
---|
232 | } |
---|
233 | |
---|
234 | $_POST["question"][$i]["option"] = $temp_data; |
---|
235 | |
---|
236 | if( ( strlen( $_POST["question"][$i] ["option"][0] ) == 0 ) || ( strlen( $_POST["question"][$i] ["option"][0] ) > 0 |
---|
237 | && strlen( $_POST["question"][$i] ["option"][1] ) == 0 ) ) $objErr->arrErr["question"][$i]['kind'] = "²¼µ¤Î2¤Ä°Ê¾å¤Î¹àÌܤ˵Æþ¤·¤Æ¤¯¤À¤µ¤¤¡£"; |
---|
238 | } |
---|
239 | } |
---|
240 | |
---|
241 | return lfGetArrInput( $objErr->arrErr ); |
---|
242 | |
---|
243 | } |
---|
244 | |
---|
245 | |
---|
246 | function lfGetArrInput( $arr ){ |
---|
247 | // Ãͤ¬ÆþÎϤµ¤ì¤¿ÇÛÎó¤Î¤ß¤òÊÖ¤¹ |
---|
248 | |
---|
249 | if ( is_array($arr) ){ |
---|
250 | foreach ( $arr as $key=>$val ) { |
---|
251 | if ( is_string($val) && strlen($val) > 0 ){ |
---|
252 | $return[$key] = $val; |
---|
253 | } elseif ( is_array( $val ) ) { |
---|
254 | $data = lfGetArrInput ( $val ); |
---|
255 | if ( $data ){ |
---|
256 | $return[$key] = $data; |
---|
257 | } |
---|
258 | } |
---|
259 | } |
---|
260 | } |
---|
261 | return $return; |
---|
262 | } |
---|
263 | ?> |
---|