| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 4 | * |
|---|
| 5 | * http://www.lockon.co.jp/ |
|---|
| 6 | */ |
|---|
| 7 | require_once("../require.php"); |
|---|
| 8 | |
|---|
| 9 | // ǧ¾Ú²ÄÈݤÎȽÄê |
|---|
| 10 | sfIsSuccess(new SC_Session()); |
|---|
| 11 | |
|---|
| 12 | // order_id¤Î¸¡¾Ú |
|---|
| 13 | if (lfIsValidOrderID() !== true) { |
|---|
| 14 | sfDispError(''); |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | class LC_Page { |
|---|
| 18 | var $arrMAILTEMPLATE; |
|---|
| 19 | |
|---|
| 20 | function LC_Page() { |
|---|
| 21 | $this->tpl_mainpage = 'order/mail.tpl'; |
|---|
| 22 | $this->tpl_subnavi = 'order/subnavi.tpl'; |
|---|
| 23 | $this->tpl_mainno = 'order'; |
|---|
| 24 | $this->tpl_subno = 'index'; |
|---|
| 25 | $this->tpl_subtitle = '¼õÃí´ÉÍý'; |
|---|
| 26 | } |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | $objPage = new LC_Page(); |
|---|
| 30 | $objView = new SC_AdminView(); |
|---|
| 31 | $objFormParam = new SC_FormParam(); |
|---|
| 32 | |
|---|
| 33 | // ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ |
|---|
| 34 | lfInitParam(); |
|---|
| 35 | |
|---|
| 36 | // ¸¡º÷¥Ñ¥é¥á¡¼¥¿¤Î°ú¤·Ñ¤® |
|---|
| 37 | foreach ($_POST as $key => $val) { |
|---|
| 38 | if (ereg("^search_", $key)) { |
|---|
| 39 | $objPage->arrSearchHidden[$key] = $val; |
|---|
| 40 | } |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | $objPage->tpl_order_id = $_POST['order_id']; |
|---|
| 44 | |
|---|
| 45 | // DB¤«¤é¼õÃí¾ðÊó¤òÆÉ¤ß¹þ¤à |
|---|
| 46 | lfGetOrderData($_POST['order_id']); |
|---|
| 47 | |
|---|
| 48 | //¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤Ø¥Ç¡¼¥¿¤òÂåÆþ |
|---|
| 49 | $objPage->arrMAILTEMPLATE = lfCreateTemplateList(); |
|---|
| 50 | |
|---|
| 51 | $mode = isset($_POST['mode']) ? $_POST['mode'] : ''; |
|---|
| 52 | switch($mode) { |
|---|
| 53 | // ¼õÃí¸¡º÷¤«¤é¤ÎÁ«°Ü |
|---|
| 54 | case 'pre_edit': |
|---|
| 55 | break; |
|---|
| 56 | // ³Îǧ²èÌ̤«¤éÌá¤ë. |
|---|
| 57 | case 'return': |
|---|
| 58 | // POSTÃͤμèÆÀ |
|---|
| 59 | $objFormParam->setParam($_POST); |
|---|
| 60 | break; |
|---|
| 61 | case 'send': |
|---|
| 62 | // POSTÃͤμèÆÀ |
|---|
| 63 | $objFormParam->setParam($_POST); |
|---|
| 64 | // ÆþÎÏÃͤÎÊÑ´¹ |
|---|
| 65 | $objFormParam->convParam(); |
|---|
| 66 | $objPage->arrErr = $objFormParam->checkerror(); |
|---|
| 67 | // ¥á¡¼¥ë¤ÎÁ÷¿® |
|---|
| 68 | if (count($objPage->arrErr) == 0) { |
|---|
| 69 | // Ãíʸ¼õÉե᡼¥ë |
|---|
| 70 | sfSendOrderMail($_POST['order_id'], $_POST['template_id'], $_POST['subject'], $_POST['body']); |
|---|
| 71 | } |
|---|
| 72 | header("Location: " . URL_SEARCH_ORDER); |
|---|
| 73 | exit; |
|---|
| 74 | break; |
|---|
| 75 | case 'confirm': |
|---|
| 76 | // POSTÃͤμèÆÀ |
|---|
| 77 | $objFormParam->setParam($_POST); |
|---|
| 78 | // ÆþÎÏÃͤÎÊÑ´¹ |
|---|
| 79 | $objFormParam->convParam(); |
|---|
| 80 | // ÆþÎÏÃͤΰú¤·Ñ¤® |
|---|
| 81 | $objPage->arrHidden = $objFormParam->getHashArray(); |
|---|
| 82 | $objPage->arrErr = $objFormParam->checkerror(); |
|---|
| 83 | // ¥á¡¼¥ë¤ÎÁ÷¿® |
|---|
| 84 | if (count($objPage->arrErr) == 0) { |
|---|
| 85 | // Ãíʸ¼õÉե᡼¥ë(Á÷¿®¤Ê¤·) |
|---|
| 86 | $objSendMail = sfSendOrderMail($_POST['order_id'], $_POST['template_id'], $_POST['subject'], $_POST['body'], false); |
|---|
| 87 | // ³Îǧ¥Ú¡¼¥¸¤Îɽ¼¨ |
|---|
| 88 | $objPage->tpl_subject = $objSendMail->subject; |
|---|
| 89 | $objPage->tpl_body = mb_convert_encoding( $objSendMail->body, "EUC-JP", "auto" ); |
|---|
| 90 | $objPage->tpl_to = $objSendMail->tpl_to; |
|---|
| 91 | $objPage->tpl_mainpage = 'order/mail_confirm.tpl'; |
|---|
| 92 | |
|---|
| 93 | $objView->assignobj($objPage); |
|---|
| 94 | $objView->display(MAIN_FRAME); |
|---|
| 95 | |
|---|
| 96 | exit; |
|---|
| 97 | } |
|---|
| 98 | break; |
|---|
| 99 | case 'change': |
|---|
| 100 | $objFormParam->setValue('template_id', $_POST['template_id']); |
|---|
| 101 | |
|---|
| 102 | if(sfIsInt($_POST['template_id'])) { |
|---|
| 103 | $objQuery = new SC_Query(); |
|---|
| 104 | $where = "template_id = ?"; |
|---|
| 105 | $arrRet = $objQuery->select("subject, body", "dtb_mailtemplate", $where, array($_POST['template_id'])); |
|---|
| 106 | $objFormParam->setParam($arrRet[0]); |
|---|
| 107 | } |
|---|
| 108 | break; |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | if(sfIsInt($_POST['order_id'])) { |
|---|
| 112 | $objPage->arrMailHistory = lfGetMailHistory($_POST['order_id']); |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | $objPage->arrForm = $objFormParam->getFormParamList(); |
|---|
| 116 | $objView->assignObj($objPage); |
|---|
| 117 | $objView->display(MAIN_FRAME); |
|---|
| 118 | //----------------------------------------------------------------------------------------------------------------------------------- |
|---|
| 119 | /* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */ |
|---|
| 120 | function lfInitParam() { |
|---|
| 121 | global $objFormParam; |
|---|
| 122 | $objFormParam->addParam("¥Æ¥ó¥×¥ì¡¼¥È", "template_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); |
|---|
| 123 | $objFormParam->addParam("¥á¡¼¥ë¥¿¥¤¥È¥ë", "subject", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK")); |
|---|
| 124 | $objFormParam->addParam("ËÜʸ", "body", LTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "SPTAB_CHECK")); |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | function lfGetOrderData($order_id) { |
|---|
| 128 | global $objFormParam; |
|---|
| 129 | global $objPage; |
|---|
| 130 | if(sfIsInt($order_id)) { |
|---|
| 131 | // DB¤«¤é¼õÃí¾ðÊó¤òÆÉ¤ß¹þ¤à |
|---|
| 132 | $objQuery = new SC_Query(); |
|---|
| 133 | $where = "order_id = ?"; |
|---|
| 134 | $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id)); |
|---|
| 135 | $objFormParam->setParam($arrRet[0]); |
|---|
| 136 | list($point, $total_point) = sfGetCustomerPoint($order_id, $arrRet[0]['use_point'], $arrRet[0]['add_point']); |
|---|
| 137 | $objFormParam->setValue('total_point', $total_point); |
|---|
| 138 | $objFormParam->setValue('point', $point); |
|---|
| 139 | $objPage->arrDisp = $arrRet[0]; |
|---|
| 140 | } |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | /** |
|---|
| 144 | * POST¤µ¤ì¤ëorder_id¤ò¸¡¾Ú¤¹¤ë. |
|---|
| 145 | * |
|---|
| 146 | * @param void |
|---|
| 147 | * @return boolean |
|---|
| 148 | */ |
|---|
| 149 | function lfIsValidOrderID() { |
|---|
| 150 | if (isset($_POST['order_id']) && sfIsint($_POST['order_id'])) { |
|---|
| 151 | return true; |
|---|
| 152 | } |
|---|
| 153 | return false; |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | /** |
|---|
| 157 | * ¥Æ¥ó¥×¥ì¡¼¥È¥×¥ë¥À¥¦¥ó¥á¥Ë¥å¡¼¤ÎÇÛÎó¤òºîÀ®¤¹¤ë. |
|---|
| 158 | * array( |
|---|
| 159 | * array(template_id => template_name), |
|---|
| 160 | * array(template_id => template_name), |
|---|
| 161 | * ... |
|---|
| 162 | * ) |
|---|
| 163 | * |
|---|
| 164 | * @param void |
|---|
| 165 | * @return array |
|---|
| 166 | */ |
|---|
| 167 | function lfCreateTemplateList() { |
|---|
| 168 | $objQuery = new SC_Query; |
|---|
| 169 | $objQuery->setOrder('template_id ASC'); |
|---|
| 170 | $arrTemp = $objQuery->select('template_id, template_name', 'dtb_mailtemplate', 'del_flg = 0'); |
|---|
| 171 | |
|---|
| 172 | $arrRet = array(); |
|---|
| 173 | foreach($arrTemp as $val) { |
|---|
| 174 | $arrRet[$val['template_id']] = $val['template_name']; |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | return $arrRet; |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | /** |
|---|
| 181 | * ¥á¡¼¥ëÇÛ¿®ÍúÎò¤ò¼èÆÀ¤¹¤ë. |
|---|
| 182 | * |
|---|
| 183 | * @param integer $order_id |
|---|
| 184 | * @return array |
|---|
| 185 | */ |
|---|
| 186 | function lfGetMailHistory($order_id) { |
|---|
| 187 | $cols = "send_date, subject, template_id, send_id"; |
|---|
| 188 | $where = "order_id = ?"; |
|---|
| 189 | $objQuery = new SC_Query(); |
|---|
| 190 | $objQuery->setorder("send_date DESC"); |
|---|
| 191 | |
|---|
| 192 | $arrRet = $objQuery->select($cols, "dtb_mail_history", $where, array($order_id)); |
|---|
| 193 | return $arrRet; |
|---|
| 194 | } |
|---|