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

Source for file SC_Helper_Mail.php

Documentation is available at SC_Helper_Mail.php

  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. /**
  25.  * メール関連 のヘルパークラス.
  26.  *
  27.  * @package Helper
  28.  * @author LOCKON CO.,LTD.
  29.  * @version $Id$
  30.  */
  31. class SC_Helper_Mail {
  32.  
  33.     /** メールテンプレートのパス */
  34.     var $arrMAILTPLPATH;
  35.  
  36.     /**
  37.      * コンストラクタ.
  38.      */
  39.     function SC_Helper_Mail({
  40.         $masterData new SC_DB_MasterData_Ex();
  41.         $this->arrMAILTPLPATH =  $masterData->getMasterData("mtb_mail_tpl_path");
  42.         $this->arrPref $masterData->getMasterData("mtb_pref",
  43.                                  array("pref_id""pref_name""rank"));
  44.     }
  45.  
  46.     /* DBに登録されたテンプレートメールの送信 */
  47.     function sfSendTemplateMail($to$to_name$template_id&$objPage$from_address ""$from_name ""$reply_to ""{
  48.  
  49.         $objQuery new SC_Query();
  50.         // メールテンプレート情報の取得
  51.         $where "template_id = ?";
  52.         $arrRet $objQuery->select("subject, header, footer""dtb_mailtemplate"$wherearray($template_id));
  53.         $objPage->tpl_header $arrRet[0]['header'];
  54.         $objPage->tpl_footer $arrRet[0]['footer'];
  55.         $tmp_subject $arrRet[0]['subject'];
  56.  
  57.         $objSiteInfo new SC_SiteInfo();
  58.         $arrInfo $objSiteInfo->data;
  59.  
  60.         $objMailView new SC_SiteView();
  61.         // メール本文の取得
  62.         $objMailView->assignobj($objPage);
  63.         $body $objMailView->fetch($this->arrMAILTPLPATH[$template_id]);
  64.  
  65.         // メール送信処理
  66.         $objSendMail new SC_SendMail_Ex();
  67.         $from $arrInfo['email03'];
  68.         if ($from_address == ""$from_address $arrInfo['email03'];
  69.         if ($from_name == ""$from_name $arrInfo['shop_name'];
  70.         if ($reply_to == ""$reply_to $arrInfo['email03'];
  71.         $error $arrInfo['email04'];
  72.         $tosubject $tmp_subject;
  73.         $objSendMail->setItem(''$tosubject$body$from_address$from_name$reply_to$error$error);
  74.         $objSendMail->setTo($to$to_name);
  75.         $objSendMail->sendMail();    // メール送信
  76.     }
  77.  
  78.     /* 受注完了メール送信 */
  79.     function sfSendOrderMail($order_id$template_id$subject ""$header ""$footer ""$send true{
  80.  
  81.         $objPage new LC_Page();
  82.         $objSiteInfo new SC_SiteInfo();
  83.         $arrInfo $objSiteInfo->data;
  84.         $objPage->arrInfo $arrInfo;
  85.  
  86.         $objQuery new SC_Query();
  87.  
  88.         if($subject == "" && $header == "" && $footer == ""{
  89.             // メールテンプレート情報の取得
  90.             $where "template_id = ?";
  91.             $arrRet $objQuery->select("subject, header, footer""dtb_mailtemplate"$wherearray($template_id));
  92.             $objPage->tpl_header $arrRet[0]['header'];
  93.             $objPage->tpl_footer $arrRet[0]['footer'];
  94.             $tmp_subject $arrRet[0]['subject'];
  95.         else {
  96.             $objPage->tpl_header $header;
  97.             $objPage->tpl_footer $footer;
  98.             $tmp_subject $subject;
  99.         }
  100.  
  101.         // 受注情報の取得
  102.         $where "order_id = ?";
  103.         $arrRet $objQuery->select("*""dtb_order"$wherearray($order_id));
  104.         $arrOrder $arrRet[0];
  105.         $arrOrderDetail $objQuery->select("*""dtb_order_detail"$wherearray($order_id));
  106.  
  107.         $objPage->Message_tmp $arrOrder['message'];
  108.  
  109.         // 顧客情報の取得
  110.         $customer_id $arrOrder['customer_id'];
  111.         $arrRet $objQuery->select("point""dtb_customer""customer_id = ?"array($customer_id));
  112.         $arrCustomer = isset($arrRet[0]$arrRet[0"";
  113.  
  114.         $objPage->arrCustomer $arrCustomer;
  115.         $objPage->arrOrder $arrOrder;
  116.  
  117.         //その他決済情報
  118.         if($arrOrder['memo02'!= ""{
  119.             $arrOther unserialize($arrOrder['memo02']);
  120.  
  121.             foreach($arrOther as $other_key => $other_val){
  122.                 if(SC_Utils_Ex::sfTrim($other_val["value"]== ""){
  123.                     $arrOther[$other_key]["value""";
  124.                 }
  125.             }
  126.  
  127.             $objPage->arrOther $arrOther;
  128.         }
  129.  
  130.         // 都道府県変換
  131.         $objPage->arrOrder['deliv_pref'$this->arrPref[$objPage->arrOrder['deliv_pref']];
  132.  
  133.         $objPage->arrOrderDetail $arrOrderDetail;
  134.  
  135.         $objCustomer new SC_Customer();
  136.         $objPage->tpl_user_point $objCustomer->getValue('point');
  137.  
  138.         $objMailView new SC_SiteView();
  139.         // メール本文の取得
  140.         $objMailView->assignobj($objPage);
  141.         $body $objMailView->fetch($this->arrMAILTPLPATH[$template_id]);
  142.  
  143.         // メール送信処理
  144.         $objSendMail new SC_SendMail_Ex();
  145.         $bcc $arrInfo['email01'];
  146.         $from $arrInfo['email03'];
  147.         $error $arrInfo['email04'];
  148.  
  149.         $tosubject $this->sfMakeSubject($objQuery$objMailView,
  150.                                              $objPage$tmp_subject);
  151.  
  152.         $objSendMail->setItem(''$tosubject$body$from$arrInfo['shop_name']$from$error$error$bcc);
  153.         $objSendMail->setTo($arrOrder["order_email"]$arrOrder["order_name01"" "$arrOrder["order_name02"." 様");
  154.  
  155.  
  156.         // 送信フラグ:trueの場合は、送信する。
  157.         if($send{
  158.             if ($objSendMail->sendMail()) {
  159.                 $this->sfSaveMailHistory($order_id$template_id$tosubject$body);
  160.             }
  161.         }
  162.  
  163.         return $objSendMail;
  164.     }
  165.  
  166.     // テンプレートを使用したメールの送信
  167.     function sfSendTplMail($to$subject$tplpath&$objPage{
  168.         $objMailView new SC_SiteView();
  169.         $objSiteInfo new SC_SiteInfo();
  170.         $arrInfo $objSiteInfo->data;
  171.         // メール本文の取得
  172.         $objPage->tpl_shopname=$arrInfo['shop_name'];
  173.         $objPage->tpl_infoemail $arrInfo['email02'];
  174.         $objMailView->assignobj($objPage);
  175.         $body $objMailView->fetch($tplpath);
  176.         // メール送信処理
  177.         $objSendMail new SC_SendMail_Ex();
  178.         $bcc $arrInfo['email01'];
  179.         $from $arrInfo['email03'];
  180.         $error $arrInfo['email04'];
  181.         $objSendMail->setItem($to$subject$body$from$arrInfo['shop_name']$from$error$error$bcc);
  182.         $objSendMail->sendMail();
  183.     }
  184.  
  185.     // 通常のメール送信
  186.     function sfSendMail($to$subject$body{
  187.         $objSiteInfo new SC_SiteInfo();
  188.         $arrInfo $objSiteInfo->data;
  189.         // メール送信処理
  190.         $objSendMail new SC_SendMail_Ex();
  191.         $bcc $arrInfo['email01'];
  192.         $from $arrInfo['email03'];
  193.         $error $arrInfo['email04'];
  194.         $objSendMail->setItem($to$subject$body$from$arrInfo['shop_name']$from$error$error$bcc);
  195.         $objSendMail->sendMail();
  196.     }
  197.  
  198.     //件名にテンプレートを用いる
  199.     function sfMakeSubject(&$objQuery&$objMailView&$objPage$subject){
  200.  
  201.         $arrInfo $objQuery->select("*","dtb_baseinfo");
  202.         $arrInfo $arrInfo[0];
  203.         $objPage->tpl_shopname=$arrInfo['shop_name'];
  204.         $objPage->tpl_infoemail=$subject;
  205.         $objMailView->assignobj($objPage);
  206.         $mailtitle $objMailView->fetch('mail_templates/mail_title.tpl');
  207.         $ret $mailtitle.$subject;
  208.         return $ret;
  209.     }
  210.  
  211.     // メール配信履歴への登録
  212.     function sfSaveMailHistory($order_id$template_id$subject$body{
  213.         $sqlval['subject'$subject;
  214.         $sqlval['order_id'$order_id;
  215.         $sqlval['template_id'$template_id;
  216.         $sqlval['send_date'"Now()";
  217.         if (!isset($_SESSION['member_id'])) $_SESSION['member_id'"";
  218.         if($_SESSION['member_id'!= ""{
  219.             $sqlval['creator_id'$_SESSION['member_id'];
  220.         else {
  221.             $sqlval['creator_id''0';
  222.         }
  223.         $sqlval['mail_body'$body;
  224.  
  225.         $objQuery new SC_Query();
  226.         $objQuery->insert("dtb_mail_history"$sqlval);
  227.     }
  228.  
  229.     /* 会員登録があるかどうかのチェック(仮会員を含まない) */
  230.     function sfCheckCustomerMailMaga($email{
  231.         $col "email, mailmaga_flg, customer_id";
  232.         $from "dtb_customer";
  233.         $where "(email = ? OR email_mobile = ?) AND status = 2 AND del_flg = 0";
  234.         $objQuery new SC_Query();
  235.         $arrRet $objQuery->select($col$from$wherearray($email));
  236.         // 会員のメールアドレスが登録されている
  237.         if(!empty($arrRet[0]['customer_id'])) {
  238.             return true;
  239.         }
  240.         return false;
  241.     }
  242. }
  243. ?>

Documentation generated on Fri, 24 Feb 2012 14:00:15 +0900 by Seasoft