/** * Page のアクション. * * @return void */ public function action() { $masterData = new SC_DB_MasterData_Ex(); $objMailtemplate = new SC_Helper_Mailtemplate_Ex(); $mode = $this->getMode(); if (!empty($_POST)) { $objFormParam = new SC_FormParam_Ex(); $this->lfInitParam($mode, $objFormParam); $objFormParam->setParam($_POST); $objFormParam->convParam(); $this->arrErr = $objFormParam->checkError(); $post = $objFormParam->getHashArray(); } $this->arrMailTEMPLATE = $masterData->getMasterData('mtb_mail_template'); switch ($mode) { case 'id_set': $mailtemplate = $objMailtemplate->get($post['template_id']); if ($mailtemplate) { $this->arrForm = $mailtemplate; } else { $this->arrForm['template_id'] = $post['template_id']; } break; case 'regist': $this->arrForm = $post; if ($this->arrErr) { // エラーメッセージ $this->tpl_msg = 'エラーが発生しました'; } else { // 正常 $this->lfRegistMailTemplate($this->arrForm, $_SESSION['member_id'], $objMailtemplate); // 完了メッセージ $this->tpl_onload = "window.alert('メール設定が完了しました。テンプレートを選択して内容をご確認ください。');"; unset($this->arrForm); } break; default: break; } }
/** * * テンプレートの文言をフォームに入れる。 * @param SC_FormParam $objFormParam */ public function changeData(&$objFormParam) { $template_id = $objFormParam->getValue('template_id'); // 未選択時 if (strlen($template_id) === 0) { $mailTemplates = null; // 有効選択時 } elseif (SC_Utils_Ex::sfIsInt($template_id)) { $objMailtemplate = new SC_Helper_Mailtemplate_Ex(); $mailTemplates = $objMailtemplate->get($template_id); // 不正選択時 } else { trigger_error('テンプレートの指定が不正。', E_USER_ERROR); } if (empty($mailTemplates)) { foreach (array('subject', 'header', 'footer') as $key) { $objFormParam->setValue($key, ''); } } else { $objFormParam->setParam($mailTemplates); } return $objFormParam; }
public function sfSendOrderMail($order_id, $template_id, $subject = '', $header = '', $footer = '', $send = true) { $arrTplVar = new stdClass(); $arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); $arrTplVar->arrInfo = $arrInfo; $objQuery =& SC_Query_Ex::getSingletonInstance(); if ($subject == '' && $header == '' && $footer == '') { // メールテンプレート情報の取得 $objMailtemplate = new SC_Helper_Mailtemplate_Ex(); $mailtemplate = $objMailtemplate->get($template_id); $arrTplVar->tpl_header = $mailtemplate['header']; $arrTplVar->tpl_footer = $mailtemplate['footer']; $tmp_subject = $mailtemplate['subject']; } else { $arrTplVar->tpl_header = $header; $arrTplVar->tpl_footer = $footer; $tmp_subject = $subject; } // 受注情報の取得 $where = 'order_id = ? AND del_flg = 0'; $arrOrder = $objQuery->getRow('*', 'dtb_order', $where, array($order_id)); if (empty($arrOrder)) { trigger_error("該当する受注が存在しない。(注文番号: {$order_id})", E_USER_ERROR); } $where = 'order_id = ?'; $objQuery->setOrder('order_detail_id'); $arrTplVar->arrOrderDetail = $objQuery->select('*', 'dtb_order_detail', $where, array($order_id)); // 配送情報の取得 $arrTplVar->arrShipping = $this->sfGetShippingData($order_id); $arrTplVar->Message_tmp = $arrOrder['message']; // 会員情報の取得 $customer_id = $arrOrder['customer_id']; $objQuery->setOrder('customer_id'); $arrRet = $objQuery->select('point', 'dtb_customer', 'customer_id = ?', array($customer_id)); $arrCustomer = isset($arrRet[0]) ? $arrRet[0] : ''; $arrTplVar->arrCustomer = $arrCustomer; $arrTplVar->arrOrder = $arrOrder; //その他決済情報 if ($arrOrder['memo02'] != '') { $arrOther = unserialize($arrOrder['memo02']); foreach ($arrOther as $other_key => $other_val) { if (SC_Utils_Ex::sfTrim($other_val['value']) == '') { $arrOther[$other_key]['value'] = ''; } } $arrTplVar->arrOther = $arrOther; } // 都道府県変換 $arrTplVar->arrPref = $this->arrPref; // 国変換 $arrTplVar->arrCountry = $this->arrCountry; $objCustomer = new SC_Customer_Ex(); $arrTplVar->tpl_user_point = $objCustomer->getValue('point'); $objMailView = null; // 注文受付メール(携帯) if ($template_id == 2) { $objMailView = new SC_MobileView_Ex(); } else { $objMailView = new SC_SiteView_Ex(); } // メール本文の取得 $objMailView->setPage($this->getPage()); $objMailView->assignobj($arrTplVar); $body = $objMailView->fetch($this->arrMAILTPLPATH[$template_id]); // メール送信処理 $objSendMail = new SC_SendMail_Ex(); $bcc = $arrInfo['email01']; $from = $arrInfo['email03']; $error = $arrInfo['email04']; $tosubject = $this->sfMakeSubject($tmp_subject, $objMailView); $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); $objSendMail->setTo($arrOrder['order_email'], $arrOrder['order_name01'] . ' ' . $arrOrder['order_name02'] . ' 様'); // 送信フラグ:trueの場合は、送信する。 if ($send) { if ($objSendMail->sendMail()) { $this->sfSaveMailHistory($order_id, $template_id, $tosubject, $body); } } return $objSendMail; }