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

Revision 1328, 6.7 KB checked in by naka, 20 years ago (diff)

* empty log message *

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