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

Revision 22857, 11.0 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

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