hxp
2025-06-09 6c3f6335c70859ded94a1ad8d218acb0ac34239c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
include_once "/Account/User.php";
include_once "/Common/Logging.php";
include_once "/Common/CommFunc.php";
include_once "/language/lang.php";
 
\Logging\CreateLogging("AddPersonalCompensation.php");
 
\CommFunc\SessionStart();
$Permission = \User\Permission::P_PersonalMailSend;
$spid = $_SESSION['spid'];
$user = new \User\User($_SESSION['UserAccount']);
if (!$user->HavePermission($Permission)) {
    exit;
}
 
$readTempContent = \CommFunc\GetFileContents("MailTemp\\" . $spid . "_Person.json", "[]");
$mailTempArray = json_decode($readTempContent, true);
$selectTempIndex = -1;
if (array_key_exists('tempIndex', $_GET)) {
    $selectTempIndex = intval($_GET["tempIndex"]);
}
 
$moneyNameInfo = CommFunc\getCfgKeyNameContent("money", true);
$itemIDNameInfo = CommFunc\getCfgKeyNameContent("item", false);
$mailtypes = CommFunc\GetMailTypes();
 
$accID = $_GET["accID"];
$mailTitle = $_GET["mailTitle"];
$mailServerID = $_GET["mailServerID"];
$callName = $_GET["callName"];
 
$tool_page = "";
if ($mailServerID) {
    $serverIDArray = array(intval($mailServerID));
    $serverPageInfo = \CommFunc\GetGameServerPageInfo($spid, $serverIDArray);
    if (count($serverPageInfo) <= 0) {
        exit;
    }
    // 目标角色对应游戏服务器gmtool地址
    $serverPageValues = array_values($serverPageInfo);
    $tool_page = $serverPageValues[0]["Page"];
}
 
// echo print_r($_GET, true), "<br/>";
 
?>
 
<!DOCTYPE html>
<html>
 
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php echo \Lang\gettext("个人邮件"); ?></title>
    <link rel="gettext" type="application/x-po" href="../language/<?php echo \Lang\getLang(); ?>/LC_MESSAGES/<?php echo \Lang\getjspodomain(); ?>.po" />
</head>
 
