source: temp/trunk/html/admin/contents/inquiry.php @ 5229

Revision 5229, 6.9 KB checked in by kakinaka, 20 years ago (diff)

blank

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