Forked from apivat60/เว็บแอปแจ้งคิว+ไลน์ 21 พ.ย.63
Created
November 23, 2020 02:23
-
-
Save k2003/d4791f46af9a93e4821bd022269bdc5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| สูตรรันเลขคิวอัตโนมัติ | |
| ={"ลำดับคิว";ARRAYFORMULA ("Q" & text (ROW (B1:INDEX (B:B, COUNTA (B:B)-1)), "000"))} | |
| ------------ | |
| โค้ด.gs | |
| ------------- | |
| var data | |
| var ss = SpreadsheetApp.openById('aaa') | |
| var sheet = ss.getSheetByName('aaa') | |
| var range = sheet.getDataRange().getDisplayValues() | |
| function doGet(e) { | |
| var qid = e.parameter.qid | |
| var html = HtmlService.createTemplateFromFile('index') | |
| data = { result: 'result', range: range } | |
| html.data = JSON.stringify(data) | |
| return html.evaluate() | |
| } | |
| function sendNotify(queue) { | |
| var result = '' | |
| var msg = '' | |
| var token = 'aaa' | |
| for (var i = 1; i < range.length; i++) { | |
| if (range[i][1] == queue) { | |
| msg = '📣 ขอเชิญคิว..ลำดับที่ : '+range[i][3]+' คุณ: '+range[i][1] + ' 👆 ️เข้ารับบริการค่ะ' | |
| var options = { | |
| "method": "post", | |
| "payload": "message=" + msg, | |
| "headers": { | |
| "Authorization": "Bearer " + token | |
| } | |
| }; | |
| UrlFetchApp.fetch("https://notify-api.line.me/api/notify", options); | |
| result = 'success' | |
| } else { | |
| result = 'fail' | |
| } | |
| } | |
| return result | |
| } | |
| ------------- | |
| html | |
| ------------- | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <base target="_top" /> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport"content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | |
| <!-- Bootstrap CSS --> | |
| <link | |
| rel="stylesheet" | |
| href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" | |
| integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" | |
| crossorigin="anonymous" | |
| /> | |
| <script | |
| src="https://code.jquery.com/jquery-3.5.1.min.js" | |
| integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" | |
| crossorigin="anonymous" | |
| ></script> | |
| </head> | |
| <body> | |
| <nav class="navbar navbar-dark bg-primary"> | |
| <span class="navbar-brand mb-0 h1">🙋♂️ระบบคิว การให้คำปรึกษาจากครูอภิวัฒน์"สอนสร้างสื่อ"</span> | |
| <img src="https://drive.google.com/uc?export=view&id=1PO_CTljdmsnvVnbcWnquVsfu-vSlh-yx" width="60" height="60" alt="" loading="lazy"> | |
| </nav> | |
| <div class="container-fluid"> | |
| <table class="table" table-hover> | |
| <thead> | |
| <tr> | |
| <th>ประทับเวลา</th> | |
| <th>ชื่อ</th> | |
| <th>เบอร์โทร</th> | |
| <th>ลำดับคิว</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <? ?> | |
| </tbody> | |
| </table> | |
| </div> | |
| <script> | |
| var DATA | |
| window.onload = () => { | |
| DATA = '<?!= data ?>' | |
| DATA = JSON.parse(DATA) | |
| DATA.range.shift() | |
| //console.log(DATA) | |
| DATA.range.forEach((row,i) =>{ | |
| $("table tbody").append(`<tr id="TR${i}"></tr>`); | |
| $("#TR" + i).append(`<td>${DATA.range[i][0]}</td>`); | |
| $("#TR" + i).append(`<td>${DATA.range[i][1]}</td>`); | |
| $("#TR" + i).append(`<td>${DATA.range[i][2]}</td>`); | |
| $("#TR" + i).append(`<td>${DATA.range[i][3]}</td>`); | |
| $("#TR" + i).append(`<td><button id="buttonQ" onclick='this.style.backgroundColor = "#03fc2c";google.script.run.withSuccessHandler(onSuccess).sendNotify("${DATA.range[i][1]}")'>เรียกคิว</button></td>`); | |
| }) | |
| }; | |
| function onSuccess(result){ | |
| //console.log(result) | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment