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

Revision 20970, 10.7 KB checked in by Seasoft, 13 years ago (diff)

#1288 (「-er」カタカナ表記の統一)

  • 現状で混在が発生しているもののみ改修。
  • 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-2011 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_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.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_Ex {
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_subno = 'class';
48        $this->tpl_maintitle = '商品管理';
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        $objFormParam = new SC_FormParam_Ex();
70
71        $this->lfInitParam($objFormParam);
72        $objFormParam->setParam($_REQUEST);
73        $objFormParam->convParam();
74        $class_id = $objFormParam->getValue('class_id');
75        $classcategory_id = $objFormParam->getValue('classcategory_id');
76
77        switch($this->getMode()) {
78        // 登録ボタン押下
79        // 新規作成 or 編集
80        case 'edit':
81            // パラメーター値の取得
82            $this->arrForm = $objFormParam->getHashArray();
83            // 入力パラメーターチェック
84            $this->arrErr = $this->lfCheckError($objFormParam);
85            if (SC_Utils_Ex::isBlank($this->arrErr)) {
86                //新規規格追加かどうかを判定する
87                $is_insert = $this->lfCheckInsert($classcategory_id);
88                if($is_insert) {
89                    //新規追加
90                    $this->lfInsertClass($this->arrForm);
91                } else {
92                    //更新
93                    $this->lfUpdateClass($this->arrForm);
94                }
95                // 再表示
96                SC_Response_Ex::reload();
97            }
98            break;
99            // 削除
100        case 'delete':
101            // ランク付きレコードの削除
102            $this->lfDeleteClassCat($class_id, $classcategory_id);
103            SC_Response_Ex::reload();
104            break;
105            // 編集前処理
106        case 'pre_edit':
107            // 規格名を取得する。
108            $classcategory_name = $this->lfGetClassCatName($classcategory_id);
109            // 入力項目にカテゴリ名を入力する。
110            $this->arrForm['name'] = $classcategory_name;
111            break;
112        case 'down':
113            //並び順を下げる
114            $this->lfDownRank($class_id, $classcategory_id);
115            SC_Response_Ex::reload();
116            break;
117        case 'up':
118            //並び順を上げる
119            $this->lfUpRank($class_id, $classcategory_id);
120            SC_Response_Ex::reload();
121            break;
122        default:
123            break;
124        }
125        //規格分類名の取得
126        $this->tpl_class_name = $this->lfGetClassName($class_id);
127        //規格分類情報の取得
128        $this->arrClassCat = $this->lfGetClassCat($class_id);
129        // POSTデータを引き継ぐ
130        $this->tpl_classcategory_id = $classcategory_id;
131    }
132
133    /**
134     * デストラクタ.
135     *
136     * @return void
137     */
138    function destroy() {
139        parent::destroy();
140    }
141
142    /**
143     * パラメーターの初期化を行う.
144     *
145     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
146     * @return void
147     */
148    function lfInitParam(&$objFormParam) {
149        $objFormParam->addParam("規格ID", "class_id", INT_LEN, 'n', array("NUM_CHECK"));
150        $objFormParam->addParam("規格分類名", 'name', STEXT_LEN, 'KVa', array("EXIST_CHECK" ,"SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
151        $objFormParam->addParam("規格分類ID", "classcategory_id", INT_LEN, 'n', array("NUM_CHECK"));
152    }
153
154   /**
155     * 有効な規格分類情報の取得
156     *
157     * @param integer $class_id 規格ID
158     * @return array 規格分類情報
159     */
160    function lfGetClassCat($class_id) {
161        $objQuery =& SC_Query_Ex::getSingletonInstance();
162
163        $where = "del_flg <> 1 AND class_id = ?";
164        $objQuery->setOrder("rank DESC"); // XXX 降順
165        $arrClassCat = $objQuery->select("name, classcategory_id", "dtb_classcategory", $where, array($class_id));
166        return $arrClassCat;
167    }
168
169   /**
170     * 規格名の取得
171     *
172     * @param integer $class_id 規格ID
173     * @return string 規格名
174     */
175    function lfGetClassName($class_id) {
176        $objQuery =& SC_Query_Ex::getSingletonInstance();
177
178        $where = "class_id = ?";
179        $name = $objQuery->get('name', "dtb_class", $where, array($class_id));
180        return $name;
181    }
182   /**
183     * 規格分類名を取得する
184     *
185     * @param integer $classcategory_id 規格分類ID
186     * @return string 規格分類名
187     */
188    function lfGetClassCatName($classcategory_id) {
189        $objQuery =& SC_Query_Ex::getSingletonInstance();
190        $where = "classcategory_id = ?";
191        $name = $objQuery->get('name', "dtb_classcategory", $where, array($classcategory_id));
192        return $name;
193    }
194
195   /**
196     * 規格分類情報を新規登録
197     *
198     * @param array $arrForm フォームパラメータークラス
199     * @return integer 更新件数
200     */
201    function lfInsertClass($arrForm) {
202        $objQuery =& SC_Query_Ex::getSingletonInstance();
203        $objQuery->begin();
204        // 親規格IDの存在チェック
205        $where = "del_flg <> 1 AND class_id = ?";
206        $class_id = $objQuery->get("class_id", "dtb_class", $where, array($arrForm['class_id']));
207        if(!SC_Utils_Ex::isBlank($class_id)) {
208            // INSERTする値を作成する。
209            $sqlval['name'] = $arrForm['name'];
210            $sqlval['class_id'] = $arrForm['class_id'];
211            $sqlval['creator_id'] = $_SESSION['member_id'];
212            $sqlval['rank'] = $objQuery->max('rank', "dtb_classcategory", $where, array($arrForm['class_id'])) + 1;
213            $sqlval['create_date'] = "now()";
214            $sqlval['update_date'] = "now()";
215            // INSERTの実行
216            $sqlval['classcategory_id'] = $objQuery->nextVal('dtb_classcategory_classcategory_id');
217            $ret = $objQuery->insert("dtb_classcategory", $sqlval);
218        }
219        $objQuery->commit();
220        return $ret;
221    }
222
223   /**
224     * 規格分類情報を更新
225     *
226     * @param array $arrForm フォームパラメータークラス
227     * @return integer 更新件数
228     */
229    function lfUpdateClass($arrForm) {
230        $objQuery = new SC_Query_Ex();
231        // UPDATEする値を作成する。
232        $sqlval['name'] = $arrForm['name'];
233        $sqlval['update_date'] = "Now()";
234        $where = "classcategory_id = ?";
235        // UPDATEの実行
236        $ret = $objQuery->update("dtb_classcategory", $sqlval, $where, array($arrForm['classcategory_id']));
237        return $ret;
238    }
239
240   /**
241     * エラーチェック
242     *
243     * @param array $objFormParam フォームパラメータークラス
244     * @return array エラー配列
245     */
246    function lfCheckError(&$objFormParam) {
247        $objQuery =& SC_Query_Ex::getSingletonInstance();
248        $arrForm = $objFormParam->getHashArray();
249        // パラメーターの基本チェック
250        $arrErr = $objFormParam->checkError();
251        if (!SC_Utils_Ex::isBlank($arrErr)) {
252            return $arrErr;
253        }else{
254            $arrForm = $objFormParam->getHashArray();
255        }
256
257        $where = "class_id = ? AND name = ?";
258        $arrRet = $objQuery->select("classcategory_id, name", "dtb_classcategory", $where, array($arrForm['class_id'], $arrForm['name']));
259        // 編集中のレコード以外に同じ名称が存在する場合
260        if ($arrRet[0]['classcategory_id'] != $arrForm['classcategory_id'] && $arrRet[0]['name'] == $arrForm['name']) {
261            $arrErr['name'] = "※ 既に同じ内容の登録が存在します。<br>";
262        }
263        return $arrErr;
264    }
265
266    /**
267     * 新規規格分類追加かどうかを判定する.
268     *
269     * @param integer $classcategory_id 規格分類ID
270     * @return boolean 新規商品追加の場合 true
271     */
272    function lfCheckInsert($classcategory_id) {
273        //classcategory_id のあるなしで新規規格分類化かどうかを判定
274        if (empty($classcategory_id)){
275            return true;
276        }else{
277            return false;
278        }
279    }
280
281    /**
282     * 規格分類情報を削除する
283     *
284     * @param integer $class_id 規格ID
285     * @param integer $classcategory_id 規格分類ID
286     * @return void
287     */
288    function lfDeleteClassCat($class_id, $classcategory_id) {
289        $objDb = new SC_Helper_DB_Ex();
290        $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($class_id);
291        $objDb->sfDeleteRankRecord("dtb_classcategory", "classcategory_id", $classcategory_id, $where, true);
292    }
293    /**
294     * 並び順を上げる
295     *
296     * @param integer $class_id 規格ID
297     * @param integer $classcategory_id 規格分類ID
298     * @return void
299     */
300    function lfUpRank($class_id, $classcategory_id) {
301        $objDb = new SC_Helper_DB_Ex();
302        $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($class_id);
303        $objDb->sfRankUp("dtb_classcategory", "classcategory_id", $classcategory_id, $where);
304    }
305    /**
306     * 並び順を下げる
307     *
308     * @param integer $class_id 規格ID
309     * @param integer $classcategory_id 規格分類ID
310     * @return void
311     */
312    function lfDownRank($class_id, $classcategory_id) {
313        $objDb = new SC_Helper_DB_Ex();
314        $where = "class_id = " . SC_Utils_Ex::sfQuoteSmart($class_id);
315        $objDb->sfRankDown("dtb_classcategory", "classcategory_id", $classcategory_id, $where);
316    }
317}
318?>
Note: See TracBrowser for help on using the repository browser.