source: branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_DeliveryInput.php @ 22567

Revision 22567, 8.4 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • 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
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$
33 */
34class LC_Page_Admin_Basis_DeliveryInput extends LC_Page_Admin_Ex
35{
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init()
45    {
46        parent::init();
47        $this->tpl_mainpage = 'basis/delivery_input.tpl';
48        $this->tpl_subno = 'delivery';
49        $this->tpl_mainno = 'basis';
50        $masterData = new SC_DB_MasterData_Ex();
51        $this->arrPref = $masterData->getMasterData('mtb_pref');
52        $this->arrProductType = $masterData->getMasterData('mtb_product_type');
53        $this->arrPayments = SC_Helper_Payment_Ex::getIDValueList();
54        $this->tpl_maintitle = '基本情報管理';
55        $this->tpl_subtitle = '配送方法設定';
56        $this->mode = $this->getMode();
57    }
58
59    /**
60     * Page のプロセス.
61     *
62     * @return void
63     */
64    function process()
65    {
66        $this->action();
67        $this->sendResponse();
68    }
69
70    /**
71     * Page のアクション.
72     *
73     * @return void
74     */
75    function action()
76    {
77        $objFormParam = new SC_FormParam_Ex();
78        $this->lfInitParam($this->mode, $objFormParam);
79        $objFormParam->setParam($_POST);
80
81        // 入力値の変換
82        $objFormParam->convParam();
83        $this->arrErr = $this->lfCheckError($objFormParam);
84
85        switch ($this->mode) {
86            case 'edit':
87                if (count($this->arrErr) == 0) {
88                    $objFormParam->setValue('deliv_id', $this->lfRegistData($objFormParam->getHashArray(), $_SESSION['member_id']));
89                    $this->tpl_onload = "window.alert('配送方法設定が完了しました。');";
90                }
91                break;
92            case 'pre_edit':
93                if (count($this->arrErr) > 0) {
94                    trigger_error('', E_USER_ERROR);
95                }
96                $this->lfGetDelivData($objFormParam);
97                break;
98            default:
99                break;
100        }
101
102        $this->arrForm = $objFormParam->getFormParamList();
103
104    }
105
106    /**
107     * デストラクタ.
108     *
109     * @return void
110     */
111    function destroy()
112    {
113        parent::destroy();
114    }
115
116    /* パラメーター情報の初期化 */
117    function lfInitParam($mode, &$objFormParam)
118    {
119        $objFormParam = new SC_FormParam_Ex();
120
121        switch ($mode) {
122            case 'edit':
123                $objFormParam->addParam('配送業者ID', 'deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
124                $objFormParam->addParam('配送業者名', 'name', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
125                $objFormParam->addParam('名称', 'service_name', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
126                $objFormParam->addParam('説明', 'remark', LLTEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK'));
127                $objFormParam->addParam('伝票No.確認URL', 'confirm_url', URL_LEN, 'n', array('URL_CHECK', 'MAX_LENGTH_CHECK'), 'http://');
128                $objFormParam->addParam('取扱商品種別', 'product_type_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
129                $objFormParam->addParam('取扱支払方法', 'payment_ids', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
130
131                for ($cnt = 1; $cnt <= DELIVTIME_MAX; $cnt++) {
132                    $objFormParam->addParam("お届け時間$cnt", "deliv_time$cnt", STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK'));
133                }
134
135                if (INPUT_DELIV_FEE) {
136                    for ($cnt = 1; $cnt <= DELIVFEE_MAX; $cnt++) {
137                        $objFormParam->addParam("配送料金$cnt", "fee$cnt", PRICE_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
138                    }
139                }
140                break;
141
142            case 'pre_edit':
143                $objFormParam->addParam('配送業者ID', 'deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
144                break;
145
146            default:
147                break;
148        }
149    }
150
151    /**
152     * 配送情報を登録する
153     *
154     * @return $deliv_id
155     */
156    function lfRegistData($arrRet, $member_id)
157    {
158        $objDelivery = new SC_Helper_Delivery_Ex();
159
160        // 入力データを渡す。
161        $sqlval['deliv_id'] = $arrRet['deliv_id'];
162        $sqlval['name'] = $arrRet['name'];
163        $sqlval['service_name'] = $arrRet['service_name'];
164        $sqlval['remark'] = $arrRet['remark'];
165        $sqlval['confirm_url'] = $arrRet['confirm_url'];
166        $sqlval['product_type_id'] = $arrRet['product_type_id'];
167        $sqlval['creator_id'] = $member_id;
168
169        // お届け時間
170        $sqlval['deliv_time'] = array();
171        for ($cnt = 1; $cnt <= DELIVTIME_MAX; $cnt++) {
172            $keyname = "deliv_time$cnt";
173            if ($arrRet[$keyname] != '') {
174                $sqlval['deliv_time'][$cnt] = $arrRet[$keyname];
175            }
176        }
177
178        // 配送料
179        if (INPUT_DELIV_FEE) {
180            $sqlval['deliv_fee'] = array();
181            // 配送料金の設定
182            for ($cnt = 1; $cnt <= DELIVFEE_MAX; $cnt++) {
183                $keyname = "fee$cnt";
184                if ($arrRet[$keyname] != '') {
185                    $fee = array();
186                    $fee['fee_id'] = $cnt;
187                    $fee['fee'] = $arrRet[$keyname];
188                    $fee['pref'] = $cnt;
189                    $sqlval['deliv_fee'][$cnt] = $fee;
190                }
191            }
192        }
193
194        // 支払い方法
195        $sqlval['payment_ids'] = array();
196        foreach ($arrRet['payment_ids'] as $payment_id) {
197            $sqlval['payment_ids'][] = $payment_id;
198        }
199
200        $deliv_id = $objDelivery->save($sqlval);
201
202        return $deliv_id;
203    }
204
205    /* 配送業者情報の取得 */
206    function lfGetDelivData(&$objFormParam)
207    {
208        $objDelivery = new SC_Helper_Delivery_Ex();
209
210        $deliv_id = $objFormParam->getValue('deliv_id');
211
212        // パラメーター情報の初期化
213        $this->lfInitParam('edit', $objFormParam);
214
215        $arrDeliv = $objDelivery->get($deliv_id);
216
217        // お届け時間
218        $deliv_times = array();
219        foreach ($arrDeliv['deliv_time'] as $value) {
220            $deliv_times[]['deliv_time'] = $value;
221        }
222        $objFormParam->setParamList($deliv_times, 'deliv_time');
223        unset($arrDeliv['deliv_time']);
224        // 配送料金
225        $deliv_fee = array();
226        foreach ($arrDeliv['deliv_fee'] as $value) {
227            $deliv_fee[]['fee'] = $value['fee'];
228        }
229        $objFormParam->setParamList($deliv_fee, 'fee');
230        unset($arrDeliv['deliv_fee']);
231        // 支払方法
232        $objFormParam->setValue('payment_ids', $arrDeliv['payment_ids']);
233        unset($arrDeliv['payment_ids']);
234        // 配送業者
235        $objFormParam->setParam($arrDeliv);
236    }
237
238    /* 入力内容のチェック */
239    function lfCheckError(&$objFormParam)
240    {
241        // 入力データを渡す。
242        $arrRet =  $objFormParam->getHashArray();
243        $objErr = new SC_CheckError_Ex($arrRet);
244        $objErr->arrErr = $objFormParam->checkError();
245
246        if (!isset($objErr->arrErr['name'])) {
247            // 既存チェック
248            $objDelivery = new SC_Helper_Delivery_Ex();
249            if ($objDelivery->checkExist($arrRet)) {
250                $objErr->arrErr['service_name'] = '※ 同じ名称の組み合わせは登録できません。<br>';
251            }
252        }
253
254        return $objErr->arrErr;
255    }
256}
Note: See TracBrowser for help on using the repository browser.