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

Revision 13907, 4.6 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 template_name FROM dtb_mailtemplate WHERE del_flg=0";
50$arrTemp = $conn->getAll($sql);
51
52for($i = 0;$i < count($arrTemp);$i++){
53    $arrTemp[$i] = $arrTemp[$i]['template_name'];
54}
55
56$objPage->arrMAILTEMPLATE = $arrTemp;
57
58switch($_POST['mode']) {
59case 'pre_edit':
60    break;
61case 'return':
62    // POSTÃͤμèÆÀ
63    $objFormParam->setParam($_POST);
64    break;
65case 'send':
66    // POSTÃͤμèÆÀ
67    $objFormParam->setParam($_POST);
68    // ÆþÎÏÃͤÎÊÑ´¹
69    $objFormParam->convParam();
70    $objPage->arrErr = $objFormParam->checkerror();
71    // ¥á¡¼¥ë¤ÎÁ÷¿®
72    if (count($objPage->arrErr) == 0) {
73        // Ãíʸ¼õÉե᡼¥ë
74        sfSendOrderMail($_POST['order_id'], $_POST['template_id'], $_POST['subject'], $_POST['header'], $_POST['footer']);
75    }
76    header("Location: " . URL_SEARCH_ORDER);
77    exit;
78    break; 
79case 'confirm':
80    // POSTÃͤμèÆÀ
81    $objFormParam->setParam($_POST);
82    // ÆþÎÏÃͤÎÊÑ´¹
83    $objFormParam->convParam();
84    // ÆþÎÏÃͤΰú¤­·Ñ¤®
85    $objPage->arrHidden = $objFormParam->getHashArray();
86    $objPage->arrErr = $objFormParam->checkerror();
87    // ¥á¡¼¥ë¤ÎÁ÷¿®
88    if (count($objPage->arrErr) == 0) {
89        // Ãíʸ¼õÉե᡼¥ë(Á÷¿®¤Ê¤·)
90        $objSendMail = sfSendOrderMail($_POST['order_id'], $_POST['template_id'], $_POST['subject'], $_POST['header'], $_POST['footer'], false);
91        // ³Îǧ¥Ú¡¼¥¸¤Îɽ¼¨
92        $objPage->tpl_subject = $objSendMail->subject;
93        $objPage->tpl_body = mb_convert_encoding( $objSendMail->body, "EUC-JP", "auto" );       
94        $objPage->tpl_to = $objSendMail->tpl_to;
95        $objPage->tpl_mainpage = 'order/mail_confirm.tpl';
96       
97        $objView->assignobj($objPage);
98        $objView->display(MAIN_FRAME);
99       
100        exit;   
101    }
102    break;
103case 'change':
104    // POSTÃͤμèÆÀ
105    $objFormParam->setValue('template_id', $_POST['template_id']);
106    if(sfIsInt($_POST['template_id'])) {
107        $objQuery = new SC_Query();
108        $where = "template_id = ?";
109        $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($_POST['template_id']));
110        print_r($arrRet);exit;
111        $objFormParam->setParam($arrRet[0]);
112    }
113    break;
114}
115
116$objQuery = new SC_Query();
117$col = "send_date, subject, template_id, send_id";
118$where = "order_id = ?";
119$objQuery->setorder("send_date DESC");
120
121if(sfIsInt($_POST['order_id'])) {
122    $objPage->arrMailHistory = $objQuery->select($col, "dtb_mail_history", $where, array($_POST['order_id']));
123}
124
125$objPage->arrForm = $objFormParam->getFormParamList();
126$objView->assignobj($objPage);
127$objView->display(MAIN_FRAME);
128//-----------------------------------------------------------------------------------------------------------------------------------
129/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
130function lfInitParam() {
131    global $objFormParam;
132    $objFormParam->addParam("¥Æ¥ó¥×¥ì¡¼¥È", "template_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
133    $objFormParam->addParam("¥á¡¼¥ë¥¿¥¤¥È¥ë", "subject", STEXT_LEN, "KVa",  array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK"));
134    $objFormParam->addParam("¥Ø¥Ã¥À¡¼", "header", LTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK"));
135    $objFormParam->addParam("¥Õ¥Ã¥¿¡¼", "footer", LTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK"));
136}
137
138function lfGetOrderData($order_id) {
139    global $objFormParam;
140    global $objPage;
141    if(sfIsInt($order_id)) {
142        // DB¤«¤é¼õÃí¾ðÊó¤òÆÉ¤ß¹þ¤à
143        $objQuery = new SC_Query();
144        $where = "order_id = ?";
145        $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
146        $objFormParam->setParam($arrRet[0]);
147        list($point, $total_point) = sfGetCustomerPoint($order_id, $arrRet[0]['use_point'], $arrRet[0]['add_point']);
148        $objFormParam->setValue('total_point', $total_point);
149        $objFormParam->setValue('point', $point);
150        $objPage->arrDisp = $arrRet[0];
151    }
152}
Note: See TracBrowser for help on using the repository browser.