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

Revision 19803, 6.6 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$
33 */
34class LC_Page_Admin_Products_Class 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/class.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        $objSess = new SC_Session();
70        $objQuery =& SC_Query::getSingletonInstance();
71        $objDb = new SC_Helper_DB_Ex();
72
73        // 認証可否の判定
74        SC_Utils_Ex::sfIsSuccess($objSess);
75
76        if (!isset($_POST['mode'])) $_POST['mode'] = "";
77
78        // 要求判定
79        switch($_POST['mode']) {
80            // 編集処理
81        case 'edit':
82            // POST値の引き継ぎ
83            $this->arrForm = $_POST;
84            // 入力文字の変換
85            $this->arrForm = $this->lfConvertParam($this->arrForm);
86            // エラーチェック
87            $this->arrErr = $this->lfErrorCheck();
88            if(count($this->arrErr) <= 0) {
89                if($_POST['class_id'] == "") {
90                    $this->lfInsertClass($this->arrForm); // 新規作成
91                } else {
92                    $this->lfUpdateClass($this->arrForm); // 既存編集
93                }
94                // 再表示
95                $this->objDisplay->reload();
96            } else {
97                // POSTデータを引き継ぐ
98                $this->tpl_class_id = $_POST['class_id'];
99            }
100            break;
101            // 削除
102        case 'delete':
103            $objDb->sfDeleteRankRecord("dtb_class", "class_id", $_POST['class_id'], "", true);
104            $objQuery->delete("dtb_classcategory", "class_id = ?", $_POST['class_id']);
105            // 再表示
106            $this->objDisplay->reload();
107            break;
108            // 編集前処理
109        case 'pre_edit':
110            // 編集項目をDBより取得する。
111            $where = "class_id = ?";
112            $class_name = $objQuery->get("name", "dtb_class", $where, array($_POST['class_id']));
113            // 入力項目にカテゴリ名を入力する。
114            $this->arrForm['name'] = $class_name;
115            // POSTデータを引き継ぐ
116            $this->tpl_class_id = $_POST['class_id'];
117            break;
118        case 'down':
119            $objDb->sfRankDown("dtb_class", "class_id", $_POST['class_id']);
120            // 再表示
121            $this->objDisplay->reload();
122            break;
123        case 'up':
124            $objDb->sfRankUp("dtb_class", "class_id", $_POST['class_id']);
125            // 再表示
126            $this->objDisplay->reload();
127            break;
128        default:
129            break;
130        }
131
132        // 規格の読込
133        $where = "del_flg <> 1";
134        $objQuery->setOrder("rank DESC");
135        $this->arrClass = $objQuery->select("name, class_id", "dtb_class", $where);
136        $this->arrClassCatCount = SC_Utils_Ex::sfGetClassCatCount();
137    }
138
139    /**
140     * デストラクタ.
141     *
142     * @return void
143     */
144    function destroy() {
145        parent::destroy();
146    }
147
148    /* DBへの挿入 */
149    function lfInsertClass($arrData) {
150        $objQuery =& SC_Query::getSingletonInstance();
151        // INSERTする値を作成する。
152        $sqlval['name'] = $arrData['name'];
153        $sqlval['creator_id'] = $_SESSION['member_id'];
154        $sqlval['rank'] = $objQuery->max("rank", "dtb_class") + 1;
155        $sqlval['create_date'] = "now()";
156        $sqlval['update_date'] = "now()";
157        // INSERTの実行
158        $sqlval['class_id'] = $objQuery->nextVal('dtb_class_class_id');
159        $ret = $objQuery->insert("dtb_class", $sqlval);
160
161        return $ret;
162    }
163
164    /* DBへの更新 */
165    function lfUpdateClass($arrData) {
166        $objQuery =& SC_Query::getSingletonInstance();
167        // UPDATEする値を作成する。
168        $sqlval['name'] = $arrData['name'];
169        $sqlval['update_date'] = "Now()";
170        $where = "class_id = ?";
171        // UPDATEの実行
172        $ret = $objQuery->update("dtb_class", $sqlval, $where, array($arrData['class_id']));
173        return $ret;
174    }
175
176    /* 取得文字列の変換 */
177    function lfConvertParam($array) {
178        // 文字変換
179        $arrConvList['name'] = "KVa";
180
181        foreach ($arrConvList as $key => $val) {
182            // POSTされてきた値のみ変換する。
183            if(isset($array[$key])) {
184                $array[$key] = mb_convert_kana($array[$key] ,$val);
185            }
186        }
187        return $array;
188    }
189
190    /* 入力エラーチェック */
191    function lfErrorCheck() {
192        $objErr = new SC_CheckError();
193        $objErr->doFunc(array("規格名", "name", STEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
194
195        if(!isset($objErr->arrErr['name'])) {
196            $objQuery =& SC_Query::getSingletonInstance();
197            $arrRet = $objQuery->select("class_id, name", "dtb_class", "del_flg = 0 AND name = ?", array($_POST['name']));
198            // 編集中のレコード以外に同じ名称が存在する場合
199            if ($arrRet[0]['class_id'] != $_POST['class_id'] && $arrRet[0]['name'] == $_POST['name']) {
200                $objErr->arrErr['name'] = "※ 既に同じ内容の登録が存在します。<br>";
201            }
202        }
203        return $objErr->arrErr;
204    }
205}
206?>
Note: See TracBrowser for help on using the repository browser.