1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | require_once("../require.php"); |
---|
8 | |
---|
9 | class LC_Page { |
---|
10 | var $arrSession; |
---|
11 | var $arrHidden; |
---|
12 | var $arrForm; |
---|
13 | var $tpl_class_name; |
---|
14 | var $arrClassCat; |
---|
15 | function LC_Page() { |
---|
16 | $this->tpl_mainpage = 'products/classcategory.tpl'; |
---|
17 | $this->tpl_subnavi = 'products/subnavi.tpl'; |
---|
18 | $this->tpl_subno = 'class'; |
---|
19 | $this->tpl_subtitle = 'µ¬³ÊÅÐÏ¿'; |
---|
20 | $this->tpl_mainno = 'products'; |
---|
21 | } |
---|
22 | } |
---|
23 | |
---|
24 | $conn = new SC_DBConn(); |
---|
25 | $objPage = new LC_Page(); |
---|
26 | $objView = new SC_AdminView(); |
---|
27 | $objQuery = new SC_Query(); |
---|
28 | |
---|
29 | // ǧ¾Ú²ÄÈݤÎȽÄê |
---|
30 | $objSess = new SC_Session(); |
---|
31 | sfIsSuccess($objSess); |
---|
32 | |
---|
33 | $get_check = false; |
---|
34 | |
---|
35 | // µ¬³ÊID¤Î¥Á¥§¥Ã¥¯ |
---|
36 | if(sfIsInt($_GET['class_id'])) { |
---|
37 | // µ¬³Ê̾¤Î¼èÆÀ |
---|
38 | $objPage->tpl_class_name = $objQuery->get("dtb_class", "name", "class_id = ?", array($_GET['class_id'])); |
---|
39 | if($objPage->tpl_class_name != "") { |
---|
40 | // µ¬³ÊID¤Î°ú¤·Ñ¤® |
---|
41 | $objPage->arrHidden['class_id'] = $_GET['class_id']; |
---|
42 | $get_check = true; |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | if(!$get_check) { |
---|
47 | // µ¬³ÊÅÐÏ¿¥Ú¡¼¥¸¤ËÈô¤Ð¤¹¡£ |
---|
48 | header("Location: " . URL_CLASS_REGIST); |
---|
49 | exit; |
---|
50 | } |
---|
51 | |
---|
52 | // ¿·µ¬ºîÀ® or ÊÔ½¸ |
---|
53 | switch($_POST['mode']) { |
---|
54 | // ÅÐÏ¿¥Ü¥¿¥ó²¡²¼ |
---|
55 | case 'edit': |
---|
56 | // POSTÃͤΰú¤·Ñ¤® |
---|
57 | $objPage->arrForm = $_POST; |
---|
58 | // ÆþÎÏʸ»ú¤ÎÊÑ´¹ |
---|
59 | $_POST = lfConvertParam($_POST); |
---|
60 | // ¥¨¥é¡¼¥Á¥§¥Ã¥¯ |
---|
61 | $objPage->arrErr = lfErrorCheck(); |
---|
62 | if(count($objPage->arrErr) <= 0) { |
---|
63 | if($_POST['classcategory_id'] == "") { |
---|
64 | lfInsertClass(); // DB¤Ø¤Î½ñ¤¹þ¤ß |
---|
65 | } else { |
---|
66 | lfUpdateClass(); // DB¤Ø¤Î½ñ¤¹þ¤ß |
---|
67 | } |
---|
68 | // ºÆɽ¼¨ |
---|
69 | sfReload("class_id=" . $_GET['class_id']); |
---|
70 | } else { |
---|
71 | // POST¥Ç¡¼¥¿¤ò°ú¤·Ñ¤° |
---|
72 | $objPage->tpl_classcategory_id = $_POST['classcategory_id']; |
---|
73 | } |
---|
74 | break; |
---|
75 | // ºï½ü |
---|
76 | case 'delete': |
---|
77 | // ¥é¥ó¥¯ÉÕ¤¥ì¥³¡¼¥É¤Îºï½ü |
---|
78 | $where = "class_id = " . addslashes($_POST['class_id']); |
---|
79 | sfDeleteRankRecord("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where, true); |
---|
80 | break; |
---|
81 | // ÊÔ½¸Á°½èÍý |
---|
82 | case 'pre_edit': |
---|
83 | // ÊÔ½¸¹àÌܤòDB¤è¤ê¼èÆÀ¤¹¤ë¡£ |
---|
84 | $where = "classcategory_id = ?"; |
---|
85 | $name = $objQuery->get("dtb_classcategory", "name", $where, array($_POST['classcategory_id'])); |
---|
86 | // ÆþÎϹàÌܤ˥«¥Æ¥´¥ê̾¤òÆþÎϤ¹¤ë¡£ |
---|
87 | $objPage->arrForm['name'] = $name; |
---|
88 | // POST¥Ç¡¼¥¿¤ò°ú¤·Ñ¤° |
---|
89 | $objPage->tpl_classcategory_id = $_POST['classcategory_id']; |
---|
90 | break; |
---|
91 | case 'down': |
---|
92 | $where = "class_id = " . addslashes($_POST['class_id']); |
---|
93 | sfRankDown("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where); |
---|
94 | break; |
---|
95 | case 'up': |
---|
96 | $where = "class_id = " . addslashes($_POST['class_id']); |
---|
97 | sfRankUp("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where); |
---|
98 | break; |
---|
99 | default: |
---|
100 | break; |
---|
101 | } |
---|
102 | |
---|
103 | // µ¬³ÊʬÎà¤ÎÆɹþ |
---|
104 | $where = "del_flg <> 1 AND class_id = ?"; |
---|
105 | $objQuery->setorder("rank DESC"); |
---|
106 | $objPage->arrClassCat = $objQuery->select("name, classcategory_id", "dtb_classcategory", $where, array($_GET['class_id'])); |
---|
107 | |
---|
108 | $objView->assignobj($objPage); |
---|
109 | $objView->display(MAIN_FRAME); |
---|
110 | |
---|
111 | //----------------------------------------------------------------------------------------------------------------------------- |
---|
112 | |
---|
113 | /* DB¤Ø¤ÎÁÞÆþ */ |
---|
114 | function lfInsertClass() { |
---|
115 | $objQuery = new SC_Query(); |
---|
116 | $objQuery->begin(); |
---|
117 | // ¿Æµ¬³ÊID¤Î¸ºß¥Á¥§¥Ã¥¯ |
---|
118 | $where = "del_flg <> 1 AND class_id = ?"; |
---|
119 | $ret = $objQuery->get("dtb_class", "class_id", $where, array($_POST['class_id'])); |
---|
120 | if($ret != "") { |
---|
121 | // INSERT¤¹¤ëÃͤòºîÀ®¤¹¤ë¡£ |
---|
122 | $sqlval['name'] = $_POST['name']; |
---|
123 | $sqlval['class_id'] = $_POST['class_id']; |
---|
124 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
125 | $sqlval['rank'] = $objQuery->max("dtb_classcategory", "rank", $where, array($_POST['class_id'])) + 1; |
---|
126 | $sqlval['create_date'] = "now()"; |
---|
127 | $sqlval['update_date'] = "now()"; |
---|
128 | // INSERT¤Î¼Â¹Ô |
---|
129 | $ret = $objQuery->insert("dtb_classcategory", $sqlval); |
---|
130 | } |
---|
131 | $objQuery->commit(); |
---|
132 | return $ret; |
---|
133 | } |
---|
134 | |
---|
135 | /* DB¤Ø¤Î¹¹¿· */ |
---|
136 | function lfUpdateClass() { |
---|
137 | $objQuery = new SC_Query(); |
---|
138 | // UPDATE¤¹¤ëÃͤòºîÀ®¤¹¤ë¡£ |
---|
139 | $sqlval['name'] = $_POST['name']; |
---|
140 | $sqlval['update_date'] = "Now()"; |
---|
141 | $where = "classcategory_id = ?"; |
---|
142 | // UPDATE¤Î¼Â¹Ô |
---|
143 | $ret = $objQuery->update("dtb_classcategory", $sqlval, $where, array($_POST['classcategory_id'])); |
---|
144 | return $ret; |
---|
145 | } |
---|
146 | |
---|
147 | /* ¼èÆÀʸ»úÎó¤ÎÊÑ´¹ */ |
---|
148 | function lfConvertParam($array) { |
---|
149 | // ʸ»úÊÑ´¹ |
---|
150 | $arrConvList['name'] = "KVa"; |
---|
151 | |
---|
152 | foreach ($arrConvList as $key => $val) { |
---|
153 | // POST¤µ¤ì¤Æ¤¤¿ÃͤΤßÊÑ´¹¤¹¤ë¡£ |
---|
154 | if(isset($array[$key])) { |
---|
155 | $array[$key] = mb_convert_kana($array[$key] ,$val); |
---|
156 | } |
---|
157 | } |
---|
158 | return $array; |
---|
159 | } |
---|
160 | |
---|
161 | /* ÆþÎÏ¥¨¥é¡¼¥Á¥§¥Ã¥¯ */ |
---|
162 | function lfErrorCheck() { |
---|
163 | $objErr = new SC_CheckError(); |
---|
164 | $objErr->doFunc(array("ʬÎà̾", "name", STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); |
---|
165 | if(!isset($objErr->arrErr['name'])) { |
---|
166 | $objQuery = new SC_Query(); |
---|
167 | $where = "class_id = ? AND name = ?"; |
---|
168 | $arrRet = $objQuery->select("classcategory_id, name", "dtb_classcategory", $where, array($_GET['class_id'], $_POST['name'])); |
---|
169 | // ÊÔ½¸Ãæ¤Î¥ì¥³¡¼¥É°Ê³°¤ËƱ¤¸Ì¾¾Î¤¬Â¸ºß¤¹¤ë¾ì¹ç |
---|
170 | if ($arrRet[0]['classcategory_id'] != $_POST['classcategory_id'] && $arrRet[0]['name'] == $_POST['name']) { |
---|
171 | $objErr->arrErr['name'] = "¢¨ ´û¤ËƱ¤¸ÆâÍƤÎÅÐÏ¿¤¬Â¸ºß¤·¤Þ¤¹¡£<br>"; |
---|
172 | } |
---|
173 | } |
---|
174 | return $objErr->arrErr; |
---|
175 | } |
---|
176 | ?> |
---|