source: branches/comu-ver2/data/class/pages/admin/products/LC_Page_Admin_Products_Class.php @ 17509

Revision 17509, 6.4 KB checked in by Seasoft, 16 years ago (diff)

パラメータ設定により、在庫無し商品を一覧に非表示しないように設定可能とする。
※ カテゴリ別おすすめ商品( SC_Utils::sfGetBestProducts() )はテスト方法が分からず、未テスト。
※ dtb_maker_count の更新は未対応。

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