1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 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 | // {{{ requires |
---|
25 | require_once(CLASS_REALDIR . "pages/LC_Page.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * MyPage のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_MyPage_Favorite extends LC_Page { |
---|
35 | |
---|
36 | // {{{ properties |
---|
37 | |
---|
38 | /** ページナンバー */ |
---|
39 | var $tpl_pageno; |
---|
40 | |
---|
41 | // }}} |
---|
42 | // {{{ functions |
---|
43 | |
---|
44 | /** |
---|
45 | * Page を初期化する. |
---|
46 | * |
---|
47 | * @return void |
---|
48 | */ |
---|
49 | function init() { |
---|
50 | parent::init(); |
---|
51 | $this->tpl_title = 'MYページ'; |
---|
52 | $this->tpl_subtitle = 'お気に入り一覧'; |
---|
53 | $this->tpl_navi = TEMPLATE_REALDIR . 'mypage/navi.tpl'; |
---|
54 | $this->tpl_mainno = 'mypage'; |
---|
55 | $this->tpl_mypageno = 'favorite'; |
---|
56 | } |
---|
57 | |
---|
58 | /** |
---|
59 | * Page のプロセス. |
---|
60 | * |
---|
61 | * @return void |
---|
62 | */ |
---|
63 | function process() { |
---|
64 | parent::process(); |
---|
65 | $this->action(); |
---|
66 | $this->sendResponse(); |
---|
67 | } |
---|
68 | |
---|
69 | /** |
---|
70 | * Page のAction. |
---|
71 | * |
---|
72 | * @return void |
---|
73 | */ |
---|
74 | function action() { |
---|
75 | |
---|
76 | $objQuery = new SC_Query(); |
---|
77 | $objCustomer = new SC_Customer(); |
---|
78 | |
---|
79 | // 退会判定用情報の取得 |
---|
80 | $this->tpl_login = $objCustomer->isLoginSuccess(true); |
---|
81 | |
---|
82 | // ログインチェック |
---|
83 | if(!$objCustomer->isLoginSuccess(true)) { |
---|
84 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
---|
85 | }else { |
---|
86 | // マイページトップ顧客情報表示用 |
---|
87 | $this->CustomerName1 = $objCustomer->getvalue('name01'); |
---|
88 | $this->CustomerName2 = $objCustomer->getvalue('name02'); |
---|
89 | $this->CustomerPoint = $objCustomer->getvalue('point'); |
---|
90 | } |
---|
91 | |
---|
92 | switch ($this->getMode()) { |
---|
93 | case 'delete_favorite': |
---|
94 | // お気に入り削除 |
---|
95 | $customer_id = $objCustomer->getValue('customer_id'); |
---|
96 | $this->lfDeleteFavoriteProduct($customer_id, $_POST['product_id']); |
---|
97 | break; |
---|
98 | default: |
---|
99 | break; |
---|
100 | } |
---|
101 | |
---|
102 | // ページ送り用 |
---|
103 | if (isset($_POST['pageno'])) { |
---|
104 | $this->tpl_pageno = htmlspecialchars($_POST['pageno'], ENT_QUOTES, CHAR_CODE); |
---|
105 | } |
---|
106 | |
---|
107 | // FIXME SC_Product クラスを使用した実装 |
---|
108 | $col = "alldtl.*"; |
---|
109 | $from = "dtb_customer_favorite_products AS dcfp LEFT JOIN vw_products_allclass_detail AS alldtl USING(product_id)"; |
---|
110 | |
---|
111 | $where = "dcfp.customer_id = ? AND alldtl.del_flg = 0 AND alldtl.status = 1"; |
---|
112 | // 在庫無し商品の非表示 |
---|
113 | if (NOSTOCK_HIDDEN === true) { |
---|
114 | $where .= ' AND (alldtl.stock_max >= 1 OR alldtl.stock_unlimited_max = 1)'; |
---|
115 | } |
---|
116 | $order = "create_date DESC"; |
---|
117 | |
---|
118 | $arrval = array($objCustomer->getvalue('customer_id')); |
---|
119 | |
---|
120 | // お気に入りの数を取得 |
---|
121 | $linemax = $objQuery->count($from, $where, $arrval); |
---|
122 | $this->tpl_linemax = $linemax; |
---|
123 | |
---|
124 | // ページ送りの取得 |
---|
125 | $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, SEARCH_PMAX, "fnNaviPage", NAVI_PMAX); |
---|
126 | $this->tpl_strnavi = $objNavi->strnavi; // 表示文字列 |
---|
127 | $startno = $objNavi->start_row; |
---|
128 | |
---|
129 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
130 | $objQuery->setLimitOffset(SEARCH_PMAX, $startno); |
---|
131 | // 表示順序 |
---|
132 | $objQuery->setOrder($order); |
---|
133 | |
---|
134 | // お気に入りの取得 |
---|
135 | $this->arrFavorite = $objQuery->select($col, $from, $where, $arrval); |
---|
136 | |
---|
137 | // パラメータ管理クラス |
---|
138 | $this->objFormParam = new SC_FormParam(); |
---|
139 | // POST値の取得 |
---|
140 | $this->objFormParam->setParam($_POST); |
---|
141 | |
---|
142 | // 入力情報を渡す |
---|
143 | $this->arrForm = $this->objFormParam->getFormParamList(); |
---|
144 | } |
---|
145 | |
---|
146 | /** |
---|
147 | * デストラクタ. |
---|
148 | * |
---|
149 | * @return void |
---|
150 | */ |
---|
151 | function destroy() { |
---|
152 | parent::destroy(); |
---|
153 | } |
---|
154 | |
---|
155 | //エラーチェック |
---|
156 | |
---|
157 | function lfErrorCheck() { |
---|
158 | $objErr = new SC_CheckError(); |
---|
159 | $objErr->doFunc(array("メールアドレス", "login_email", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","EMAIL_CHECK","MAX_LENGTH_CHECK")); |
---|
160 | $objErr->dofunc(array("パスワード", "login_password", PASSWORD_LEN2), array("EXIST_CHECK","ALNUM_CHECK")); |
---|
161 | return $objErr->arrErr; |
---|
162 | } |
---|
163 | |
---|
164 | // お気に入り商品削除 |
---|
165 | function lfDeleteFavoriteProduct($customer_id, $product_id) { |
---|
166 | $objQuery = new SC_Query(); |
---|
167 | $count = $objQuery->count("dtb_customer_favorite_products", "customer_id = ? AND product_id = ?", array($customer_id, $product_id)); |
---|
168 | |
---|
169 | if ($count > 0) { |
---|
170 | $objQuery->begin(); |
---|
171 | $objQuery->delete('dtb_customer_favorite_products', "customer_id = ? AND product_id = ?", array($customer_id, $product_id)); |
---|
172 | $objQuery->commit(); |
---|
173 | } |
---|
174 | } |
---|
175 | } |
---|
176 | ?> |
---|