source: branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Mail.php @ 20534

Revision 20534, 7.5 KB checked in by Seasoft, 13 years ago (diff)

#627(ソース整形・ソースコメントの改善)
#628(未使用処理・定義などの削除)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
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
25require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
26
27/**
28 * 受注メール管理 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Order_Mail extends LC_Page_Admin_Ex {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'order/mail.tpl';
47        $this->tpl_subnavi = 'order/subnavi.tpl';
48        $this->tpl_mainno = 'order';
49        $this->tpl_subno = 'index';
50        $this->tpl_subtitle = '受注管理';
51
52        $masterData = new SC_DB_MasterData_Ex();
53        $this->arrMAILTEMPLATE = $masterData->getMasterData("mtb_mail_template");
54        $this->httpCacheControl('nocache');
55    }
56
57    /**
58     * Page のプロセス.
59     *
60     * @return void
61     */
62    function process() {
63        $this->action();
64        $this->sendResponse();
65    }
66
67    /**
68     * Page のアクション.
69     *
70     * @return void
71     */
72    function action() {
73        // 検索パラメータの引き継ぎ
74        $this->arrSearchHidden = SC_Utils_Ex::sfFilterKey($_POST,"^search_");
75        // パラメータ管理クラス
76        $objFormParam = new SC_FormParam_Ex();
77        // パラメータ情報の初期化
78        $this->lfInitParam($objFormParam);
79        // POST値の取得
80        $objFormParam->setParam($_POST);
81        $objFormParam->convParam();
82        $this->tpl_order_id = $objFormParam->getValue('order_id');
83
84        switch($this->getMode()) {
85            case 'pre_edit':
86                break;
87            case 'return':
88                break;
89            case 'send':
90                $sendStatus = $this->doSend($objFormParam);
91                if($sendStatus === true){
92                    SC_Response_Ex::sendRedirect(ADMIN_ORDER_URLPATH);
93                    exit;
94                }else{
95                    $this->arrErr = $sendStatus;
96                }
97            case 'confirm':
98                $status = $this->confirm($objFormParam);
99                if($status === true){
100                    $this->arrHidden = $objFormParam->getHashArray();
101                    return ;
102                }else{
103                    $this->arrErr = $status;
104                }
105                break;
106            case 'change':
107                $objFormParam =  $this->changeData($objFormParam);
108                break;
109        }
110
111        if(SC_Utils_Ex::sfIsInt($objFormParam->getValue('order_id'))) {
112            $this->arrMailHistory = $this->getMailHistory($objFormParam->getValue('order_id'));
113        }
114
115        $this->arrForm = $objFormParam->getFormParamList();
116    }
117
118    /**
119     * 指定された注文番号のメール履歴を取得する。
120     * @var int order_id
121     */
122    function getMailHistory($order_id){
123        $objQuery =& SC_Query_Ex::getSingletonInstance();
124        $col = "send_date, subject, template_id, send_id";
125        $where = "order_id = ?";
126        $objQuery->setOrder("send_date DESC");
127        return $objQuery->select($col, "dtb_mail_history", $where, array($order_id));
128    }
129
130    /**
131     *
132     * メールを送る。
133     * @param SC_FormParam $objFormParam
134     */
135    function doSend(&$objFormParam){
136        $arrErr = $objFormParam->checkerror();
137
138        // メールの送信
139        if (count($arrErr) == 0) {
140            // 注文受付メール
141            $objMail = new SC_Helper_Mail_Ex();
142            $objSendMail = $objMail->sfSendOrderMail($objFormParam->getValue('order_id'),
143            $objFormParam->getValue('template_id'),
144            $objFormParam->getValue('subject'),
145            $objFormParam->getValue('header'),
146            $objFormParam->getValue('footer'));
147            // TODO $SC_SendMail から送信がちゃんと出来たか確認できたら素敵。
148            return true;
149        }
150        return $arrErr;
151    }
152
153    /**
154     * 確認画面を表示する為の準備
155     * @param SC_FormParam $objFormParam
156     */
157    function confirm(&$objFormParam){
158        $arrErr = $objFormParam->checkerror();
159        // メールの送信
160        if (count($arrErr) == 0) {
161            // 注文受付メール(送信なし)
162            $objMail = new SC_Helper_Mail_Ex();
163            $objSendMail = $objMail->sfSendOrderMail(
164            $objFormParam->getValue('order_id'),
165            $objFormParam->getValue('template_id'),
166            $objFormParam->getValue('subject'),
167            $objFormParam->getValue('header'),
168            $objFormParam->getValue('footer'), false);
169
170            $this->tpl_subject = $objFormParam->getValue('subject');
171            $this->tpl_body = mb_convert_encoding( $objSendMail->body, CHAR_CODE, "auto" );
172            $this->tpl_to = $objSendMail->tpl_to;
173            $this->tpl_mainpage = 'order/mail_confirm.tpl';
174            return true;
175        }
176        return $arrErr;
177    }
178
179    /**
180     *
181     * テンプレートの文言をフォームに入れる。
182     * @param SC_FormParam $objFormParam
183     */
184    function changeData(&$objFormParam){
185        if(SC_Utils_Ex::sfIsInt($objFormParam->getValue('template_id'))) {
186            $objQuery =& SC_Query_Ex::getSingletonInstance();
187            $where = "template_id = ?";
188            $mailTemplates = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($objFormParam->getValue('template_id')));
189            if(!is_null($mailTemplates )){
190                foreach(array('subject','header','footer') as $key){
191                    $objFormParam->setValue($key,$mailTemplates[$key]);
192                }
193            }
194            $objFormParam->setParam($mailTemplates[0]);
195        }else{
196            foreach(array('subject','header','footer') as $key){
197                $objFormParam->setValue($key,"");
198            }
199        }
200        return $objFormParam;
201    }
202
203
204    /**
205     * デストラクタ.
206     *
207     * @return void
208     */
209    function destroy() {
210        parent::destroy();
211    }
212
213
214    /**
215     * パラメータ情報の初期化
216     * @param SC_FormParam $objFormParam
217     */
218    function lfInitParam(&$objFormParam) {
219        $objFormParam->addParam("オーダーID", "order_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
220        $objFormParam->addParam("テンプレート", "template_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
221        $objFormParam->addParam("メールタイトル", "subject", STEXT_LEN, "KVa",  array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK"));
222        $objFormParam->addParam("ヘッダー", "header", LTEXT_LEN, "KVa", array("MAX_LENGTH_CHECK", "SPTAB_CHECK"));
223        $objFormParam->addParam("フッター", "footer", LTEXT_LEN, "KVa", array("MAX_LENGTH_CHECK", "SPTAB_CHECK"));
224    }
225}
226?>
Note: See TracBrowser for help on using the repository browser.