source: branches/version-2_5-dev/data/class/pages/admin/products/LC_Page_Admin_Products_ClassCategory.php @ 19803

Revision 19803, 8.2 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある)

  • 一斉置換前の現状記録のためのコミット

#628(未使用処理・定義などの削除)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once(CLASS_FILE_PATH . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * 規格分類 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id:LC_Page_Admin_Products_ClassCategory.php 15532 2007-08-31 14:39:46Z nanasess $
33 */
34class LC_Page_Admin_Products_ClassCategory extends LC_Page_Admin {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'products/classcategory.tpl';
47        $this->tpl_subnavi = 'products/subnavi.tpl';
48        $this->tpl_subno = 'class';
49        $this->tpl_subtitle = '規格登録';
50        $this->tpl_mainno = 'products';
51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
58    function process() {
59        $this->action();
60        $this->sendResponse();
61    }
62
63    /**
64     * Page のアクション.
65     *
66     * @return void
67     */
68    function action() {
69        $objQuery = new SC_Query();
70        $objDb = new SC_Helper_DB_Ex();
71
72        // 認証可否の判定
73        $objSess = new SC_Session();
74        SC_Utils_Ex::sfIsSuccess($objSess);
75
76        $get_check = false;
77
78        // 規格IDのチェック
79        if(SC_Utils_Ex::sfIsInt($_GET['class_id'])) {
80            // 規格名の取得
81            $this->tpl_class_name = $objQuery->get("name", "dtb_class", "class_id = ?", array($_GET['class_id']));
82            if($this->tpl_class_name != "") {
83                // 規格IDの引き継ぎ
84                $this->arrHidden['class_id'] = $_GET['class_id'];
85                $get_check = true;
86            }
87        }
88
89        if(!$get_check) {
90            // 規格登録ページに飛ばす。
91            $this->objDisplay->redirect($this->getLocation(URL_CLASS_REGIST));
92            exit;
93        }
94
95        if (!isset($_POST['mode'])) $_POST['mode'] = "";
96
97        if (isset($_POST['class_id'])) {
98            if (!SC_Utils_Ex::sfIsInt($_POST['class_id'])) {
99                SC_Utils_Ex::sfDispError("");
100            }
101        }
102
103        // 新規作成 or 編集
104        switch($_POST['mode']) {
105            // 登録ボタン押下
106        case 'edit':
107            // POST値の引き継ぎ
108            $this->arrForm = $_POST;
109            // 入力文字の変換
110            $_POST = $this->lfConvertParam($_POST);
111            // エラーチェック
112            $this->arrErr = $this->lfErrorCheck();
113            if(count($this->arrErr) <= 0) {
114                if($_POST['classcategory_id'] == "") {
115                    $this->lfInsertClass(); // DBへの書き込み
116                } else {
117                    $this->lfUpdateClass(); // DBへの書き込み
118                }
119                // 再表示
120                $this->objDisplay->reload($_GET['class_id']);
121                //sfReload("class_id=" . $_GET['class_id']);
122            } else {
123                // POSTデータを引き継ぐ
124                $this->tpl_classcategory_id = $_POST['classcategory_id'];
125            }
126            break;
127            // 削除
128        case 'delete':
129            // ランク付きレコードの削除
130            $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['class_id']);
131            $objDb->sfDeleteRankRecord("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where, true);
132            break;
133            // 編集前処理
134        case 'pre_edit':
135            // 編集項目をDBより取得する。
136            $where = "classcategory_id = ?";
137            $name = $objQuery->get("name", "dtb_classcategory", $where, array($_POST['classcategory_id']));
138            // 入力項目にカテゴリ名を入力する。
139            $this->arrForm['name'] = $name;
140            // POSTデータを引き継ぐ
141            $this->tpl_classcategory_id = $_POST['classcategory_id'];
142            break;
143        case 'down':
144            $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['class_id']);
145            $objDb->sfRankDown("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where);
146            break;
147        case 'up':
148            $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['class_id']);
149            $objDb->sfRankUp("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where);
150            break;
151        default:
152            break;
153        }
154
155        // 規格分類の読込
156        $where = "del_flg <> 1 AND class_id = ?";
157        $objQuery->setOrder("rank DESC");
158        $this->arrClassCat = $objQuery->select("name, classcategory_id", "dtb_classcategory", $where, array($_GET['class_id']));
159    }
160
161    /**
162     * デストラクタ.
163     *
164     * @return void
165     */
166    function destroy() {
167        parent::destroy();
168    }
169
170    /* DBへの挿入 */
171    function lfInsertClass() {
172        $objQuery = new SC_Query();
173        $objQuery->begin();
174        // 親規格IDの存在チェック
175        $where = "del_flg <> 1 AND class_id = ?";
176        $ret =  $objQuery->get("class_id", "dtb_class", $where, array($_POST['class_id']));
177        if($ret != "") {
178            // INSERTする値を作成する。
179            $sqlval['name'] = $_POST['name'];
180            $sqlval['class_id'] = $_POST['class_id'];
181            $sqlval['creator_id'] = $_SESSION['member_id'];
182            $sqlval['rank'] = $objQuery->max("rank", "dtb_classcategory", $where, array($_POST['class_id'])) + 1;
183            $sqlval['create_date'] = "now()";
184            $sqlval['update_date'] = "now()";
185            // INSERTの実行
186            $sqlval['classcategory_id'] = $objQuery->nextVal('dtb_classcategory_classcategory_id');
187            $ret = $objQuery->insert("dtb_classcategory", $sqlval);
188        }
189        $objQuery->commit();
190        return $ret;
191    }
192
193    /* DBへの更新 */
194    function lfUpdateClass() {
195        $objQuery = new SC_Query();
196        // UPDATEする値を作成する。
197        $sqlval['name'] = $_POST['name'];
198        $sqlval['update_date'] = "Now()";
199        $where = "classcategory_id = ?";
200        // UPDATEの実行
201        $ret = $objQuery->update("dtb_classcategory", $sqlval, $where, array($_POST['classcategory_id']));
202        return $ret;
203    }
204
205    /* 取得文字列の変換 */
206    function lfConvertParam($array) {
207        // 文字変換
208        $arrConvList['name'] = "KVa";
209
210        foreach ($arrConvList as $key => $val) {
211            // POSTされてきた値のみ変換する。
212            if(isset($array[$key])) {
213                $array[$key] = mb_convert_kana($array[$key] ,$val);
214            }
215        }
216        return $array;
217    }
218
219    /* 入力エラーチェック */
220    function lfErrorCheck() {
221        $objErr = new SC_CheckError();
222        $objErr->doFunc(array("分類名", "name", STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
223        if(!isset($objErr->arrErr['name'])) {
224            $objQuery = new SC_Query();
225            $where = "class_id = ? AND name = ?";
226            $arrRet = $objQuery->select("classcategory_id, name", "dtb_classcategory", $where, array($_GET['class_id'], $_POST['name']));
227            // 編集中のレコード以外に同じ名称が存在する場合
228            if ($arrRet[0]['classcategory_id'] != $_POST['classcategory_id'] && $arrRet[0]['name'] == $_POST['name']) {
229                $objErr->arrErr['name'] = "※ 既に同じ内容の登録が存在します。<br>";
230            }
231        }
232        return $objErr->arrErr;
233    }
234}
235?>
Note: See TracBrowser for help on using the repository browser.