| <?php | 
| include_once "/Account/User.php"; | 
| include_once "/Common/Logging.php"; | 
| include_once "/Common/CommFunc.php"; | 
| include_once "/language/lang.php"; | 
|   | 
| \Logging\CreateLogging("CompensationTempSend.php"); | 
|   | 
| $UserAccount = $_SESSION['UserAccount']; | 
| $user = new \User\User($UserAccount); | 
|   | 
| $spID = $user->GetSPID(); | 
| $readTempContent = \CommFunc\GetFileContents("MailTemp/" . $spID . "_Person.json", "[]"); | 
| // $mailTempArray = json_decode($readTempContent, true); | 
|   | 
| $moneyNameInfo = CommFunc\getCfgKeyNameContent("money", true); | 
| $itemIDNameInfo = CommFunc\getCfgKeyNameContent("item", false); | 
|   | 
| ?> | 
|   | 
| <!DOCTYPE html> | 
| <html> | 
| <style> | 
|     /*设置p标签上下间距为1px,左右为0 */ | 
|     p { | 
|         margin: 1px 0; | 
|     } | 
| </style> | 
|   | 
| <head> | 
|     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | 
|     <title><?php echo \Lang\gettext("个人邮件-群发"); ?></title> | 
| </head> | 
|   | 
| <body> | 
|   | 
|     <center> | 
|         <p><?php echo \Lang\gettext("个人邮件-群发"); ?></P> | 
|     </center> | 
|   | 
|     <form id="CompensationTempSend" name="CompensationTempSend" action="CompensationTempSendMulti.php" method="post"> | 
|         <div id="TempSendHtml"></div> | 
|         <input type="hidden" name="massSendMaxNum" id="massSendMaxNum" value="" /> | 
|         <hr /> | 
|         <input type="button" value="<?php echo \Lang\gettext("添加邮件"); ?>" onclick="addTempHtml()" /> | 
|         <input type="button" value="<?php echo \Lang\gettext("显隐邮件明细"); ?>" onclick="changeMailDetailDisplay()" /> | 
|         <br /> | 
|         <hr /> | 
|         <p> | 
|             <?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\" />"; | 
|             } | 
|             ?> | 
|             <input type="submit" name="submit" value="<?php echo \Lang\gettext("提交"); ?>" onclick="return CheckTempSend()" /><br /> | 
|         </p> | 
|         <hr /> | 
|     </form> | 
|     <script src="/js/calendar.js"></script> | 
|     <script language='javascript' src='compensationTemp.js' type='text/javascript'></script> | 
|     <script type="text/javascript"> | 
|         window.onload = function() { | 
|             // 默认两个 | 
|             addPersonTempSendHtml(<?php echo $readTempContent; ?>); | 
|             addPersonTempSendHtml(<?php echo $readTempContent; ?>); | 
|         } | 
|   | 
|         function addTempHtml() { | 
|             addPersonTempSendHtml(<?php echo $readTempContent; ?>); | 
|         } | 
|   | 
|         var massSendNum = -1; // 群发邮件编号 | 
|         function CheckTempSend() { | 
|             var massSendMaxNum = parseInt(document.getElementById("massSendMaxNum").value); | 
|             for (let num = 0; num <= massSendMaxNum; num++) { | 
|                 if (!document.getElementById("send" + num)) { | 
|                     continue; | 
|                 } | 
|   | 
|                 if (!document.getElementById("playerList" + num).value) { | 
|                     alert("<?php echo \Lang\gettext("玩家不能为空"); ?>!"); | 
|                     document.getElementById("playerList" + num).focus(); | 
|                     return false; | 
|                 } | 
|   | 
|                 if (document.getElementById("MailTemp" + num).value == "") { | 
|                     alert("<?php echo \Lang\gettext("需选择邮件模板"); ?>!"); | 
|                     document.getElementById("MailTemp" + num).focus(); | 
|                     return false; | 
|                 } | 
|             } | 
|   | 
|             if (document.getElementById("key").type != "hidden" && !document.getElementById("key").value) { | 
|                 alert("<?php echo \Lang\gettext("请输入授权码!"); ?>"); | 
|                 return false; | 
|             } | 
|   | 
|             if (!confirm("<?php echo \Lang\gettext("请检查模板详情内容是否正确!确认无误并发送?"); ?>")) { | 
|                 return false; | 
|             } | 
|   | 
|             return true; | 
|         } | 
|   | 
|         // 添加个人模板群发 html | 
|         function addPersonTempSendHtml(tempInfo) { | 
|             if (!tempInfo) { | 
|                 alert("<?php echo \Lang\gettext("无模板内容"); ?>!"); | 
|                 return | 
|             } | 
|   | 
|             massSendNum++; | 
|   | 
|             var insHtml = ""; | 
|             insHtml += "<div id=\"send" + massSendNum + "\">"; | 
|             insHtml += "<hr/>"; | 
|             insHtml += "<input type=\"radio\" id=\"queryType" + massSendNum + "\" name=\"queryType" + massSendNum + "\" value=\"accID\" checked /><?php echo \Lang\gettext("按账号"); ?>"; | 
|             insHtml += "<input type=\"radio\" id=\"queryType" + massSendNum + "\" name=\"queryType" + massSendNum + "\" value=\"playerName\" /><?php echo \Lang\gettext("角色名"); ?>"; | 
|             insHtml += "<input type=\"radio\" id=\"queryType" + massSendNum + "\" name=\"queryType" + massSendNum + "\" value=\"familyID\" /><?php echo \Lang\gettext("仙盟"); ?>"; | 
|             insHtml += "  <input type=\"text\" id=\"playerList" + massSendNum + "\" name=\"playerList" + massSendNum + "\" value=\"\" size=\"50\" />"; | 
|             insHtml += "<a href=\"javascript:delPersonTempSendHtml(" + massSendNum + ")\"><?php echo \Lang\gettext("删除"); ?></a>"; | 
|   | 
|             insHtml += "<br/>"; | 
|             insHtml += "<select id='MailTemp" + massSendNum + "' name='MailTemp" + massSendNum + "' onchange='selectTemp(" + massSendNum + ", this.selectedIndex)'>"; | 
|             insHtml += "    <option value=''><?php echo \Lang\gettext("选择邮件模板"); ?></option>"; | 
|             for (let index = 0; index < tempInfo.length; index++) { | 
|                 const temp = tempInfo[index]; | 
|                 insHtml += "    <option value='" + index + "'>" + temp["Name"] + "</option>"; | 
|             } | 
|             insHtml += "</select>"; | 
|             insHtml += "<br/>"; | 
|   | 
|             // 邮件明细 | 
|             insHtml += "    <div id=\"mailDetail" + massSendNum + "\" style=\"text-indent:2em;font-size:14px;\">"; | 
|             // ... 由  onSelectTemp 触发改变明细内容 | 
|             insHtml += "    </div>"; | 
|   | 
|             insHtml += "<br/>"; | 
|             insHtml += "</div>"; | 
|   | 
|             document.getElementById("TempSendHtml").insertAdjacentHTML("beforeEnd", insHtml); | 
|             // 更新群发最大编号 | 
|             document.getElementById("massSendMaxNum").value = massSendNum; | 
|         } | 
|   | 
|         function selectTemp(num, selectIndex) { | 
|             onSelectTemp(num, selectIndex, <?php echo $readTempContent; ?>); | 
|         } | 
|   | 
|         // 选择群发模板 | 
|         function onSelectTemp(num, selectIndex, tempInfo) { | 
|             var tempIndex = selectIndex - 1; | 
|             var innerHTML = ""; | 
|             if (tempIndex >= 0) { | 
|                 var temp = tempInfo[tempIndex] | 
|                 innerHTML += "<p><?php echo \Lang\gettext("结束时间"); ?>: " + sumDateByDays(temp.EndDays) + " 00:00:00</p>"; | 
|                 innerHTML += "<p><?php echo \Lang\gettext("标题"); ?>: " + temp.Title + "</p>"; | 
|                 innerHTML += "<p><?php echo \Lang\gettext("内容"); ?>: " + temp.Text + "</p>"; | 
|                 innerHTML += "<p><?php echo $moneyNameInfo["1"]; ?>: <font color=\"red\"><b>" + temp.Gold + "</b></font>" + | 
|                     "  <?php echo $moneyNameInfo["2"]; ?>: <font color=\"blue\"><b>" + temp.GoldPaper + "</b></font>" + | 
|                     "  <?php echo $moneyNameInfo["3"]; ?>: <font><b>" + temp.Silver + "</b></font>" + | 
|                     "</p>"; | 
|                 // innerHTML += "物品: "; | 
|                 var itemIDNameInfo = <?php echo $itemIDNameInfo; ?>; | 
|                 for (let index = 0; index < temp.Items.length; index++) { | 
|                     const itemInfo = temp.Items[index]; | 
|                     var itemName = itemIDNameInfo[itemInfo[0]]; | 
|                     if (itemName) { | 
|                         innerHTML += "<p><?php echo \Lang\gettext("物品ID"); ?>: <font color=\"blue\"><b>" + itemName + "(" + itemInfo[0] + ")" + "</b></font>"; | 
|                     } else { | 
|                         innerHTML += "<p><?php echo \Lang\gettext("物品ID"); ?>: <font color=\"red\"><b><?php echo \Lang\gettext("未知物品ID"); ?>(" + itemInfo[0] + ")" + "</b></font>"; | 
|                     } | 
|                     innerHTML += " x <b>" + itemInfo[1] + "</b><?php echo \Lang\gettext("个"); ?>"; | 
|                     if (itemInfo[2]) { | 
|                         innerHTML += " (<?php echo \Lang\gettext("拍品"); ?>)"; | 
|                     } | 
|                     innerHTML += "</p>"; | 
|                 } | 
|             } | 
|             document.getElementById("mailDetail" + num).innerHTML = innerHTML; | 
|         } | 
|   | 
|         // 显隐 邮件内容明细 | 
|         function changeMailDetailDisplay() { | 
|             var display = null; | 
|             for (let num = 0; num < massSendNum + 1; num++) { | 
|                 const detailDiv = document.getElementById("mailDetail" + num); | 
|                 if (!detailDiv) { | 
|                     continue | 
|                 } | 
|                 if (display == null) { | 
|                     if (detailDiv.style.display == "") { | 
|                         display = "none"; // 隐 | 
|                     } else { | 
|                         display = ""; // 显 | 
|                     } | 
|                 } | 
|                 detailDiv.style.display = display; | 
|             } | 
|         } | 
|   | 
|         // 删除个人模板群发 html | 
|         function delPersonTempSendHtml(delNum) { | 
|             document.getElementById("TempSendHtml").removeChild(document.getElementById("send" + delNum)); | 
|         } | 
|     </script> | 
| </body> | 
|   | 
| </html> |