source: branches/version-2_13_0/data/class/pages/admin/basis/LC_Page_Admin_Basis_DeliveryInput.php @ 23126

Revision 23126, 8.3 KB checked in by m_uehara, 11 years ago (diff)

#2348 r23116 - r23125 をマージ

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