1 | <style type="text/css"> |
---|
2 | div#sendPoint{border: none;background: #FFF6CF;text-align: center;overflow: auto;} |
---|
3 | div#sendPoint div#innner{border: 3px solid red;margin:8px;} |
---|
4 | div#sendPoint div#innner h2{margin:12px;font-size:18px;color:red;text-shadow: -1px -1px 0px #FFF;font-weight: bold;} |
---|
5 | div#sendPoint div#innner p{margin:2px 4px;font-size:90%;} |
---|
6 | div#sendPoint div#innner div#sendForm{border:1px solid #CCC;margin:12px;background:#FFF;padding:8px 4px;} |
---|
7 | div#sendPoint div#innner div#sendForm form input{font-size: 120%;width: 60px;margin-bottom:4px;} |
---|
8 | div#sendPoint div#innner div#sendForm form input#sendpointValue{text-align: right; padding:2px 4px;margin-right: 6px;} |
---|
9 | div#sendPoint div#innner span.smalltext{font-size:90%;} |
---|
10 | div#sendPoint div#innner span.red{color:red;font-weight: bold;} |
---|
11 | </style> |
---|
12 | <?php |
---|
13 | /* |
---|
14 | * This file is part of EC-CUBE |
---|
15 | * |
---|
16 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
17 | * |
---|
18 | * http://www.lockon.co.jp/ |
---|
19 | * |
---|
20 | * This program is free software; you can redistribute it and/or |
---|
21 | * modify it under the terms of the GNU General Public License |
---|
22 | * as published by the Free Software Foundation; either version 2 |
---|
23 | * of the License, or (at your option) any later version. |
---|
24 | * |
---|
25 | * This program is distributed in the hope that it will be useful, |
---|
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
28 | * GNU General Public License for more details. |
---|
29 | * |
---|
30 | * You should have received a copy of the GNU General Public License |
---|
31 | * along with this program; if not, write to the Free Software |
---|
32 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
33 | * |
---|
34 | * 2011-03-12 Tao Sasaki (tao@xross-cube.com) |
---|
35 | * |
---|
36 | */ |
---|
37 | |
---|
38 | // {{{ requires |
---|
39 | if( !defined("CLASS_PATH") ){ |
---|
40 | require_once("../../require.php"); |
---|
41 | } |
---|
42 | require_once(CLASS_PATH . "pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php"); |
---|
43 | |
---|
44 | // }}} |
---|
45 | // {{{ generate page |
---|
46 | class LC_Page_FrontParts_Bloc_SendPoint extends LC_Page_FrontParts_Bloc { |
---|
47 | |
---|
48 | // }}} |
---|
49 | // {{{ functions |
---|
50 | |
---|
51 | /** |
---|
52 | * Page を初期化する. |
---|
53 | * |
---|
54 | * @return void |
---|
55 | */ |
---|
56 | function init() { |
---|
57 | parent::init(); |
---|
58 | $this->tpl_login = false; |
---|
59 | $this->tpl_disable_logout = false; |
---|
60 | $this->tpl_error = ""; |
---|
61 | $this->complete = false; |
---|
62 | } |
---|
63 | |
---|
64 | /** |
---|
65 | * Page のプロセス. |
---|
66 | * |
---|
67 | * @return void |
---|
68 | */ |
---|
69 | function process() { |
---|
70 | if(!file_exists(DATA_PATH.'downloads/donation.csv')){ |
---|
71 | $objQuery = new SC_Query; |
---|
72 | $ret = $objQuery->getOne("SELECT php_path FROM dtb_bloc WHERE php_path = 'frontparts/bloc/send_point.php'"); |
---|
73 | if(!$ret){ |
---|
74 | $objQuery->query("INSERT INTO dtb_bloc (bloc_name,tpl_path,filename,create_date,update_date,php_path,del_flg) |
---|
75 | VALUES('東北地方太平洋沖地震ポイント寄付','','send_point',NOW(),NOW(),'frontparts/bloc/send_point.php',0)"); |
---|
76 | if(!file_exists(DATA_PATH.'downloads/donation_summary.csv') AND $fp = fopen(DATA_PATH.'downloads/donation_summary.csv','a+')){ |
---|
77 | fwrite($fp,'0,0,0'); |
---|
78 | fclose($fp); |
---|
79 | } |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | |
---|
84 | |
---|
85 | $objCustomer = new SC_Customer(); |
---|
86 | $objCustomer->updateSession(); |
---|
87 | // クッキー管理クラス |
---|
88 | $objCookie = new SC_Cookie(COOKIE_EXPIRE); |
---|
89 | |
---|
90 | $limit = 0; |
---|
91 | if($fp2 = fopen(DATA_PATH.'downloads/donation_summary.csv','a+')){ |
---|
92 | flock($fp2,LOCK_EX); |
---|
93 | $summary = file_get_contents(DATA_PATH.'downloads/donation_summary.csv'); |
---|
94 | $summary = explode(",",$summary); |
---|
95 | $total = intval($summary[1]); |
---|
96 | $limit = intval($summary[2]); |
---|
97 | if($limit > 0 and $total == $limit){ |
---|
98 | $this->complete = true; |
---|
99 | } |
---|
100 | } |
---|
101 | |
---|
102 | // ログイン判定 |
---|
103 | if($objCustomer->isLoginSuccess() and $this->complete == false ) { |
---|
104 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
105 | if (strlen($this->tpl_user_point) == 0) $this->tpl_user_point = 0; |
---|
106 | if(isset($_POST["sendpoint"]) and $this->isValidToken()){ |
---|
107 | //ポイント寄付処理 |
---|
108 | $point = intval(mb_convert_kana($_POST["sendpoint"],"n")); |
---|
109 | if(!$point or $this->tpl_user_point < $point){ |
---|
110 | $this->tpl_error = "1以上のポイントを保有ポイント内で半角数字で入力してください。"; |
---|
111 | }else{ |
---|
112 | if(isset($summary) and $this->complete == false){ |
---|
113 | if(($limit - $total) < $point){ |
---|
114 | $point = $limit - $total; |
---|
115 | $this->complete = true; |
---|
116 | } |
---|
117 | } |
---|
118 | if($fp = fopen(DATA_PATH.'downloads/donation.csv','a+') and $point > 0){ |
---|
119 | $objQuery = new SC_Query; |
---|
120 | $sqlval = array('point' => ($this->tpl_user_point - $point)); |
---|
121 | $where = 'customer_id = ? AND del_flg = 0 AND status = 2'; |
---|
122 | $rs = $objQuery->update('dtb_customer', $sqlval, $where, array($objCustomer->getValue('customer_id'))); |
---|
123 | if($rs){ |
---|
124 | flock($fp,LOCK_EX); |
---|
125 | fwrite($fp,date("Y-m-d G:i:s").",".$objCustomer->getValue('customer_id').",".$point."\n"); |
---|
126 | $objCustomer->setValue("point", ($this->tpl_user_point - $point)); |
---|
127 | $this->tpl_error = "ご協力ありがとうございます。".$point."ptを承りました。<br />寄付頂いたポイント分を、東北地方太平洋沖地震の復旧活動へ寄付いたします。"; |
---|
128 | //サマリー更新 |
---|
129 | if(isset($summary)){ |
---|
130 | $num = intval($summary[0]) + 1; |
---|
131 | $total = $total+$point; |
---|
132 | ftruncate($fp2,0); |
---|
133 | fseek($fp2,0); |
---|
134 | fwrite($fp2,$num.','.$total.','.$limit); |
---|
135 | }else{ |
---|
136 | $this->tpl_error = "正常に寄付ポイントを集計出来ませんでした。サイト管理者へご連絡願います。"; |
---|
137 | } |
---|
138 | }else{ |
---|
139 | $this->tpl_error = "正常に寄付ポイントを記録出来ませんでした。もう一度お願いします。"; |
---|
140 | } |
---|
141 | fclose($fp); |
---|
142 | } else { |
---|
143 | $this->tpl_error = "システムエラー"; |
---|
144 | } |
---|
145 | } |
---|
146 | } |
---|
147 | $this->tpl_login = true; |
---|
148 | $objCustomer->updateSession(); |
---|
149 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
150 | if (strlen($this->tpl_user_point) == 0) $this->tpl_user_point = 0; |
---|
151 | $this->tpl_name1 = $objCustomer->getValue('name01'); |
---|
152 | $this->tpl_name2 = $objCustomer->getValue('name02'); |
---|
153 | } |
---|
154 | |
---|
155 | if($fp2){ |
---|
156 | fclose($fp2); |
---|
157 | } |
---|
158 | |
---|
159 | $this->transactionid = $this->getToken(); |
---|
160 | } |
---|
161 | |
---|
162 | /** |
---|
163 | * デストラクタ. |
---|
164 | * |
---|
165 | * @return void |
---|
166 | */ |
---|
167 | function destroy() { |
---|
168 | parent::destroy(); |
---|
169 | } |
---|
170 | } |
---|
171 | |
---|
172 | $objPage = new LC_Page_FrontParts_Bloc_SendPoint(); |
---|
173 | register_shutdown_function(array($objPage, "destroy")); |
---|
174 | $objPage->init(); |
---|
175 | $objPage->process(); |
---|
176 | |
---|
177 | ?> |
---|
178 | <a name="sendPoint"></a> |
---|
179 | <div id="sendPoint"> |
---|
180 | <div id="innner"> |
---|
181 | <?php if($objPage->complete === true){ ?> |
---|
182 | <h2>ご協力ありがとうございました</h2> |
---|
183 | <p>ポイントの東北地方太平洋沖地震の復旧活動への寄付ですが、皆様のご協力により目標ポイント数を達成する事が出来ました。</p> |
---|
184 | <p>寄付して頂いたポイント分の金額を、当店がお客様に代わり東北地方太平洋沖地震の復旧活動へ寄付させて頂きます。<br />多大なご協力ありがとうございました。<br /></p> |
---|
185 | <p>現金で赤十字に募金される場合は<a href="http://www.jrc.or.jp/contribution/l3/Vcms3_00002069.html" target="_blank" title="赤十字募金ページへ">コチラ</a>をご参照ください。</p> |
---|
186 | <?php }else{ ?> |
---|
187 | <h2>東北地方太平洋沖地震へのポイント寄付のお願い</h2> |
---|
188 | <?php if($objPage->tpl_login){?> |
---|
189 | <p>現在お客様が保有している当店のポイントを東北地方太平洋沖地震の復旧活動へ寄付出来ます。</p> |
---|
190 | <p>下記フォームに寄付するポイント数を入力の上、「寄付」ボタンをクリックしてください。</p> |
---|
191 | <p>運営担当者が寄付されたポイントを集計し、東北地方太平洋沖地震の復旧活動に寄付させて頂きます。</p> |
---|
192 | <div id="sendForm"> |
---|
193 | <p><span class="red"><?php echo $objPage->tpl_error; ?></span></p> |
---|
194 | <form method="post" action="#sendPoint" name="sendPoint"> |
---|
195 | <input type="hidden" name="transactionid" value="<?php echo $objPage->transactionid ?>" /> |
---|
196 | <p><span class="smalltext">現在お客様が保有しているポイント:<?php echo $objPage->tpl_user_point ?>pt</span></p> |
---|
197 | <p> |
---|
198 | <input type="text" maxlength="10" name="sendpoint" id="sendpointValue" value="" size="5" />ptを寄付<br /> |
---|
199 | <input type="submit" value="寄付" /> |
---|
200 | </p> |
---|
201 | </form> |
---|
202 | </div> |
---|
203 | <p>直接現金で赤十字に募金される場合は<a href="http://www.jrc.or.jp/contribution/l3/Vcms3_00002069.html" target="_blank" title="赤十字募金ページへ">コチラ</a>をご参照ください。</p> |
---|
204 | <?php }else{ ?> |
---|
205 | <p>会員のお客様は、現在お客様が保有している当店のポイントを東北地方太平洋沖地震の復旧活動へ寄付できます。ログインしてご協力をお願いします。</p> |
---|
206 | <p>- <a href="<?php echo URL_MYPAGE_TOP ?>">ログイン</a> -</p> |
---|
207 | <p>運営担当者が寄付されたポイントを集計し、東北地方太平洋沖地震の復旧活動へ寄付させて頂きます。</p> |
---|
208 | <p>直接現金で赤十字に募金される場合は<a href="http://www.jrc.or.jp/contribution/l3/Vcms3_00002069.html" target="_blank" title="赤十字募金ページへ">コチラ</a>をご参照ください。</p> |
---|
209 | <?php } ?> |
---|
210 | <?php } ?> |
---|
211 | </div> |
---|
212 | </div> |
---|