Page
[ class tree: Page ] [ index: Page ] [ all elements ]

Source for file LC_Page_Admin_Order_Mail.php

Documentation is available at LC_Page_Admin_Order_Mail.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2011 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_EX_REALDIR 'page_extends/admin/order/LC_Page_Admin_Order_Ex.php';
  26.  
  27. /**
  28.  * 受注メール管理 のページクラス.
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id: LC_Page_Admin_Order_Mail.php 20970 2011-06-10 10:27:24Z Seasoft $
  33.  */
  34. class LC_Page_Admin_Order_Mail extends LC_Page_Admin_Order_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_mainno 'order';
  48.         $this->tpl_subno 'index';
  49.         $this->tpl_maintitle '受注管理';
  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.         $objFormParam new SC_FormParam_Ex();
  75.         // パラメーター情報の初期化
  76.         $this->lfInitParam($objFormParam);
  77.  
  78.         // POST値の取得
  79.         $objFormParam->setParam($_POST);
  80.         $objFormParam->convParam();
  81.         $this->tpl_order_id $objFormParam->getValue('order_id');
  82.  
  83.         // 検索パラメーターの引き継ぎ
  84.         $this->arrSearchHidden $objFormParam->getSearchArray();
  85.  
  86.         switch($this->getMode()) {
  87.             case 'pre_edit':
  88.                 break;
  89.             case 'return':
  90.                 break;
  91.             case 'send':
  92.                 $sendStatus $this->doSend($objFormParam);
  93.                 if($sendStatus === true){
  94.                     SC_Response_Ex::sendRedirect(ADMIN_ORDER_URLPATH);
  95.                     exit;
  96.                 }else{
  97.                     $this->arrErr $sendStatus;
  98.                 }
  99.             case 'confirm':
  100.                 $status $this->confirm($objFormParam);
  101.                 if($status === true){
  102.                     $this->arrHidden $objFormParam->getHashArray();
  103.                     return ;
  104.                 }else{
  105.                     $this->arrErr $status;
  106.                 }
  107.                 break;
  108.             case 'change':
  109.                 $objFormParam =  $this->changeData($objFormParam);
  110.                 break;
  111.         }
  112.  
  113.         if(SC_Utils_Ex::sfIsInt($objFormParam->getValue('order_id'))) {
  114.             $this->arrMailHistory $this->getMailHistory($objFormParam->getValue('order_id'));
  115.         }
  116.  
  117.         $this->arrForm $objFormParam->getFormParamList();
  118.     }
  119.  
  120.     /**
  121.      * 指定された注文番号のメール履歴を取得する。
  122.      * @var int order_id
  123.      */
  124.     function getMailHistory($order_id){
  125.         $objQuery =SC_Query_Ex::getSingletonInstance();
  126.         $col "send_date, subject, template_id, send_id";
  127.         $where "order_id = ?";
  128.         $objQuery->setOrder("send_date DESC");
  129.         return $objQuery->select($col"dtb_mail_history"$wherearray($order_id));
  130.     }
  131.  
  132.     /**
  133.      *
  134.      * メールを送る。
  135.      * @param SC_FormParam $objFormParam 
  136.      */
  137.     function doSend(&$objFormParam){
  138.         $arrErr $objFormParam->checkerror();
  139.  
  140.         // メールの送信
  141.         if (count($arrErr== 0{
  142.             // 注文受付メール
  143.             $objMail new SC_Helper_Mail_Ex();
  144.             $objSendMail $objMail->sfSendOrderMail($objFormParam->getValue('order_id'),
  145.             $objFormParam->getValue('template_id'),
  146.             $objFormParam->getValue('subject'),
  147.             $objFormParam->getValue('header'),
  148.             $objFormParam->getValue('footer'));
  149.             // TODO $SC_SendMail から送信がちゃんと出来たか確認できたら素敵。
  150.             return true;
  151.         }
  152.         return $arrErr;
  153.     }
  154.  
  155.     /**
  156.      * 確認画面を表示する為の準備
  157.      * @param SC_FormParam $objFormParam 
  158.      */
  159.     function confirm(&$objFormParam){
  160.         $arrErr $objFormParam->checkerror();
  161.         // メールの送信
  162.         if (count($arrErr== 0{
  163.             // 注文受付メール(送信なし)
  164.             $objMail new SC_Helper_Mail_Ex();
  165.             $objSendMail $objMail->sfSendOrderMail(
  166.             $objFormParam->getValue('order_id'),
  167.             $objFormParam->getValue('template_id'),
  168.             $objFormParam->getValue('subject'),
  169.             $objFormParam->getValue('header'),
  170.             $objFormParam->getValue('footer')false);
  171.  
  172.             $this->tpl_subject $objFormParam->getValue('subject');
  173.             $this->tpl_body mb_convert_encoding$objSendMail->bodyCHAR_CODE'auto' );
  174.             $this->tpl_to $objSendMail->tpl_to;
  175.             $this->tpl_mainpage 'order/mail_confirm.tpl';
  176.             return true;
  177.         }
  178.         return $arrErr;
  179.     }
  180.  
  181.     /**
  182.      *
  183.      * テンプレートの文言をフォームに入れる。
  184.      * @param SC_FormParam $objFormParam 
  185.      */
  186.     function changeData(&$objFormParam){
  187.         if(SC_Utils_Ex::sfIsInt($objFormParam->getValue('template_id'))) {
  188.             $objQuery =SC_Query_Ex::getSingletonInstance();
  189.             $where "template_id = ?";
  190.             $mailTemplates $objQuery->select("subject, header, footer""dtb_mailtemplate"$wherearray($objFormParam->getValue('template_id')));
  191.             if(!is_null($mailTemplates )){
  192.                 foreach(array('subject','header','footer'as $key){
  193.                     $objFormParam->setValue($key,$mailTemplates[$key]);
  194.                 }
  195.             }
  196.             $objFormParam->setParam($mailTemplates[0]);
  197.         }else{
  198.             foreach(array('subject','header','footer'as $key){
  199.                 $objFormParam->setValue($key,"");
  200.             }
  201.         }
  202.         return $objFormParam;
  203.     }
  204.  
  205.     /**
  206.      * デストラクタ.
  207.      *
  208.      * @return void 
  209.      */
  210.     function destroy({
  211.         parent::destroy();
  212.     }
  213.  
  214.     /**
  215.      * パラメーター情報の初期化
  216.      * @param SC_FormParam $objFormParam 
  217.      */
  218.     function lfInitParam(&$objFormParam{
  219.         // 検索条件のパラメーターを初期化
  220.         parent::lfInitParam($objFormParam);
  221.  
  222.         $objFormParam->addParam("オーダーID""order_id"INT_LEN'n'array("EXIST_CHECK""MAX_LENGTH_CHECK""NUM_CHECK"));
  223.         $objFormParam->addParam("テンプレート""template_id"INT_LEN'n'array("EXIST_CHECK""MAX_LENGTH_CHECK""NUM_CHECK"));
  224.         $objFormParam->addParam("メールタイトル"'subject'STEXT_LEN'KVa',  array("EXIST_CHECK""MAX_LENGTH_CHECK""SPTAB_CHECK"));
  225.         $objFormParam->addParam("ヘッダー"'header'LTEXT_LEN'KVa'array("MAX_LENGTH_CHECK""SPTAB_CHECK"));
  226.         $objFormParam->addParam("フッター"'footer'LTEXT_LEN'KVa'array("MAX_LENGTH_CHECK""SPTAB_CHECK"));
  227.     }
  228. }
  229. ?>

Documentation generated on Fri, 24 Feb 2012 14:01:27 +0900 by Seasoft