source: branches/version-2_12-dev/data/class/helper/SC_Helper_Address.php @ 22567

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

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

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