<body>
 
    <form id="AddPersonalCompensation" name="AddPersonalCompensation" action="/Common/GMCmdProcess.php" method="post">
        <table>
            <caption>
                <p><?php echo \Lang\gettext("个人邮件"); ?></P>
            </caption>
            <tr>
                <td><?php echo \Lang\gettext("模板名称"); ?>:</td>
                <td>
                    <input type="text" name="MailTempName" id="MailTempName" size="50" />
                    <?php
                    $tempCount = count($mailTempArray);
                    echo "<select id='MailTemp' name='MailTemp' onchange='onChangeMailTemp(" . $readTempContent . ", true)'><option value=''>" . \Lang\gettext("选择邮件模板") . "</option>";
                    for ($i = 0; $i < $tempCount; $i++) {
                        $tempInfo = $mailTempArray[$i];
                        echo '<option value ="' . $i . '"';
                        if ($i == $selectTempIndex) {
                            echo 'selected="selected"';
                        }
                        echo '>' .  ($i + 1) . '. ' . $tempInfo["Name"] . '</option>';
                    }
                    echo "</select>";
                    echo '&nbsp;<a href="CompensationTempSend.php">' . \Lang\gettext("模板群发") . '</a>';
                    ?>
                </td>
            </tr>
            <?php
            if ($user->HavePermission(\User\Permission::P_PersonalMailTempMgr, false)) {
                echo "<tr><td></td><td>";
                echo '<input type="submit" name="saveTemp" value="' . \Lang\gettext("保存修改模板") . '" onclick="return onSaveMailTemp()" />';
                echo '&nbsp;<input type="submit" name="delTemp" value="' . \Lang\gettext("删除此模板") . '" onclick="return onDelMailTemp()" />';
                echo '&nbsp;<input type="submit" name="saveNewTemp" value="' . \Lang\gettext("另存为新模板") . '" onclick="return onSaveNewMailTemp()" />';
                echo "</td></tr>";
            }
            ?>
            <tr>
                <td style="text-align: right;"><?php echo \Lang\gettext("发件人"); ?>:</td>
                <td><input type="text" name="Sender" value="" size="20" /></td>
            </tr>
            <tr>
                <td style="text-align: right;"><?php echo \Lang\gettext("收件人"); ?>:</td>
                <td>
                    <input type="radio" name="queryType" value="accID" checked />
                    <span><?php echo \Lang\gettext("按账号"); ?></span>
                    <input type="radio" name="queryType" value="playerName" />
                    <span><?php echo \Lang\gettext("角色名"); ?></span>
                    <input type="radio" name="queryType" value="familyID" />
                    <span><?php echo \Lang\gettext("仙盟"); ?></span>
                    <br />
                    <input type="text" name="playerList" id="playerList" value="<?php echo $accID ?>" size="50" />
                    <span class="tips">(<?php echo \Lang\gettext("多个用英文\",\"隔开如:玩家1,玩家2"); ?>)</span><br />
                    <input type="hidden" name="playerFind" value="0" />
                </td>
            </tr>
            <tr>
                <td><?php echo \Lang\gettext("结束时间"); ?>:</td>
                <td>
                    <?php
                    include_once "/Common/EndTimeSelect.php";
                    ?>
                </td>
            </tr>
            <tr>
                <td><?php echo \Lang\gettext("邮件类型"); ?>: </td>
                <td>
                    <select name="MailType" id="MailType">
                        <?php
                        foreach ($mailtypes as $key => $value) {
                            echo "<option value='" . $key . "'>" . $value . "(" . $key . ")</option>";
                        }
                        ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td><?php echo \Lang\gettext("邮件标题"); ?>:</td>
                <td><input type="text" name="Title" id="Title" size="68" /></td>
            </tr>
            <tr>
                <td><?php echo \Lang\gettext("邮件内容"); ?>:</td>
                <td>
                    <textarea name="Text" id="Text" cols="70" rows="7"></textarea><br />
                    <input type="button" value="<?php echo \Lang\gettext("插入超链接"); ?>" onclick="inserthyperlink('Text');" />
                    <input type="button" value="<?php echo \Lang\gettext("插入界面"); ?>" onclick="insertgameform('Text');" />
                </td>
            </tr>
            <tr>
                <td><?php echo \Lang\gettext("流向记录"); ?>:</td>
                <td>
                    <input type="text" name="Detail" id="Detail" size="68" />(<?php echo \Lang\gettext("使用英文"); ?>)
                </td>
            </tr>
            <tr>
                <td style="text-align: right;"><?php echo $moneyNameInfo["1"]; ?>: </td>
                <td><input type="number" id="Gold" name="Gold" value="" min="0" max="2000000000" /></td>
            </tr>
            <tr>
                <td style="text-align: right;"><?php echo $moneyNameInfo["2"]; ?>: </td>
                <td><input type="number" id="GoldPaper" name="GoldPaper" value="" min="0" max="2000000000" /></td>
            </tr>
            <tr>
                <td style="text-align: right;"><?php echo $moneyNameInfo["3"]; ?>: </td>
                <td><input type="number" id="Silver" name="Silver" value="" min="0" max="2000000000" /></td>
            </tr>
            <tr>
                <td><?php echo \Lang\gettext("邮件物品"); ?>:</td>
                <td>
                    <div id="itemContent"></div>
                    <input type="hidden" name="itemNums" id="itemNums" value="" />
                    <a href="javascript:AddItemHtml();"><?php echo \Lang\gettext("添加邮件物品"); ?></a>
                </td>
            </tr>
        </table>
        <hr>
        <input type="hidden" name="Permission" value="<?php echo $Permission; ?>" />
        <input type="hidden" name="pack_type" id="pack_type" value="GMT_AddPersonalCompensation" />
        <input type="hidden" name="tool_page" value="<?php echo $tool_page; ?>" />
        <input type="hidden" id="processType" name="processType" value="" />
        <?php
        if ($user->NeedCheckKey()) {
            echo \Lang\gettext("授权码(key)") . ":";
            echo "<input type=\"text\" name=\"key\" id=\"key\" />";
        } else {
            echo "<input type=\"hidden\" name=\"key\" id=\"key\" />";
        }
        ?>
        <p />
        <input type="submit" name="submit" value="<?php echo \Lang\gettext("提交"); ?>" onclick="return CheckSubmit()" /><br />
        <hr>
    </form>
 
    <script type='text/javascript' src='/language/gettext.js'></script>
    <script type='text/javascript' src="/js/calendar.js"></script>
    <script type='text/javascript' src="/js/common.js"></script>
    <script language='javascript' src='compensationitem.js' type='text/javascript'></script>
    <script language='javascript' src='compensationTemp.js' type='text/javascript'></script>
    <script type="text/javascript">
        window.onload = function() {
            onChangeMailTemp(<?php echo $readTempContent; ?>, false);
            var mailTitle = "<?php echo $mailTitle; ?>";
            if (mailTitle) {
                document.getElementById("Title").value = mailTitle;
            }
 
            var callName = "<?php echo $callName; ?>";
            if (callName == "BugReport") {
                document.getElementById("processType").value = "JustRet";
                document.getElementById('AddPersonalCompensation').addEventListener('submit', function(event) {
                    event.preventDefault(); // 阻止表单默认提交行为
                    handleFormSubmit(); // 调用处理函数
                });
            }
        }
 
        function handleFormSubmit() {
            // console.log('handleFormSubmit');
            var callName = "<?php echo $callName; ?>";
            // console.log('callName:' + callName);
 
            var thisform = document.getElementById('AddPersonalCompensation');
            // 发送POST请求
            fetch(thisform.action, {
                    method: 'POST',
                    body: new FormData(thisform)
                })
                .then(response => response.json())
                .then(data => {
                    console.log(data);
                    if (data["ProcessRetCode"] == 0 && data["ErrorMsg"].length == 0) {
                        console.log("Success");
                        alert("发送成功");
                        if (callName == "BugReport") {
                            var repID = "<?php echo $_GET["repID"]; ?>";
                            var iframe_bugreport = window.parent.frames['iframe_bugreport'];
                            iframe_bugreport.mailReplyOK(repID, getMailInfo());
                        }
                    } else {
                        alert("发送失败");
                    }
                })
                .catch(error => {
                    alert("出错啦~");
                    console.error(error)
                });
        }
 
        function onItemIDChange(num, value) {
            var itemIDNameInfo = <?php echo $itemIDNameInfo; ?>;
            var itemName = "<font color='red'><?php echo \Lang\gettext("未知物品ID"); ?></font>";
            if (itemIDNameInfo[value]) {
                itemName = itemIDNameInfo[value];
            }
            document.getElementById("ItemName" + num).innerHTML = itemName;
        }
    </script>
</body>
 
</html>