source: branches/version-2_4/data/class/pages/admin/products/LC_Page_Admin_Products_ClassCategory.php @ 18734

Revision 18734, 8.0 KB checked in by nanasess, 14 years ago (diff)

Copyright の更新(#601)

  • 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_PATH . "pages/LC_Page.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 {
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        $conn = new SC_DBConn();
60        $objView = new SC_AdminView();
61        $objQuery = new SC_Query();
62        $objDb = new SC_Helper_DB_Ex();
63
64        // 認証可否の判定
65        $objSess = new SC_Session();
66        SC_Utils_Ex::sfIsSuccess($objSess);
67
68        $get_check = false;
69
70        // 規格IDのチェック
71        if(SC_Utils_Ex::sfIsInt($_GET['class_id'])) {
72            // 規格名の取得
73            $this->tpl_class_name = $objQuery->get("dtb_class", "name", "class_id = ?", array($_GET['class_id']));
74            if($this->tpl_class_name != "") {
75                // 規格IDの引き継ぎ
76                $this->arrHidden['class_id'] = $_GET['class_id'];
77                $get_check = true;
78            }
79        }
80
81        if(!$get_check) {
82            // 規格登録ページに飛ばす。
83            $this->sendRedirect($this->getLocation(URL_CLASS_REGIST));
84            exit;
85        }
86
87        if (!isset($_POST['mode'])) $_POST['mode'] = "";
88
89        if (isset($_POST['class_id'])) {
90            if (!SC_Utils_Ex::sfIsInt($_POST['class_id'])) {
91                SC_Utils_Ex::sfDispError("");
92            }
93        }
94
95        // 新規作成 or 編集
96        switch($_POST['mode']) {
97            // 登録ボタン押下
98        case 'edit':
99            // POST値の引き継ぎ
100            $this->arrForm = $_POST;
101            // 入力文字の変換
102            $_POST = $this->lfConvertParam($_POST);
103            // エラーチェック
104            $this->arrErr = $this->lfErrorCheck();
105            if(count($this->arrErr) <= 0) {
106                if($_POST['classcategory_id'] == "") {
107                    $this->lfInsertClass(); // DBへの書き込み
108                } else {
109                    $this->lfUpdateClass(); // DBへの書き込み
110                }
111                // 再表示
112                $this->reload($_GET['class_id']);
113                //sfReload("class_id=" . $_GET['class_id']);
114            } else {
115                // POSTデータを引き継ぐ
116                $this->tpl_classcategory_id = $_POST['classcategory_id'];
117            }
118            break;
119            // 削除
120        case 'delete':
121            // ランク付きレコードの削除
122            $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['class_id']);
123            $objDb->sfDeleteRankRecord("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where, true);
124            break;
125            // 編集前処理
126        case 'pre_edit':
127            // 編集項目をDBより取得する。
128            $where = "classcategory_id = ?";
129            $name = $objQuery->get("dtb_classcategory", "name", $where, array($_POST['classcategory_id']));
130            // 入力項目にカテゴリ名を入力する。
131            $this->arrForm['name'] = $name;
132            // POSTデータを引き継ぐ
133            $this->tpl_classcategory_id = $_POST['classcategory_id'];
134            break;
135        case 'down':
136            $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['class_id']);
137            $objDb->sfRankDown("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where);
138            break;
139        case 'up':
140            $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['class_id']);
141            $objDb->sfRankUp("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where);
142            break;
143        default:
144            break;
145        }
146
147        // 規格分類の読込
148        $where = "del_flg <> 1 AND class_id = ?";
149        $objQuery->setorder("rank DESC");
150        $this->arrClassCat = $objQuery->select("name, classcategory_id", "dtb_classcategory", $where, array($_GET['class_id']));
151
152        $objView->assignobj($this);
153        $objView->display(MAIN_FRAME);
154
155    }
156
157    /**
158     * デストラクタ.
159     *
160     * @return void
161     */
162    function destroy() {
163        parent::destroy();
164    }
165
166    /* DBへの挿入 */
167    function lfInsertClass() {
168        $objQuery = new SC_Query();
169        $objQuery->begin();
170        // 親規格IDの存在チェック
171        $where = "del_flg <> 1 AND class_id = ?";
172        $ret =  $objQuery->get("dtb_class", "class_id", $where, array($_POST['class_id']));
173        if($ret != "") {
174            // INSERTする値を作成する。
175            $sqlval['name'] = $_POST['name'];
176            $sqlval['class_id'] = $_POST['class_id'];
177            $sqlval['creator_id'] = $_SESSION['member_id'];
178            $sqlval['rank'] = $objQuery->max("dtb_classcategory", "rank", $where, array($_POST['class_id'])) + 1;
179            $sqlval['create_date'] = "now()";
180            $sqlval['update_date'] = "now()";
181            // INSERTの実行
182            $ret = $objQuery->insert("dtb_classcategory", $sqlval);
183        }
184        $objQuery->commit();
185        return $ret;
186    }
187
188    /* DBへの更新 */
189    function lfUpdateClass() {
190        $objQuery = new SC_Query();
191        // UPDATEする値を作成する。
192        $sqlval['name'] = $_POST['name'];
193        $sqlval['update_date'] = "Now()";
194        $where = "classcategory_id = ?";
195        // UPDATEの実行
196        $ret = $objQuery->update("dtb_classcategory", $sqlval, $where, array($_POST['classcategory_id']));
197        return $ret;
198    }
199
200    /* 取得文字列の変換 */
201    function lfConvertParam($array) {
202        // 文字変換
203        $arrConvList['name'] = "KVa";
204
205        foreach ($arrConvList as $key => $val) {
206            // POSTされてきた値のみ変換する。
207            if(isset($array[$key])) {
208                $array[$key] = mb_convert_kana($array[$key] ,$val);
209            }
210        }
211        return $array;
212    }
213
214    /* 入力エラーチェック */
215    function lfErrorCheck() {
216        $objErr = new SC_CheckError();
217        $objErr->doFunc(array("分類名", "name", STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
218        if(!isset($objErr->arrErr['name'])) {
219            $objQuery = new SC_Query();
220            $where = "class_id = ? AND name = ?";
221            $arrRet = $objQuery->select("classcategory_id, name", "dtb_classcategory", $where, array($_GET['class_id'], $_POST['name']));
222            // 編集中のレコード以外に同じ名称が存在する場合
223            if ($arrRet[0]['classcategory_id'] != $_POST['classcategory_id'] && $arrRet[0]['name'] == $_POST['name']) {
224                $objErr->arrErr['name'] = "※ 既に同じ内容の登録が存在します。<br>";
225            }
226        }
227        return $objErr->arrErr;
228    }
229}
230?>
Note: See TracBrowser for help on using the repository browser.