{"id":17,"date":"2026-07-28T23:38:07","date_gmt":"2026-07-28T23:38:07","guid":{"rendered":"https:\/\/jobstracker.nhum.in.th\/?page_id=17"},"modified":"2026-07-28T23:38:07","modified_gmt":"2026-07-28T23:38:07","slug":"logs","status":"publish","type":"page","link":"https:\/\/jobstracker.nhum.in.th\/?page_id=17","title":{"rendered":"Logs"},"content":{"rendered":"\n\n\n<!DOCTYPE html>\n<html>\n<head>\n  <base target=\"_top\">\n  <?!= include('Styles'); ?>\n<\/head>\n<body>\n  <?!= include('Nav'); ?>\n\n  <div class=\"container\">\n    <div class=\"card\">\n      <div class=\"toolbar\">\n        <h2 style=\"margin:0;\">\ud83d\udcdc \u0e1b\u0e23\u0e30\u0e27\u0e31\u0e15\u0e34\u0e01\u0e32\u0e23\u0e17\u0e33\u0e07\u0e32\u0e19 (JobLogs)<\/h2>\n        <button class=\"secondary\" onclick=\"loadLogs()\">\ud83d\udd04 \u0e23\u0e35\u0e40\u0e1f\u0e23\u0e0a<\/button>\n      <\/div>\n      <div class=\"filter-row\">\n        <input type=\"text\" id=\"logSearch\" placeholder=\"\u0e04\u0e49\u0e19\u0e2b\u0e32 job_id \u0e2b\u0e23\u0e37\u0e2d\u0e1c\u0e39\u0e49\u0e17\u0e33\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23...\" oninput=\"renderLogs()\">\n      <\/div>\n      <div id=\"logsLoading\" class=\"loading\">\u0e01\u0e33\u0e25\u0e31\u0e07\u0e42\u0e2b\u0e25\u0e14&#8230;<\/div>\n      <div class=\"table-scroll\">\n        <table id=\"logsTable\" style=\"display:none;\">\n          <thead><tr><th>\u0e40\u0e27\u0e25\u0e32<\/th><th>Job ID<\/th><th>Action<\/th><th>\u0e42\u0e14\u0e22<\/th><th>\u0e2b\u0e21\u0e32\u0e22\u0e40\u0e2b\u0e15\u0e38<\/th><\/tr><\/thead>\n          <tbody id=\"logsBody\"><\/tbody>\n        <\/table>\n      <\/div>\n    <\/div>\n\n    <div class=\"card\">\n      <div class=\"toolbar\">\n        <h2 style=\"margin:0;\">\ud83d\udd14 \u0e1b\u0e23\u0e30\u0e27\u0e31\u0e15\u0e34\u0e01\u0e32\u0e23\u0e41\u0e08\u0e49\u0e07\u0e40\u0e15\u0e37\u0e2d\u0e19 (Notifications)<\/h2>\n        <button class=\"secondary\" onclick=\"loadNotifications()\">\ud83d\udd04 \u0e23\u0e35\u0e40\u0e1f\u0e23\u0e0a<\/button>\n      <\/div>\n      <div id=\"notifLoading\" class=\"loading\">\u0e01\u0e33\u0e25\u0e31\u0e07\u0e42\u0e2b\u0e25\u0e14&#8230;<\/div>\n      <div class=\"table-scroll\">\n        <table id=\"notifTable\" style=\"display:none;\">\n          <thead><tr><th>\u0e40\u0e27\u0e25\u0e32\u0e2a\u0e48\u0e07<\/th><th>Job ID<\/th><th>\u0e1c\u0e39\u0e49\u0e23\u0e31\u0e1a<\/th><th>\u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17<\/th><th>\u0e2a\u0e16\u0e32\u0e19\u0e30<\/th><\/tr><\/thead>\n          <tbody id=\"notifBody\"><\/tbody>\n        <\/table>\n      <\/div>\n    <\/div>\n  <\/div>\n\n  <script>\n    var allLogs = [];\n\n    function fmtDate(d) {\n      if (!d) return '-';\n      return new Date(d).toLocaleString('th-TH', { dateStyle: 'short', timeStyle: 'short' });\n    }\n\n    function loadLogs() {\n      document.getElementById('logsLoading').style.display = 'block';\n      document.getElementById('logsTable').style.display = 'none';\n      google.script.run.withSuccessHandler(function (logs) {\n        allLogs = logs;\n        renderLogs();\n        document.getElementById('logsLoading').style.display = 'none';\n        document.getElementById('logsTable').style.display = 'table';\n      }).getJobLogsList();\n    }\n\n    function renderLogs() {\n      var search = document.getElementById('logSearch').value.toLowerCase();\n      var body = document.getElementById('logsBody');\n      var filtered = allLogs.filter(function (l) {\n        if (!search) return true;\n        return (String(l.job_id).toLowerCase().indexOf(search) > -1) ||\n          (String(l.action_by).toLowerCase().indexOf(search) > -1);\n      });\n      body.innerHTML = filtered.map(function (l) {\n        return '<tr>' +\n          '<td>' + fmtDate(l.timestamp) + '<\/td>' +\n          '<td>' + l.job_id + '<\/td>' +\n          '<td>' + l.action + '<\/td>' +\n          '<td>' + l.action_by + '<\/td>' +\n          '<td>' + (l.note || '-') + '<\/td>' +\n          '<\/tr>';\n      }).join('');\n    }\n\n    function loadNotifications() {\n      document.getElementById('notifLoading').style.display = 'block';\n      document.getElementById('notifTable').style.display = 'none';\n      google.script.run.withSuccessHandler(function (notifs) {\n        var body = document.getElementById('notifBody');\n        body.innerHTML = notifs.map(function (n) {\n          var statusColor = n.status === 'Sent' ? 'badge-done' : 'badge-overdue';\n          return '<tr>' +\n            '<td>' + fmtDate(n.sent_at) + '<\/td>' +\n            '<td>' + n.job_id + '<\/td>' +\n            '<td>' + n.recipient + '<\/td>' +\n            '<td>' + n.type + '<\/td>' +\n            '<td><span class=\"badge ' + statusColor + '\">' + n.status + '<\/span><\/td>' +\n            '<\/tr>';\n        }).join('');\n        document.getElementById('notifLoading').style.display = 'none';\n        document.getElementById('notifTable').style.display = 'table';\n      }).getNotificationsList();\n    }\n\n    loadLogs();\n    loadNotifications();\n  <\/script>\n<\/body>\n<\/html>\n\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-17","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/jobstracker.nhum.in.th\/index.php?rest_route=\/wp\/v2\/pages\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jobstracker.nhum.in.th\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/jobstracker.nhum.in.th\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/jobstracker.nhum.in.th\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jobstracker.nhum.in.th\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":2,"href":"https:\/\/jobstracker.nhum.in.th\/index.php?rest_route=\/wp\/v2\/pages\/17\/revisions"}],"predecessor-version":[{"id":19,"href":"https:\/\/jobstracker.nhum.in.th\/index.php?rest_route=\/wp\/v2\/pages\/17\/revisions\/19"}],"wp:attachment":[{"href":"https:\/\/jobstracker.nhum.in.th\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}