source: branches/dev/html/admin/order/mail.php @ 14072

Revision 14072, 4.8 KB checked in by nakanishi, 19 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once("../require.php");
8
9class LC_Page {
10    var $list_data;
11    var $mailTemp;
12    function LC_Page() {
13        $this->tpl_mainpage = 'order/mail.tpl';
14        $this->tpl_subnavi = 'order/subnavi.tpl';
15        $this->tpl_mainno = 'order';       
16        $this->tpl_subno = 'index';
17        $this->tpl_subtitle = '¼õÃí´ÉÍý';
18        global $arrMAILTEMPLATE;
19        $this->arrMAILTEMPLATE = $arrMAILTEMPLATE;
20    }
21}
22
23$objPage = new LC_Page();
24$objView = new SC_AdminView();
25$objSess = new SC_Session();
26
27// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
28$objFormParam = new SC_FormParam();
29// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
30lfInitParam();
31
32// ǧ¾Ú²ÄÈݤÎȽÄê
33sfIsSuccess($objSess);
34
35// ¸¡º÷¥Ñ¥é¥á¡¼¥¿¤Î°ú¤­·Ñ¤®
36foreach ($_POST as $key => $val) {
37    if (ereg("^search_", $key)) {
38        $objPage->arrSearchHidden[$key] = $val;
39    }
40}
41
42$objPage->tpl_order_id = $_POST['order_id'];
43
44// DB¤«¤é¼õÃí¾ðÊó¤òÆÉ¤ß¹þ¤à
45lfGetOrderData($_POST['order_id']);
46
47// --¥Æ¥ó¥×¥ì¡¼¥È¡¿¥×¥ë¥À¥¦¥ó¥á¥Ë¥å¡¼¤ÎºîÀ®
48$conn = new SC_DbConn();
49$sql = "SELECT * FROM dtb_mailtemplate WHERE del_flg=0";
50
51$Temp = $conn->getAll($sql);//$Temp¤Ë¼èÆÀ¤·¤¿¥Ç¡¼¥¿¤ò°ì»þŪ¤Ë³ÊǼ
52//¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤Ë½ÐÎϤ¹¤ë¤¿¤á¤ËÆó¼¡¸µÇÛÎó¤ËÂåÆþ¤¹¤ë
53for($i = 0;$i < count($Temp);$i++){
54    $arrTemplate[0][$i] = $Temp[$i]['template_id'];
55    $arrTemplate[1][$i] = $Temp[$i]['template_name'];
56}
57
58//¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤Ø¥Ç¡¼¥¿¤òÂåÆþ
59$objPage->mailTemp = $arrTemplate;
60
61switch($_POST['mode']) {
62case 'pre_edit':
63    break;
64case 'return':
65    // POSTÃͤμèÆÀ
66    $objFormParam->setParam($_POST);
67    break;
68case 'send':
69    // POSTÃͤμèÆÀ
70    $objFormParam->setParam($_POST);
71    // ÆþÎÏÃͤÎÊÑ´¹
72    $objFormParam->convParam();
73    $objPage->arrErr = $objFormParam->checkerror();
74    // ¥á¡¼¥ë¤ÎÁ÷¿®
75    if (count($objPage->arrErr) == 0) {
76        // Ãíʸ¼õÉե᡼¥ë
77        sfSendOrderMail($_POST['order_id'], $_POST['template_id'], $_POST['subject'], $_POST['body']);
78    }
79    header("Location: " . URL_SEARCH_ORDER);
80    exit;
81    break; 
82case 'confirm':
83    // POSTÃͤμèÆÀ
84    $objFormParam->setParam($_POST);
85    // ÆþÎÏÃͤÎÊÑ´¹
86    $objFormParam->convParam();
87    // ÆþÎÏÃͤΰú¤­·Ñ¤®
88    $objPage->arrHidden = $objFormParam->getHashArray();
89    $objPage->arrErr = $objFormParam->checkerror();
90    // ¥á¡¼¥ë¤ÎÁ÷¿®
91    if (count($objPage->arrErr) == 0) {
92        // Ãíʸ¼õÉե᡼¥ë(Á÷¿®¤Ê¤·)
93        $objSendMail = sfSendOrderMail($_POST['order_id'], $_POST['template_id'], $_POST['subject'], $_POST['body'], false);
94        // ³Îǧ¥Ú¡¼¥¸¤Îɽ¼¨
95        $objPage->tpl_subject = $objSendMail->subject;
96        $objPage->tpl_body = mb_convert_encoding( $objSendMail->body, "EUC-JP", "auto" );       
97        $objPage->tpl_to = $objSendMail->tpl_to;
98        $objPage->tpl_mainpage = 'order/mail_confirm.tpl';
99       
100        $objView->assignobj($objPage);
101        $objView->display(MAIN_FRAME);
102       
103        exit;   
104    }
105    break;
106case 'change':
107    // POSTÃͤμèÆÀ
108   
109    $objFormParam->setValue('template_id', $_POST['template_id']);
110   
111    //¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤ÇÁªÂò¤µ¤ì¤¿¥Æ¥ó¥×¥ì¡¼¥È̾¤ò¥Æ¥ó¥×¥ì¡¼¥ÈID¤È´ØÏ¢ÉÕ¤±¤ë
112    $_POST['template_id'] = $arrTemplate[0][$_POST['template_id']];
113    if(sfIsInt($_POST['template_id'])) {
114        $objQuery = new SC_Query();
115        $where = "template_id = ?";
116        $arrRet = $objQuery->select("subject, body", "dtb_mailtemplate", $where, array($_POST['template_id']));
117        $objFormParam->setParam($arrRet[0]);
118    }
119    break;
120}
121
122$objQuery = new SC_Query();
123$col = "send_date, subject, template_id, send_id";
124$where = "order_id = ?";
125$objQuery->setorder("send_date DESC");
126
127if(sfIsInt($_POST['order_id'])) {
128    $objPage->arrMailHistory = $objQuery->select($col, "dtb_mail_history", $where, array($_POST['order_id']));
129}
130
131$objPage->arrForm = $objFormParam->getFormParamList();
132$objView->assignobj($objPage);
133$objView->display(MAIN_FRAME);
134//-----------------------------------------------------------------------------------------------------------------------------------
135/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
136function lfInitParam() {
137    global $objFormParam;
138    $objFormParam->addParam("¥Æ¥ó¥×¥ì¡¼¥È", "template_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
139    $objFormParam->addParam("¥á¡¼¥ë¥¿¥¤¥È¥ë", "subject", STEXT_LEN, "KVa",  array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK"));
140    $objFormParam->addParam("¥Ø¥Ã¥À¡¼", "body", LTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK"));
141    //$objFormParam->addParam("¥Õ¥Ã¥¿¡¼", "footer", LTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK"));
142}
143
144function lfGetOrderData($order_id) {
145    global $objFormParam;
146    global $objPage;
147    if(sfIsInt($order_id)) {
148        // DB¤«¤é¼õÃí¾ðÊó¤òÆÉ¤ß¹þ¤à
149        $objQuery = new SC_Query();
150        $where = "order_id = ?";
151        $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
152        $objFormParam->setParam($arrRet[0]);
153        list($point, $total_point) = sfGetCustomerPoint($order_id, $arrRet[0]['use_point'], $arrRet[0]['add_point']);
154        $objFormParam->setValue('total_point', $total_point);
155        $objFormParam->setValue('point', $point);
156        $objPage->arrDisp = $arrRet[0];
157    }
158}
Note: See TracBrowser for help on using the repository browser.