source: branches/eccube-donation/html/frontparts/bloc/send_point.php @ 20622

Revision 20622, 7.3 KB checked in by tao, 13 years ago (diff)

現状をコミット

  • Property svn:executable set to *
RevLine 
[20622]1<style type="text/css">
2div#sendPoint{border: none;background: #FFF6CF;text-align: center;overflow: auto;}
3div#sendPoint div#innner{border: 3px solid red;margin:8px;}
4div#sendPoint div#innner h2{margin:12px;font-size:18px;color:red;text-shadow: -1px -1px 0px #FFF;font-weight: bold;}
5div#sendPoint div#innner p{margin:2px 4px;font-size:90%;}
6div#sendPoint div#innner div#sendForm{border:1px solid #CCC;margin:12px;background:#FFF;padding:8px 4px;}
7div#sendPoint div#innner div#sendForm form input{font-size: 120%;width: 60px;margin-bottom:4px;}
8div#sendPoint div#innner div#sendForm form input#sendpointValue{text-align: right; padding:2px 4px;margin-right: 6px;}
9div#sendPoint div#innner span.smalltext{font-size:90%;}
10div#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
39if( !defined("CLASS_PATH") ){
40    require_once("../../require.php");
41}
42require_once(CLASS_PATH . "pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php");
43
44// }}}
45// {{{ generate page
46class 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    }
62
63    /**
64     * Page のプロセス.
65     *
66     * @return void
67     */
68    function process() {
69        if(!file_exists(DATA_PATH.'downloads/donation.csv')){
70            $objQuery = new SC_Query;
71            $ret = $objQuery->getOne("SELECT php_path FROM dtb_bloc WHERE php_path = 'frontparts/bloc/send_point.php'");
72            if(!$ret){
73                $objQuery->query("INSERT INTO dtb_bloc (bloc_name,tpl_path,filename,create_date,update_date,php_path,del_flg)
74                 VALUES('東北地方太平洋沖地震ポイント寄付','','send_point',NOW(),NOW(),'frontparts/bloc/send_point.php',0)");
75            }
76        }
77
78        $objCustomer = new SC_Customer();
79        $objCustomer->updateSession();
80        // クッキー管理クラス
81        $objCookie = new SC_Cookie(COOKIE_EXPIRE);
82
83        // ログイン判定
84        if($objCustomer->isLoginSuccess()) {
85            $this->tpl_user_point = $objCustomer->getValue('point');
86            if (strlen($this->tpl_user_point) == 0) $this->tpl_user_point = 0;
87            if(isset($_POST["sendpoint"]) and $this->isValidToken()){
88                //ポイント寄付処理
89                $point = intval(mb_convert_kana($_POST["sendpoint"],"n"));
90                if(!$point or $this->tpl_user_point < $point){
91                    $this->tpl_error = "1以上のポイントを保有ポイント内で半角数字で入力してください。";
92                }else{
93                    $objQuery = new SC_Query;
94                    $sqlval = array('point' => ($this->tpl_user_point - $point));
95                    $where = 'customer_id = ? AND del_flg = 0 AND status = 2';
96                    $rs = $objQuery->update('dtb_customer', $sqlval, $where, array($objCustomer->getValue('customer_id')));
97                    if($rs){
98                        $fp = fopen(DATA_PATH.'downloads/donation.csv','a+');
99                        fwrite($fp,date("Y-m-d G:i:s").",".$objCustomer->getValue('customer_id').",".$point."\n");
100                        $objCustomer->setValue("point", ($this->tpl_user_point - $point));
101                        $this->tpl_error = "ご協力ありがとうございます。".$point."ptを承りました。<br />寄付頂いたポイント分を、東北地方太平洋沖地震の復旧活動へ寄付いたします。";
102                    } else {
103                        $this->tpl_error = "システムエラー"; 
104                    }
105                }
106            }
107            $this->tpl_login = true;
108            $objCustomer->updateSession();
109            $this->tpl_user_point = $objCustomer->getValue('point');
110            if (strlen($this->tpl_user_point) == 0) $this->tpl_user_point = 0;
111            $this->tpl_name1 = $objCustomer->getValue('name01');
112            $this->tpl_name2 = $objCustomer->getValue('name02');
113        } else {
114            // クッキー判定
115            $this->tpl_login_email = $objCookie->getCookie('login_email');
116            if($this->tpl_login_email != "") {
117                $this->tpl_login_memory = "1";
118            }
119
120            // POSTされてきたIDがある場合は優先する。
121            if($_POST['login_email'] != "") {
122                $this->tpl_login_email = $_POST['login_email'];
123            }
124        }
125        $this->transactionid = $this->getToken();
126    }
127
128    /**
129     * デストラクタ.
130     *
131     * @return void
132     */
133    function destroy() {
134        parent::destroy();
135    }
136}
137
138$objPage = new LC_Page_FrontParts_Bloc_SendPoint();
139register_shutdown_function(array($objPage, "destroy"));
140$objPage->init();
141$objPage->process();
142
143?>
144<a name="sendPoint"></a>
145<div id="sendPoint">
146<div id="innner">
147<h2>東北地方太平洋沖地震へのポイント寄付のお願い</h2>
148<?php if($objPage->tpl_login){?>
149<p>現在お客様が保有している当店のポイントを東北地方太平洋沖地震の復旧活動へ寄付出来ます。</p>
150<p>下記フォームに寄付するポイント数を入力の上、「寄付」ボタンをクリックしてください。</p>
151<p>運営担当者が寄付されたポイントを集計し、東北地方太平洋沖地震の復旧活動に寄付させて頂きます。</p>
152<div id="sendForm">
153<p><span class="red"><?php echo $objPage->tpl_error; ?></span></p>
154    <form method="post" action="#sendPoint" name="sendPoint">
155        <input type="hidden" name="transactionid" value="<?php echo $objPage->transactionid ?>" />
156        <p><span class="smalltext">現在お客様が保有しているポイント:<?php echo $objPage->tpl_user_point ?>pt</span></p>
157        <p>
158            <input type="text" maxlength="10" name="sendpoint" id="sendpointValue" value="" size="5" />ptを寄付<br />
159            <input type="submit" value="寄付" />
160        </p>
161    </form>
162</div>
163<?php }else{ ?>
164<p>会員のお客様は、現在お客様が保有している当店のポイントを東北地方太平洋沖地震の復旧活動へ寄付できます。ログインしてご協力をお願いします。</p>
165<p>- <a href="<?php echo URL_MYPAGE_TOP ?>">ログイン</a> -</p>
166<p>運営担当者が寄付されたポイントを集計し、東北地方太平洋沖地震の復旧活動へ寄付させて頂きます。</p>
167<?php } ?>
168</div>
169</div>
170
Note: See TracBrowser for help on using the repository browser.