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