source: branches/version-2_12-multilang/data/class/helper/SC_Helper_Address.php @ 22102

Revision 22102, 4.5 KB checked in by h_yoshimoto, 9 years ago (diff)

#1890 メッセージを集約(ダミーID)

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2012 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 save($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, t("SC_Helper_Address_001"));
47                       
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, t("SC_Helper_Address_002"));
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, t("SC_Helper_Address_003"));
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 get($other_deliv_id) {
81        $objQuery =& SC_Query_Ex::getSingletonInstance();
82        $address = $objQuery->select('*', 'dtb_other_deliv', 'other_deliv_id = ?', array($other_deliv_id));
83        return $address ? $address[0] : FALSE;
84    }
85
86    /**
87     * お届け先の一覧を取得
88     *
89     * @param integer $customerId
90     * @param integer $startno
91     * @return array
92     */
93    function getList($customer_id, $startno = '') {
94        $objQuery =& SC_Query_Ex::getSingletonInstance();
95        $objQuery->setOrder('other_deliv_id DESC');
96        //スマートフォン用の処理
97        if ($startno != '') {
98            $objQuery->setLimitOffset(SEARCH_PMAX, $startno);
99        }
100        return $objQuery->select('*', 'dtb_other_deliv', 'customer_id = ?', array($customer_id));
101    }
102
103    /**
104     * お届け先の削除
105     *
106     * @param integer $delivId
107     * @return void
108     */
109    function delete($other_deliv_id) {
110        $where      = 'other_deliv_id = ?';
111        $objQuery   =& SC_Query_Ex::getSingletonInstance();
112        $objQuery->delete('dtb_other_deliv', $where, array($other_deliv_id));
113    }
114
115    /**
116     * お届け先フォーム初期化
117     *
118     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
119     * @return void
120     */
121    function setFormParam(&$objFormParam) {
122        SC_Helper_Customer_Ex::sfCustomerCommonParam($objFormParam);
123        $objFormParam->addParam('', 'other_deliv_id');
124    }
125
126    /**
127     * お届け先フォームエラーチェック
128     *
129     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
130     * @return void
131     */
132    function errorCheck(&$objFormParam) {
133        $objErr = SC_Helper_Customer_Ex::sfCustomerCommonErrorCheck($objFormParam);
134        return $objErr->arrErr;
135    }
136}
Note: See TracBrowser for help on using the repository browser.