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 | */ |
---|
31 | class 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 | |
---|
85 | return $address ? $address[0] : FALSE; |
---|
86 | } |
---|
87 | |
---|
88 | /** |
---|
89 | * お届け先の一覧を取得 |
---|
90 | * |
---|
91 | * @param integer $customerId |
---|
92 | * @param integer $startno |
---|
93 | * @return array |
---|
94 | */ |
---|
95 | function getList($customer_id, $startno = '') |
---|
96 | { |
---|
97 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
98 | $objQuery->setOrder('other_deliv_id DESC'); |
---|
99 | //スマートフォン用の処理 |
---|
100 | if ($startno != '') { |
---|
101 | $objQuery->setLimitOffset(SEARCH_PMAX, $startno); |
---|
102 | } |
---|
103 | |
---|
104 | return $objQuery->select('*', 'dtb_other_deliv', 'customer_id = ?', array($customer_id)); |
---|
105 | } |
---|
106 | |
---|
107 | /** |
---|
108 | * お届け先の削除 |
---|
109 | * |
---|
110 | * @param integer $delivId |
---|
111 | * @return void |
---|
112 | */ |
---|
113 | function deleteAddress($other_deliv_id) |
---|
114 | { |
---|
115 | $where = 'other_deliv_id = ?'; |
---|
116 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
117 | $objQuery->delete('dtb_other_deliv', $where, array($other_deliv_id)); |
---|
118 | } |
---|
119 | |
---|
120 | /** |
---|
121 | * お届け先フォーム初期化 |
---|
122 | * |
---|
123 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
124 | * @return void |
---|
125 | */ |
---|
126 | function setFormParam(&$objFormParam) |
---|
127 | { |
---|
128 | SC_Helper_Customer_Ex::sfCustomerCommonParam($objFormParam); |
---|
129 | $objFormParam->addParam('', 'other_deliv_id'); |
---|
130 | } |
---|
131 | |
---|
132 | /** |
---|
133 | * お届け先フォームエラーチェック |
---|
134 | * |
---|
135 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
136 | * @return void |
---|
137 | */ |
---|
138 | function errorCheck(&$objFormParam) |
---|
139 | { |
---|
140 | $objErr = SC_Helper_Customer_Ex::sfCustomerCommonErrorCheck($objFormParam); |
---|
141 | |
---|
142 | return $objErr->arrErr; |
---|
143 | } |
---|
144 | } |
---|