source: branches/version-2_12_3/data/class/helper/SC_Helper_Address.php @ 22497

Revision 22497, 4.6 KB checked in by h_yoshimoto, 11 years ago (diff)

#1958 関数名を修正

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/**
25 * 会員の登録配送先を管理するヘルパークラス.
26 *
27 * @package Helper
28 * @author pineray
29 * @version $Id:$
30 */
31class SC_Helper_Address
32{
33    /**
34     * お届け先を登録
35     *
36     * @param array $sqlval
37     * @return array()
38     */
39    function registAddress($sqlval) {
40        $objQuery =& SC_Query_Ex::getSingletonInstance();
41        $customer_id = $sqlval['customer_id'];
42        $other_deliv_id = $sqlval['other_deliv_id'];
43
44        // 顧客IDのチェック
45        if (is_null($customer_id) || !is_numeric($customer_id) || !preg_match("/^\d+$/", $customer_id)) {
46            SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '顧客IDを正しく指定して下さい。');
47        }
48        // 追加
49        if (strlen($other_deliv_id == 0)) {
50            // 別のお届け先登録数の取得
51            $deliv_count = $objQuery->count('dtb_other_deliv', 'customer_id = ?', array($customer_id));
52            // 別のお届け先最大登録数に達している場合、エラー
53            if ($deliv_count >= DELIV_ADDR_MAX) {
54                SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '別のお届け先最大登録数に達しています。');
55            }
56
57            // 実行
58            $sqlval['other_deliv_id'] = $objQuery->nextVal('dtb_other_deliv_other_deliv_id');
59            $objQuery->insert('dtb_other_deliv', $sqlval);
60
61        // 変更
62        } else {
63            $deliv_count = $objQuery->count('dtb_other_deliv','other_deliv_id = ?' ,array($other_deliv_id));
64            if ($deliv_count != 1) {
65                SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '一致する別のお届け先がありません。');
66            }
67
68            // 実行
69            $objQuery->update('dtb_other_deliv', $sqlval, 'other_deliv_id = ?', array($other_deliv_id));
70        }
71    }
72
73    /**
74     * お届け先を取得
75     *
76     * @param integer $other_deliv_id
77     * @return array()
78     */
79    function getAddress($other_deliv_id) {
80        $objQuery =& SC_Query_Ex::getSingletonInstance();
81        $address = $objQuery->select('*', 'dtb_other_deliv', 'other_deliv_id = ?', array($other_deliv_id));
82        return $address ? $address[0] : FALSE;
83    }
84
85    /**
86     * お届け先の一覧を取得
87     *
88     * @param integer $customerId
89     * @param integer $startno
90     * @return array
91     */
92    function getList($customer_id, $startno = '') {
93        $objQuery =& SC_Query_Ex::getSingletonInstance();
94        $objQuery->setOrder('other_deliv_id DESC');
95        //スマートフォン用の処理
96        if ($startno != '') {
97            $objQuery->setLimitOffset(SEARCH_PMAX, $startno);
98        }
99        return $objQuery->select('*', 'dtb_other_deliv', 'customer_id = ?', array($customer_id));
100    }
101
102    /**
103     * お届け先の削除
104     *
105     * @param integer $delivId
106     * @return void
107     */
108    function deleteAddress($other_deliv_id) {
109        $where      = 'other_deliv_id = ?';
110        $objQuery   =& SC_Query_Ex::getSingletonInstance();
111        $objQuery->delete('dtb_other_deliv', $where, array($other_deliv_id));
112    }
113
114    /**
115     * お届け先フォーム初期化
116     *
117     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
118     * @return void
119     */
120    function setFormParam(&$objFormParam) {
121        SC_Helper_Customer_Ex::sfCustomerCommonParam($objFormParam);
122        $objFormParam->addParam('', 'other_deliv_id');
123    }
124
125    /**
126     * お届け先フォームエラーチェック
127     *
128     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
129     * @return void
130     */
131    function errorCheck(&$objFormParam) {
132        $objErr = SC_Helper_Customer_Ex::sfCustomerCommonErrorCheck($objFormParam);
133        return $objErr->arrErr;
134    }
135}
Note: See TracBrowser for help on using the repository browser.