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

Revision 22735, 6.6 KB checked in by h_yoshimoto, 11 years ago (diff)

#2193 ユニットテストチームのコミットをマージ(from camp/camp-2_13-tests)

  • 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 
[17263]1<?php
2/*
3 * This file is part of EC-CUBE
4 *
[22206]5 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
[17263]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
[20534]25require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
[17263]26
27/**
[19909]28 * メーカー登録 のページクラス.
[17263]29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
[20256]32 * @version $Id$
[17263]33 */
[22567]34class LC_Page_Admin_Products_Maker extends LC_Page_Admin_Ex
35{
[17263]36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
[22567]45    function init()
46    {
[17263]47        parent::init();
48        $this->tpl_mainpage = 'products/maker.tpl';
49        $this->tpl_subno = 'maker';
[20911]50        $this->tpl_maintitle = '商品管理';
[19909]51        $this->tpl_subtitle = 'メーカー登録';
[17263]52        $this->tpl_mainno = 'products';
53    }
54
55    /**
56     * Page のプロセス.
57     *
58     * @return void
59     */
[22567]60    function process()
61    {
[19661]62        $this->action();
63        $this->sendResponse();
64    }
65
66    /**
67     * Page のアクション.
68     *
69     * @return void
70     */
[22567]71    function action()
72    {
[21591]73
[22578]74        $objMaker = new SC_Helper_Maker_Ex();
[20501]75        $objFormParam = new SC_FormParam_Ex();
[17263]76
[20970]77        // パラメーター情報の初期化
[20252]78        $this->lfInitParam($objFormParam);
[20220]79
[20252]80        // POST値をセット
81        $objFormParam->setParam($_POST);
[20540]82
[20252]83        // POST値の入力文字変換
84        $objFormParam->convParam();
[20220]85
[20598]86        //maker_idを変数にセット
87        $maker_id = $objFormParam->getValue('maker_id');
88
[20252]89        // モードによる処理切り替え
[21441]90        switch ($this->getMode()) {
[20220]91
[21526]92            // 編集処理
93            case 'edit':
[22578]94                // エラーチェック
95                $this->arrErr = $this->lfCheckError($objFormParam, $objMaker);
96                if (!SC_Utils_Ex::isBlank($this->arrErr['maker_id'])) {
97                    trigger_error('', E_USER_ERROR);
98                    return;
99                }
[20252]100
[21526]101                if (count($this->arrErr) <= 0) {
[22578]102                    // POST値の引き継ぎ
103                    $arrParam = $objFormParam->getHashArray();
104                    // 登録実行
105                    $res_maker_id = $this->doRegist($maker_id, $arrParam, $objMaker);
106                    if ($res_maker_id !== FALSE) {
107                        // 完了メッセージ
108                        $maker_id = $res_maker_id;
109                        $this->tpl_onload = "alert('登録が完了しました。');";
[21526]110                    }
[17263]111                }
[22578]112                // POSTデータを引き継ぐ
113                $this->tpl_maker_id = $maker_id;
[21526]114                break;
115
116            // 編集前処理
117            case 'pre_edit':
[22735]118                $maker = $objMaker->getMaker($maker_id);
[22578]119                $objFormParam->setParam($maker);
120
121                // POSTデータを引き継ぐ
122                $this->tpl_maker_id = $maker_id;
[21526]123                break;
[20220]124
[21526]125            // メーカー順変更
126            case 'up':
[22578]127                $objMaker->rankUp($maker_id);
128
129                // リロード
130                SC_Response_Ex::reload();
131                break;
132
[21526]133            case 'down':
[22578]134                $objMaker->rankDown($maker_id);
[21591]135
[21526]136                // リロード
137                SC_Response_Ex::reload();
138                break;
[20220]139
[21526]140            // 削除
141            case 'delete':
[22578]142                $objMaker->delete($maker_id);
[21591]143
[21526]144                // リロード
145                SC_Response_Ex::reload();
146                break;
[20220]147
[21526]148            default:
149                break;
[17263]150        }
151
[22578]152        $this->arrForm = $objFormParam->getFormParamList();
153
[20220]154        // メーカー情報読み込み
[22578]155        $this->arrMaker = $objMaker->getList();
[17263]156    }
157
158    /**
159     * デストラクタ.
160     *
161     * @return void
162     */
[22567]163    function destroy()
164    {
[17263]165        parent::destroy();
166    }
167
[20252]168    /**
[20970]169     * パラメーター情報の初期化を行う.
[20252]170     *
171     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
172     * @return void
173     */
[22567]174    function lfInitParam(&$objFormParam)
175    {
[21514]176        $objFormParam->addParam('メーカーID', 'maker_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
177        $objFormParam->addParam('メーカー名', 'name', SMTEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
[20252]178    }
[20220]179
180    /**
[22578]181     * 登録処理を実行.
182     *
183     * @param integer $maker_id
184     * @param array $sqlval
185     * @param object $objMaker
186     * @return multiple
[20220]187     */
[22578]188    function doRegist($maker_id, $sqlval, SC_Helper_Maker_Ex $objMaker)
[22567]189    {
[22578]190        $sqlval['maker_id'] = $maker_id;
[17263]191        $sqlval['creator_id'] = $_SESSION['member_id'];
[22735]192        return $objMaker->saveMaker($sqlval);
[17263]193    }
194
[20220]195    /**
[20252]196     * 入力エラーチェック.
[20220]197     *
198     * @return array $objErr->arrErr エラー内容
199     */
[22578]200    function lfCheckError(&$objFormParam, SC_Helper_Maker_Ex &$objMaker)
[22567]201    {
[20220]202
[21697]203        $arrErr = $objFormParam->checkError();
[22578]204        $arrForm = $objFormParam->getHashArray();
[21697]205
[20220]206        // maker_id の正当性チェック
[21441]207        if (!empty($arrForm['maker_id'])) {
[21743]208            if (!SC_Utils_Ex::sfIsInt($arrForm['maker_id'])
[21527]209                || SC_Utils_Ex::sfIsZeroFilling($arrForm['maker_id'])
[22735]210                || !$objMaker->getMaker($arrForm['maker_id'])
[21527]211            ) {
212                // maker_idが指定されていて、且つその値が不正と思われる場合はエラー
[21697]213                $arrErr['maker_id'] = '※ メーカーIDが不正です<br />';
[20220]214            }
215        }
[21697]216        if (!isset($arrErr['name'])) {
[22578]217            $arrMaker = $objMaker->getByName($arrForm['name']);
[20220]218
[17263]219            // 編集中のレコード以外に同じ名称が存在する場合
[22578]220            if (
221                    !SC_Utils_Ex::isBlank($arrMaker)
222                    && $arrMaker['maker_id'] != $arrForm['maker_id']
223                    && $arrMaker['name'] == $arrForm['name']
224                ) {
[21697]225                $arrErr['name'] = '※ 既に同じ内容の登録が存在します。<br />';
[17263]226            }
227        }
[20220]228
[21697]229        return $arrErr;
[17263]230    }
231}
Note: See TracBrowser for help on using the repository browser.