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

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