| 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 |
|---|
| 25 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
|---|
| 26 | |
|---|
| 27 | /** |
|---|
| 28 | * メルマガプレビュー のページクラス. |
|---|
| 29 | * |
|---|
| 30 | * @package Page |
|---|
| 31 | * @author LOCKON CO.,LTD. |
|---|
| 32 | * @version $Id$ |
|---|
| 33 | */ |
|---|
| 34 | class LC_Page_Admin_Mail_Preview extends LC_Page { |
|---|
| 35 | |
|---|
| 36 | // }}} |
|---|
| 37 | // {{{ functions |
|---|
| 38 | |
|---|
| 39 | /** |
|---|
| 40 | * Page を初期化する. |
|---|
| 41 | * |
|---|
| 42 | * @return void |
|---|
| 43 | */ |
|---|
| 44 | function init() { |
|---|
| 45 | parent::init(); |
|---|
| 46 | $this->tpl_mainpage = 'mail/preview.tpl'; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | /** |
|---|
| 50 | * Page のプロセス. |
|---|
| 51 | * |
|---|
| 52 | * @return void |
|---|
| 53 | */ |
|---|
| 54 | function process() { |
|---|
| 55 | $conn = new SC_DBConn(); |
|---|
| 56 | $objView = new SC_AdminView(); |
|---|
| 57 | $objSess = new SC_Session(); |
|---|
| 58 | $objDate = new SC_Date(); |
|---|
| 59 | |
|---|
| 60 | // 認証可否の判定 |
|---|
| 61 | SC_Utils_Ex::sfIsSuccess($objSess); |
|---|
| 62 | |
|---|
| 63 | if (!isset($_POST['body'])) $_POST['body'] = ""; |
|---|
| 64 | if (!isset($_REQUEST['method'])) $_REQUEST['method'] = ""; |
|---|
| 65 | if (!isset($_REQUEST['id'])) $_REQUEST['id'] = ""; |
|---|
| 66 | if (!isset($_GET['send_id'])) $_GET['send_id'] = ""; |
|---|
| 67 | |
|---|
| 68 | if ( $_POST['body'] ){ |
|---|
| 69 | $this->body = $_POST['body']; |
|---|
| 70 | |
|---|
| 71 | // HTMLメールテンプレートのプレビュー |
|---|
| 72 | } elseif ($_REQUEST["method"] == "template" |
|---|
| 73 | && SC_Utils_Ex::sfCheckNumLength($_REQUEST['id'])) { |
|---|
| 74 | |
|---|
| 75 | $sql = "SELECT * FROM dtb_mailmaga_template WHERE template_id = ?"; |
|---|
| 76 | $result = $conn->getAll($sql, array($_REQUEST["id"])); |
|---|
| 77 | $this->list_data = $result[0]; |
|---|
| 78 | |
|---|
| 79 | //メール担当写真の表示 |
|---|
| 80 | $objUpFile = new SC_UploadFile(IMAGE_TEMP_URL, IMAGE_SAVE_URL); |
|---|
| 81 | $objUpFile->addFile("メール担当写真", 'charge_image', array('jpg'), IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); |
|---|
| 82 | $objUpFile->setDBFileList($this->list_data); |
|---|
| 83 | // Form用配列を渡す。 |
|---|
| 84 | $this->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL); |
|---|
| 85 | |
|---|
| 86 | // メイン商品の情報取得 |
|---|
| 87 | $sql = "SELECT name, main_image, point_rate, deliv_fee, price01_min, price01_max, price02_min, price02_max FROM vw_products_allclass AS allcls WHERE product_id = ?"; |
|---|
| 88 | $main = $conn->getAll($sql, array($this->list_data["main_product_id"])); |
|---|
| 89 | $this->list_data["main"] = $main[0]; |
|---|
| 90 | |
|---|
| 91 | // サブ商品の情報取得 |
|---|
| 92 | $sql = "SELECT product_id, name, main_list_image, price01_min, price01_max, price02_min, price02_max FROM vw_products_allclass WHERE product_id = ?"; |
|---|
| 93 | $k = 0; |
|---|
| 94 | $l = 0; |
|---|
| 95 | for ($i = 1; $i <= 12; $i ++) { |
|---|
| 96 | if ($l == 4) { |
|---|
| 97 | $l = 0; |
|---|
| 98 | $k ++; |
|---|
| 99 | } |
|---|
| 100 | $result = ""; |
|---|
| 101 | $j = sprintf("%02d", $i); |
|---|
| 102 | if ($i > 0 && $i < 5 ) $k = 0; |
|---|
| 103 | if ($i > 4 && $i < 9 ) $k = 1; |
|---|
| 104 | if ($i > 8 && $i < 13 ) $k = 2; |
|---|
| 105 | |
|---|
| 106 | if (is_numeric($this->list_data["sub_product_id" .$j])) { |
|---|
| 107 | $result = $conn->getAll($sql, array($this->list_data["sub_product_id" .$j])); |
|---|
| 108 | $this->list_data["sub"][$k][$l] = $result[0]; |
|---|
| 109 | $this->list_data["sub"][$k]["data_exists"] = "OK"; //当該段にデータが1つ以上存在するフラグ |
|---|
| 110 | } |
|---|
| 111 | $l ++; |
|---|
| 112 | } |
|---|
| 113 | $this->tpl_mainpage = 'mail/html_template.tpl'; |
|---|
| 114 | |
|---|
| 115 | } elseif (SC_Utils_Ex::sfCheckNumLength($_GET['send_id']) |
|---|
| 116 | || SC_Utils_Ex::sfCheckNumLength($_GET['id'])){ |
|---|
| 117 | if (is_numeric($_GET["send_id"])) { |
|---|
| 118 | $id = $_GET["send_id"]; |
|---|
| 119 | $sql = "SELECT body, mail_method FROM dtb_send_history WHERE send_id = ?"; |
|---|
| 120 | } else { |
|---|
| 121 | $sql = "SELECT body, mail_method FROM dtb_mailmaga_template WHERE template_id = ?"; |
|---|
| 122 | $id = $_GET['id']; |
|---|
| 123 | } |
|---|
| 124 | $result = $conn->getAll($sql, array($id)); |
|---|
| 125 | |
|---|
| 126 | if ( $result ){ |
|---|
| 127 | if ( $result[0]["mail_method"] == 2 ){ |
|---|
| 128 | // テキスト形式の時はタグ文字をエスケープ |
|---|
| 129 | $this->escape_flag = 1; |
|---|
| 130 | } |
|---|
| 131 | $this->body = $result[0]["body"]; |
|---|
| 132 | } |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | $objView->assignobj($this); |
|---|
| 136 | $objView->display($this->tpl_mainpage); |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | /** |
|---|
| 140 | * デストラクタ. |
|---|
| 141 | * |
|---|
| 142 | * @return void |
|---|
| 143 | */ |
|---|
| 144 | function destroy() { |
|---|
| 145 | parent::destroy(); |
|---|
| 146 | } |
|---|
| 147 | } |
|---|
| 148 | ?> |
|---|