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

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