<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
//
$sql2 = "select * from system_user where person_id='$_SESSION[login_user_id]' ";
$dbquery2 = mysqli_query($connect,$sql2);
$result2 = mysqli_fetch_array($dbquery2);
$token_line = $result2['token_line'];
//
if(isset($_POST['newtoken_line'])){
$newtoken_line = trim($_POST['newtoken_line']);
//$newemail = md5($newemail);
$sql = "update system_user set token_line = '$newtoken_line' where person_id = '$_SESSION[login_user_id]' ";
$dbquery = mysqli_query($connect,$sql);
$sql=$sql = "select * from system_user where token_line = '$newtoken_line' and person_id='$_SESSION[login_user_id]' ";
$dbquery = mysqli_query($connect,$sql);
$result = mysqli_fetch_array($dbquery);
if($result){
echo "<script>alert('เปลี่ยน Token LINE เรียบร้อยแล้ว'); document.location.href='index.php';</script>";
exit();
}
else {
echo "<script>alert('เกิดปัญหาบางอย่าง ไม่สามารถเปลี่ยน Token LINE ใหม่ได้'); document.location.href='index.php';</script>";
exit();
}
}
?>
<form id="frm1" name="frm1">
<table cellpadding='5' cellspacing='5' align='center' class='row2' border=0 width=50%>
<tr><td colspan='2' align=center><br><font size='4'>เปลี่ยน Token LINE</td></tr>
<?php if($token_line >''){ ?>
<tr><td colspan='2' align=center><font size='2'><b>Token LINE เดิม คือ <font size='2' color='#FF0000'><?php echo $token_line ?></font></td></tr>
<?php } ?>
<?php if($token_line ==''){ ?>
<tr><td colspan='2' align=center><font size='2'><b><font size='2' color='#FF0000'>ยังไม่มี Token ของท่านในระบบ</font></td></tr>
<?php } ?>
<tr>
<td align='right'><b>Token ใหม่ </td><td align='left'><input type="text" name="newtoken_line" Size="50"/></td>
</tr>
<tr>
<td align='right'><b>Token ใหม่ (อีกครั้ง) </td><td align='left'><input type="text" name="renewtoken_line" Size="50"/></td>
</tr>
<tr align="center"><td colspan="2" align="center"><input type="button" value="ตกลง" onclick="goto_url(1)"> <INPUT TYPE="button" name="back" value="ย้อนกลับ" onclick="goto_url(0)"></td></tr>
</table>
</form>
<?php
echo "<center>";
echo "<hr size=1 width=45%>";
echo "<font size=3 color=#ff8000><strong>คำอธิบาย</strong></font>";
echo "<table width=60%>";
echo "<tr><td>";
echo "<b>สร้าง Token สำหรับการ LINE Notify</b>";
echo "<ol>";
echo "<li>Login เข้าที่ Link <a href='https://notify-bot.line.me/th/' target='_blank'><font color=blue>https://notify-bot.line.me/th/</font></a></li>";
echo "<li>My Page /หรือ หน้าของฉัน</li>";
echo "<li>เลื่อนลงมาด้านล่างคลิกที่ Generate Token /หรือ ออก Token</li>";
echo "<li>Copy /หรือ คัดลอก แล้วนำกลับมาวางในช่อง <font color=#ff00ff><b>Token ใหม่</b></font> ทั้ง 2 ช่อง</li>";
echo "</ol>";
echo "</td></tr>";
echo "<tr><td>";
echo "<b>คู่มือ <a href='modules/defualt/manual/TokenLineNotify.pdf' target='_blank'>set up Token LINE Notify</a></b>";
echo "</td></tr>";
echo "<tr><td>";
echo "<hr>";
echo "ความสามารถของ Line Notify มีดังนี้
<li>ส่ง Notification มายังตัวเราเอง</li>
<li>ส่ง Notification ไปยัง Line Group ที่เราอยู่ (ทั้งนี้เราต้องเพิ่ม LINE Notify เข้ามาใน LINE Group นั้นด้วย)</li>
<li>ส่ง ข้อความ Text, รูปภาพ และ Sticker ได้</li>";
echo "</td></tr>";
echo "</table>";
echo "</center>";
?>
<script>
function goto_url(val){
if(val==0){
callfrm("./"); // page ย้อนกลับ
}else if(val==1){
if(frm1.newtoken_line.value==''){
alert('กรุณากรอก Token ใหม่ที่ต้องการ');
}else if(frm1.renewtoken_line.value==''){
alert('กรุณากรอกยืนยัน Token ใหม่');
}else if(frm1.newtoken_line.value!=frm1.renewtoken_line.value){
alert("Token สองครั้งไม่ตรงกัน");
}else{
callfrm("?file=user_change_token"); //page ประมวลผล
}
}
}
</script>