source: branches/version-2_13_2/data/class/pages/admin/products/LC_Page_Admin_Products_Maker.php @ 23412

Revision 23412, 6.5 KB checked in by m_uehara, 10 years ago (diff)

#2457 画面再読み込みのタイミングを修正しました。

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