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

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