Add main form、modify item_content in .sql

This commit is contained in:
Chen,Hui Chen 2024-06-13 16:44:10 +08:00
parent 91543e2333
commit ad37ceb3fe
14 changed files with 670 additions and 537 deletions

72
api/main.js Normal file
View File

@ -0,0 +1,72 @@
// Required modules
const router = require('express').Router();
const util = require("./../utilities/utilities_main.js");
const moment = require("moment");
router.get("/", async function(req, res) {
try {
let conn;
try {
conn = await util.getDBConnection(); // get connection from db
const result = await conn.query("SELECT item_content FROM item_info;");
res.json(result);
}
catch(e) {
console.error(e);
res.json({suc : false});
}
finally {
util.closeDBConnection(conn); // close db connection
}
}
catch(e) {
console.log(e);
}
})
router.post("/", async function(req, res) {
try {
let conn;
try {
console.log(req.body);
// data
const apply_infos = req.body.apply_infos; // get data from request
const time = moment(new Date()).format("YYYY-MM-DD");
conn = await util.getDBConnection(); // get connection from db
await conn.beginTransaction();
// insert data into table : scholarship_application
const scholarship_application_info = await conn.batch("INSERT INTO scholarship_application(`application_date`, `student_id`) VALUES(?, ?);", [time, req.body.student_id]);
const scholarship_application_id = scholarship_application_info.insertId; // get the application_id of previous record
// 這邊你們要再改
// const application_unit = "test unit";
// const subsidy = 1000;
console.log(scholarship_application_info.insertId);
console.log(apply_infos);
// insert each apply item into item_form
for (let i = 0;i < apply_infos.length;i++) {
await conn.batch("INSERT INTO item_form(`application_id`, `item_info_id`, `application_unit`, `subsidy`) VALUES(?, ?, ?, ?);", [scholarship_application_id, apply_infos[i], application_unit, subsidy]);
}
await conn.commit();
res.json({suc : true});
}
catch(e) {
console.error(e);
await conn.rollback();
res.json({suc : false});
}
finally {
util.closeDBConnection(conn); // close db connection
}
}
catch(e) {
console.log(e);
}
})
module.exports = router;

View File

@ -1,29 +0,0 @@
// // 先從 model 引入 todos 資料
// const todoModel = require('../models/todo')
// const todoController = {
// getAll: (req, res) => {
// // 改成 callback 非同步操作
// todoModel.getAll((err, results) => {
// // 如果有 err 就印出錯誤訊息
// if (err) return console.log(err);
// // 不然就把 todos 傳給 view
// res.render('todos', {
// todos: results
// })
// })
// },
// get: (req, res) => {
// const id = req.params.id
// todoModel.get(id, (err, results) => {
// if (err) return console.log(err);
// res.render('todos', {
// // 注意回傳的結果 array必須取 results[0] 才會是一個 todo
// todos: results[0]
// })
// })
// }
// }
// module.exports = todoController

6
db.js
View File

@ -23,14 +23,14 @@ module.exports = connection;
// require module
const jwt = require('jsonwebtoken');
const db = require("mariadb");
const db = require("mysql");
// create pool
const pool = db.createPool({
connectionLimit : 500,
host : 'localhost',
user : 'test',
password : '123',
user : 'root',
password : '',
database : 'scholarship'
});

View File

@ -15,14 +15,14 @@ app.use(cookieParser()); //解析 HTTP 請求的 cookie
// // routing
// // pages
+app.use("/example", require("./pages/example.js"));
// app.use("/main", require("./pages/main.js"));
+app.use("/main", require("./pages/main.js"));
// app.use("/login", require("./pages/login.js"));
// app.use("/apply", require("./pages/apply.js"));
// // api
// app.use("/api/login", require("./api/login.js"));
app.use("/api/example", require("./api/example.js"));
app.use("/api/main", require("./api/main.js"));
// // static files
app.use('/js', express.static('./js'));
app.use('/css', express.static('./css'));

View File

@ -1,17 +1,97 @@
console.log("hello world");
let item_info_len = 0;
async function submit() {
const account = document.getElementById("account").value;
const password = document.getElementById("password").value;
console.log(account, password);
data = {account : account, password : password};
let suc_login = await axios.post('/login', data);
suc_login = suc_login.data;
console.log(suc_login);
if (suc_login.suc) {
location.href = '/main';
async function getItemInfo() {
// get the data from table : item_info
try {
let result = await axios.get('/api/main');
result = result.data;
return result;
}
catch (e) {
console.error(e);
return null;
}
}
async function putDataInTable(table_id) {
// get data
const data = await getItemInfo();
if (data != null && table_id != null) {
// insert data into table
let table_content = document.getElementById(table_id).innerHTML;
for (let i = 0; i < data.length; i++) {
if (i === 2 || i === 3 || i === 10 || i === 11) {
table_content += `
<tr>
<td><input type='checkbox' id='checkbox_${i}'/></td>
<td>${data[i].item_content}</td>
<td><div>申請單位:</div><input type='text' id='unit_${i}'/></td>
<td><div>獲得補助金額:</div><input type='number' id='subsidy_${i}'/></td>
</tr>`;
} else if (i === 4 || i === 5 || i === 12 || i === 13) {
table_content += `
<tr>
<td><input type='checkbox' id='checkbox_${i}'/></td>
<td>${data[i].item_content}</td>
<td><div>申請單位:</div><input type='text' id='unit_${i}'/></td>
</tr>`;
} else {
table_content += `
<tr>
<td><input type='checkbox' id='checkbox_${i}'/></td>
<td>${data[i].item_content}</td>
</tr>`;
}
}
// write back data into table
document.getElementById(table_id).innerHTML = table_content;
// set info length
item_info_len = data.length;
}
else {
alert("帳號或密碼錯誤");
console.error("data and table id can not be null");
}
}
}
// async function setStudentName() {
// // get student name, and show on page
// document.getElementById("student_name").innerHTML = "test";
// }
async function sendApplyData() {
// get student name
const student_name = document.getElementById("student_name").innerHTML;
const student_id = document.getElementById("student_id").innerHTML;
const department_and_grade = document.getElementById("department_and_grade").innerHTML;
const advisor_name = document.getElementById("advisor_name").innerHTML;
// get checked infos
let apply_infos = [];
let application_units = [];
let subsidy_amounts = [];
for (let i = 0; i < item_info_len; i++) {
if (document.getElementById(`checkbox_${i}`).checked) {
apply_infos.push(i + 1);
// get unit、subsidy
if (document.getElementById(`unit_${i}`) && document.getElementById(`subsidy_${i}`)) {
application_units.push(document.getElementById(`unit_${i}`).value);
subsidy_amounts.push(document.getElementById(`subsidy_${i}`).value);
} else {
application_units.push(null);
subsidy_amounts.push(null);
}
}
}
const data = {student_id,student_name,department_and_grade, advisor_name,
apply_infos,
application_units,
subsidy_amounts
};
// send data
let result = await axios.post('/api/main', data);
console.log(result);
}
putDataInTable("info_item");

View File

@ -1,24 +0,0 @@
// // 引入 db也就是 connection
// const db = require('../db')
// const todoModel = {
// // 這裡要用 callback 來拿取資料
// getAll: (cb) => {
// db.query(
// 'SELECT * FROM todos', (err, results) => {
// if (err) return cb(err);
// // cb: 第一個參數為是否有錯誤,沒有的話就是 null第二個才是結果
// cb(null, results)
// });
// },
// get: (id, cb) => {
// db.query(
// 'SELECT * FROM todos WHERE id = ?', [id], (err, results) => {
// if (err) return cb(err);
// cb(null, results)
// });
// }
// }
// module.exports = todoModel

View File

@ -1,5 +1,6 @@
const router = require('express').Router();
const util = require("./../utilities/utilities.js");
const { error } = require('console');
const util = require("./../utilities/utilities_main.js");
// processing request
router.get('/', async function(req, res) {
@ -8,6 +9,7 @@ router.get('/', async function(req, res) {
}
catch(e) {
console.log(e);
res.json({error_msg : "failed to access the file"});
}
return;
});

View File

@ -119,18 +119,18 @@ CREATE TABLE `item_info` (
INSERT INTO `item_info` (`item_info_id`, `item_content`) VALUES
(1, '參加校內、外(含國內、國際性)資管領域相關專業或學術性重要比賽得獎者。'),
(2, '參加國際性學術研討會或國際性會議並以外文發表論文者(不含摘要及海報論文):'),
(3, ' 已向校內申請補助,申請單位:,獲得補助金額'),
(4, '已向校外申請補助,申請單位:,獲得補助金額'),
(5, '已向校內申請補助,申請單位:,未獲得補助(需付未獲得補助證明)'),
(6, '已向校外申請補助,申請單位:未獲得補助(需付未獲得補助證明)'),
(3, ' 已向校內申請補助'),
(4, '已向校外申請補助'),
(5, '已向校內申請補助,未獲得補助(需付未獲得補助證明)'),
(6, '已向校外申請補助,未獲得補助(需付未獲得補助證明)'),
(7, '未向校內外單位申請補助'),
(8, '促進本系招生、聲譽提升、協助教學或行政工作等有具體事蹟者'),
(9, '碩士畢業生學位口試以英文發表者 參加資管領域相關學術研討會並榮獲最佳論文獎'),
(10, '獲得「國科會大專學生研究計畫獎勵」者口 學生申請國際交換生'),
(11, ' 已向校內申請補助,申請單位:,獲得補助金額'),
(12, '已向校外申請補助,申請單位:,獲得補助金額'),
(13, '已向校內申請補助,申請單位:,未獲得補助(需付未獲得補助證明)'),
(14, '已向校外申請補助,申請單位:未獲得補助(需付未獲得補助證明)'),
(11, ' 已向校內申請補助'),
(12, '已向校外申請補助'),
(13, '已向校內申請補助,未獲得補助(需付未獲得補助證明)'),
(14, '已向校外申請補助,未獲得補助(需付未獲得補助證明)'),
(15, '未向校內外單位申請補助'),
(16, '參加國內學術研討會發表論文並獲獎者'),
(17, '學生參加校外學術性比賽之交通費補助'),

View File

@ -1,292 +1,67 @@
<!DOCTYPE html>
<html>
<link href="/css/main.css" rel="stylesheet">
<script src = "/js/main.js"></script>
<title>Main Page</title>
<head>
<meta charset="utf-8">
<title>國立暨南國際大學資管系獎學金申請表</title>
</head>
<body>
<h1 align="center">國立暨南國際大學資管系獎學金申請表</h1>
<form id="scholarshipForm" >
<fieldset>
<div >
<label>申請日期:</label>
<input type="date" id="application_date" name="application_date" required>
</div>
<div>
<label>申請學生:</label>
<input type="text" id="student_name" name="student_name" required>
</div>
<div>
<label>學號:</label>
<input type="text" id="student_number" name="student_number" required>
</div>
<div>
<label for="department_and_grade">系所別(年級):</label>
<select id="department_and_grade" name="department_and_grade" required>
<option value="">請選擇年級</option>
<option value="大一">大一</option>
<option value="大二">大二</option>
<option value="大三">大三</option>
<option value="大四">大四</option>
<option value="碩一">碩一</option>
<option value="碩二">碩二</option>
<option value="碩三">碩三</option>
<option value="碩四">碩四</option>
</select>
</div>
<div>
<label for="advisor_name">導師:</label>
<select id="advisor_name" name="advisor_name" required>
<option value="">請選擇導師</option>
<option value="姜美玲">姜美玲</option>
<option value="戴榮賦">戴榮賦</option>
<option value="陳彥錚">陳彥錚</option>
<option value="黃俊哲">黃俊哲</option>
<option value="白炳豐">白炳豐</option>
<option value="簡宏宇">簡宏宇</option>
<option value="游子宜">游子宜</option>
<option value="余菁蓉">余菁蓉</option>
<option value="王育民">王育民</option>
<option value="洪嘉良">洪嘉良</option>
<option value="陳小芬">陳小芬</option>
<option value="陳建宏">陳建宏</option>
<option value="鄭育評">鄭育評</option>
</select>
</div>
<!-- <link href="/css/??.css" rel="stylesheet"> -->
<head>
<title>國立暨南國際大學資管系獎學金申請表</title>
</head>
<body>
<h1 align="center">國立暨南國際大學資管系獎學金申請表</h1>
<fieldset>
<div id="student">
<div>
<label>學生姓名:</label>
<input type="text" id="student_name" name="student_name" required>
</div>
<div>
<label>學號:</label>
<input type="text" id="student_id" name="student_id" required>
</div>
<div>
<label for="department_and_grade">系所別(年級):</label>
<select id="department_and_grade" name="department_and_grade" required>
<option value="">請選擇年級</option>
<option value="大一">大一</option>
<option value="大二">大二</option>
<option value="大三">大三</option>
<option value="大四">大四</option>
<option value="碩一">碩一</option>
<option value="碩二">碩二</option>
<option value="碩三">碩三</option>
<option value="碩四">碩四</option>
</select>
</div>
<div>
<label for="advisor_name">導師:</label>
<select id="advisor_name" name="advisor_name" required>
<option value="">請選擇導師</option>
<option value="姜美玲">姜美玲</option>
<option value="戴榮賦">戴榮賦</option>
<option value="陳彥錚">陳彥錚</option>
<option value="黃俊哲">黃俊哲</option>
<option value="白炳豐">白炳豐</option>
<option value="簡宏宇">簡宏宇</option>
<option value="游子宜">游子宜</option>
<option value="余菁蓉">余菁蓉</option>
<option value="王育民">王育民</option>
<option value="洪嘉良">洪嘉良</option>
<option value="陳小芬">陳小芬</option>
<option value="陳建宏">陳建宏</option>
<option value="鄭育評">鄭育評</option>
</select>
</div>
</div>
<br>
<hr>
<h2>申請項目及說明</h2>
<div>
<input type="checkbox" id="competitionAward" name="applicationItem" value="competitionAward">
<label for="competitionAward">參加校內、外(含國內、國際性)資管領域相關專業或學術性重要比賽得獎者</label>
</div>
<div>
<input type="checkbox" id="internationalConference" name="applicationItem" value="internationalConference">
<label for="internationalConference">參加國際性學術研討會或國際性會議並以外文發表論文者(不含摘要及海報論文)</label>
</div>
<blockquote><div>
<input type="checkbox" id="internalSupportApplied" name="supportApplied" value="internalSupportApplied">
<label for="internalSupportApplied">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnit" name="internalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="internalSupportAmount" name="internalSupportAmount">
</div>
<div>
<input type="checkbox" id="externalSupportApplied" name="supportApplied" value="externalSupportApplied">
<label for="externalSupportApplied">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnit" name="externalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="externalSupportAmount" name="externalSupportAmount">
</div>
<div>
<input type="checkbox" id="internalSupportAppliedNotGranted" name="supportApplied" value="internalSupportAppliedNotGranted">
<label for="internalSupportAppliedNotGranted">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnitNotGranted" name="internalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="externalSupportAppliedNotGranted" name="supportApplied" value="externalSupportAppliedNotGranted">
<label for="externalSupportAppliedNotGranted">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnitNotGranted" name="externalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="noSupportApplied" name="supportApplied" value="noSupportApplied">
<label for="noSupportApplied">未向校內外單位申請補助</label></blockquote>
</div>
<div>
<input type="checkbox" id="promoteDepartment" name="applicationItem" value="promoteDepartment">
<label for="promoteDepartment">促進本系招生、聲譽提升、協助教學或行政工作等有具體事蹟者</label>
</div>
<div>
<input type="checkbox" id="masterThesisInEnglish" name="applicationItem" value="masterThesisInEnglish">
<label for="masterThesisInEnglish">碩士畢業生學位口試以英文發表者</label>
</div>
<div>
<input type="checkbox" id="bestPaperAward" name="applicationItem" value="bestPaperAward">
<label for="bestPaperAward">參加資管領域相關學術研討會並榮獲最佳論文獎</label>
</div>
<div>
<input type="checkbox" id="nationalScienceCouncilAward" name="applicationItem" value="nationalScienceCouncilAward">
<label for="nationalScienceCouncilAward">獲得「國科會大專學生研究計畫獎勵」者</label>
</div>
<div>
<input type="checkbox" id="internationalExchangeStudent" name="applicationItem" value="internationalExchangeStudent">
<label for="internationalExchangeStudent">學生申請國際交換生</label>
</div>
<blockquote><div>
<input type="checkbox" id="internalSupportApplied" name="supportApplied" value="internalSupportApplied">
<label for="internalSupportApplied">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnit" name="internalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="internalSupportAmount" name="internalSupportAmount">
</div>
<div>
<input type="checkbox" id="externalSupportApplied" name="supportApplied" value="externalSupportApplied">
<label for="externalSupportApplied">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnit" name="externalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="externalSupportAmount" name="externalSupportAmount">
</div>
<div>
<input type="checkbox" id="internalSupportAppliedNotGranted" name="supportApplied" value="internalSupportAppliedNotGranted">
<label for="internalSupportAppliedNotGranted">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnitNotGranted" name="internalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="externalSupportAppliedNotGranted" name="supportApplied" value="externalSupportAppliedNotGranted">
<label for="externalSupportAppliedNotGranted">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnitNotGranted" name="externalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="noSupportApplied" name="supportApplied" value="noSupportApplied">
<label for="noSupportApplied">未向校內外單位申請補助</label>
</div></blockquote>
<div>
<input type="checkbox" id="undergraduateToMaster" name="applicationItem" value="undergraduateToMaster">
<label for="undergraduateToMaster">本系大學部學生報考本系碩士班經甄試或考試正取者</label>
</div>
<div>
<input type="checkbox" id="academicConferenceAward" name="applicationItem" value="academicConferenceAward">
<label for="academicConferenceAward">參加國內學術研討會發表論文並獲獎者</label>
</div>
<div>
<input type="checkbox" id="externalCompetitionTravelGrant" name="applicationItem" value="externalCompetitionTravelGrant">
<label for="externalCompetitionTravelGrant">學生參加校外學術性比賽之交通費補助</label>
</div>
<div>
<input type="checkbox" id="certificationAchievement" name="applicationItem" value="certificationAchievement">
<label for="certificationAchievement">在學學生考取TOEFL iBT 100分以上、IELTS 7分以上或日文N1、GRE 320分以上或同等證照證明</label>
</div>
<div>
<input type="checkbox" id="otherOption" name="applicationItem" value="other">
<label for="otherOption">其他:</label>
<input type="text" id="otherOptionText" name="otherOptionText">
<br>
<br>
<label for="otherOptionFile">附件上傳:</label>
<input type="file" id="otherOptionFile" name="otherOptionFile">
</div>
</fieldset>
<!-- 可以在此處繼續添加其他申請項目-->
<br>
<!-- <hr style="border-style:double; border-width: 2.5px; " > -->
<div style="border:2px black solid;">
<div>
<br>
<label><strong>系所助理:</strong></label>
<select id="assistant_name" name="assistant_name" required>
<option value="">請選系所助理</option>
<option value="王慈君">王慈君</option>
<option value="賴玫旋">賴玫旋</option>
</select>
</div>
<h2>證明文件是否備齊</h2>
<div>
<input type="radio" id="documentsReadyYes" name="documentsReady" value="yes">
<label for="documentsReadyYes"></label>
<input type="radio" id="documentsReadyNo" name="documentsReady" value="no">
<label for="documentsReadyNo">否,尚須補繳:</label>
<input type="text" id="documentsMissing" name="documentsMissing">
</div>
<h2>學生事務委員會審核結果</h2>
<div>
<input type="radio" id="passed" name="committee_review" value="passed" onclick="togglePassedDate(true)">
<label for="passed"></label>
<input type="number" id="passedTimes" name="passedTimes" min="1" style="width: 50px;" required>次通過,核發獎學金
<input type="number" id="scholarshipAmount" name="scholarshipAmount" style="width: 100px;" required>
<br>
<blockquote>
<div >
<label>通過日期:</label>
<input type="date" id="passed_date" name="passed_date" required>
</div>
</blockquote>
</div>
<div>
<input type="radio" id="notPassed" name="committeeReview" value="notPassed" onclick="togglePassedDate(false)">
<label for="notPassed">未通過</label>
</div>
<br>
<div>
<label for="noSupportProof"> 未獲補助證明檔案繳交處:</label>
<input type="file" id="noSupportProof" name="noSupportProof" accept=".pdf, .doc, .docx, .jpg, .jpeg, .png">
</div>
<br>
<div>
</div>
</div>
<div>
<p>
說明:<br>
一、依據「國立暨南國際大學資訊管理學系獎助學金作業要點」辦理。<br>
二、申辦流程:由學生詳填本申請書並檢附相關證明文件,逕送系辦審查資料是否齊全,提交學生事務委員會審核後,由系辦通知申請學生核定結果(獎學金將逕行撥入申請學生帳戶)。<br>
三、獲得本系獎助學金補助者須提供申請事項之詳細資訊,供系上公告與相關宣傳使用。若後續有召開分享會等相關需要,獲補助者需配合辦理。
</p>
</div>
<br>
<input type="submit" value="提交申請">
</div>
<form id="scholarshipForm" method="post" enctype="multipart/form-data">
<!-- 若表單須通過http post方式提交至伺服器並且包括文件上傳需使用(from)這段程式碼-->
</form>
<div id="submittedData" style="display: none;">
<!-- -->
</div>
</form>
<script>
document.getElementById('scholarshipForm').onsubmit = function(event) {
event.preventDefault(); // Prevent the default form submission behavior
// Collect form data
var formData = new FormData(this);
// Convert form data to readable text format
var formContent = '';
for (var pair of formData.entries()) {
formContent += pair[0] + ': ' + pair[1] + '<br>';
}
// Open a new window to display the form content
var newWindow = window.open();
newWindow.document.write('<h1>國立暨南國際大學資管系獎學金申請內容</h1>' + formContent);
newWindow.document.close();
// Reset the form fields
this.reset();
};
</script>
<table id="info_item" border="1">
<tr>
<td>是否申請</td>
<td>項目內容</td>
</tr>
</table>
<button onclick="sendApplyData()">送出申請</button>
</body>
</html>
<script src="https://cdn.jsdelivr.net/npm/axios@1.6.7/dist/axios.min.js"></script>
<script src = "/js/main.js"></script>
</html>

292
templates/main2.html Normal file
View File

@ -0,0 +1,292 @@
<!DOCTYPE html>
<html>
<link href="/css/main.css" rel="stylesheet">
<script src = "/js/main.js"></script>
<title>Main Page</title>
<head>
<meta charset="utf-8">
<title>國立暨南國際大學資管系獎學金申請表</title>
</head>
<body>
<h1 align="center">國立暨南國際大學資管系獎學金申請表</h1>
<form id="scholarshipForm" >
<fieldset>
<div >
<label>申請日期:</label>
<input type="date" id="application_date" name="application_date" required>
</div>
<div>
<label>申請學生:</label>
<input type="text" id="student_name" name="student_name" required>
</div>
<div>
<label>學號:</label>
<input type="text" id="student_id" name="student_id" required>
</div>
<div>
<label for="department_and_grade">系所別(年級):</label>
<select id="department_and_grade" name="department_and_grade" required>
<option value="">請選擇年級</option>
<option value="大一">大一</option>
<option value="大二">大二</option>
<option value="大三">大三</option>
<option value="大四">大四</option>
<option value="碩一">碩一</option>
<option value="碩二">碩二</option>
<option value="碩三">碩三</option>
<option value="碩四">碩四</option>
</select>
</div>
<div>
<label for="advisor_name">導師:</label>
<select id="advisor_name" name="advisor_name" required>
<option value="">請選擇導師</option>
<option value="姜美玲">姜美玲</option>
<option value="戴榮賦">戴榮賦</option>
<option value="陳彥錚">陳彥錚</option>
<option value="黃俊哲">黃俊哲</option>
<option value="白炳豐">白炳豐</option>
<option value="簡宏宇">簡宏宇</option>
<option value="游子宜">游子宜</option>
<option value="余菁蓉">余菁蓉</option>
<option value="王育民">王育民</option>
<option value="洪嘉良">洪嘉良</option>
<option value="陳小芬">陳小芬</option>
<option value="陳建宏">陳建宏</option>
<option value="鄭育評">鄭育評</option>
</select>
</div>
<br>
<hr>
<h2>申請項目及說明</h2>
<div>
<input type="checkbox" id="competitionAward" name="applicationItem" value="competitionAward">
<label for="competitionAward">參加校內、外(含國內、國際性)資管領域相關專業或學術性重要比賽得獎者</label>
</div>
<div>
<input type="checkbox" id="internationalConference" name="applicationItem" value="internationalConference">
<label for="internationalConference">參加國際性學術研討會或國際性會議並以外文發表論文者(不含摘要及海報論文)</label>
</div>
<blockquote><div>
<input type="checkbox" id="internalSupportApplied" name="supportApplied" value="internalSupportApplied">
<label for="internalSupportApplied">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnit" name="internalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="internalSupportAmount" name="internalSupportAmount">
</div>
<div>
<input type="checkbox" id="externalSupportApplied" name="supportApplied" value="externalSupportApplied">
<label for="externalSupportApplied">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnit" name="externalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="externalSupportAmount" name="externalSupportAmount">
</div>
<div>
<input type="checkbox" id="internalSupportAppliedNotGranted" name="supportApplied" value="internalSupportAppliedNotGranted">
<label for="internalSupportAppliedNotGranted">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnitNotGranted" name="internalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="externalSupportAppliedNotGranted" name="supportApplied" value="externalSupportAppliedNotGranted">
<label for="externalSupportAppliedNotGranted">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnitNotGranted" name="externalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="noSupportApplied" name="supportApplied" value="noSupportApplied">
<label for="noSupportApplied">未向校內外單位申請補助</label></blockquote>
</div>
<div>
<input type="checkbox" id="promoteDepartment" name="applicationItem" value="promoteDepartment">
<label for="promoteDepartment">促進本系招生、聲譽提升、協助教學或行政工作等有具體事蹟者</label>
</div>
<div>
<input type="checkbox" id="masterThesisInEnglish" name="applicationItem" value="masterThesisInEnglish">
<label for="masterThesisInEnglish">碩士畢業生學位口試以英文發表者</label>
</div>
<div>
<input type="checkbox" id="bestPaperAward" name="applicationItem" value="bestPaperAward">
<label for="bestPaperAward">參加資管領域相關學術研討會並榮獲最佳論文獎</label>
</div>
<div>
<input type="checkbox" id="nationalScienceCouncilAward" name="applicationItem" value="nationalScienceCouncilAward">
<label for="nationalScienceCouncilAward">獲得「國科會大專學生研究計畫獎勵」者</label>
</div>
<div>
<input type="checkbox" id="internationalExchangeStudent" name="applicationItem" value="internationalExchangeStudent">
<label for="internationalExchangeStudent">學生申請國際交換生</label>
</div>
<blockquote><div>
<input type="checkbox" id="internalSupportApplied" name="supportApplied" value="internalSupportApplied">
<label for="internalSupportApplied">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnit" name="internalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="internalSupportAmount" name="internalSupportAmount">
</div>
<div>
<input type="checkbox" id="externalSupportApplied" name="supportApplied" value="externalSupportApplied">
<label for="externalSupportApplied">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnit" name="externalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="externalSupportAmount" name="externalSupportAmount">
</div>
<div>
<input type="checkbox" id="internalSupportAppliedNotGranted" name="supportApplied" value="internalSupportAppliedNotGranted">
<label for="internalSupportAppliedNotGranted">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnitNotGranted" name="internalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="externalSupportAppliedNotGranted" name="supportApplied" value="externalSupportAppliedNotGranted">
<label for="externalSupportAppliedNotGranted">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnitNotGranted" name="externalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="noSupportApplied" name="supportApplied" value="noSupportApplied">
<label for="noSupportApplied">未向校內外單位申請補助</label>
</div></blockquote>
<div>
<input type="checkbox" id="undergraduateToMaster" name="applicationItem" value="undergraduateToMaster">
<label for="undergraduateToMaster">本系大學部學生報考本系碩士班經甄試或考試正取者</label>
</div>
<div>
<input type="checkbox" id="academicConferenceAward" name="applicationItem" value="academicConferenceAward">
<label for="academicConferenceAward">參加國內學術研討會發表論文並獲獎者</label>
</div>
<div>
<input type="checkbox" id="externalCompetitionTravelGrant" name="applicationItem" value="externalCompetitionTravelGrant">
<label for="externalCompetitionTravelGrant">學生參加校外學術性比賽之交通費補助</label>
</div>
<div>
<input type="checkbox" id="certificationAchievement" name="applicationItem" value="certificationAchievement">
<label for="certificationAchievement">在學學生考取TOEFL iBT 100分以上、IELTS 7分以上或日文N1、GRE 320分以上或同等證照證明</label>
</div>
<div>
<input type="checkbox" id="otherOption" name="applicationItem" value="other">
<label for="otherOption">其他:</label>
<input type="text" id="otherOptionText" name="otherOptionText">
<br>
<br>
<label for="otherOptionFile">附件上傳:</label>
<input type="file" id="otherOptionFile" name="otherOptionFile">
</div>
</fieldset>
<!-- 可以在此處繼續添加其他申請項目-->
<br>
<!-- <hr style="border-style:double; border-width: 2.5px; " > -->
<div style="border:2px black solid;">
<div>
<br>
<label><strong>系所助理:</strong></label>
<select id="assistant_name" name="assistant_name" required>
<option value="">請選系所助理</option>
<option value="王慈君">王慈君</option>
<option value="賴玫旋">賴玫旋</option>
</select>
</div>
<h2>證明文件是否備齊</h2>
<div>
<input type="radio" id="documentsReadyYes" name="documents_ready" value="yes">
<label for="documentsReadyYes"></label>
<input type="radio" id="documentsReadyNo" name="documents_ready" value="no">
<label for="documentsReadyNo">否,尚須補繳:</label>
<input type="text" id="documentsMissing" name="documentsMissing">
</div>
<h2>學生事務委員會審核結果</h2>
<div>
<input type="radio" id="passed" name="committee_review" value="passed" onclick="togglePassedDate(true)">
<label for="passed"></label>
<input type="number" id="passedTimes" name="passedTimes" min="1" style="width: 50px;" required>次通過,核發獎學金
<input type="number" id="scholarshipAmount" name="scholarshipAmount" style="width: 100px;" required>
<br>
<blockquote>
<div >
<label>通過日期:</label>
<input type="date" id="passed_date" name="passed_date" required>
</div>
</blockquote>
</div>
<div>
<input type="radio" id="notPassed" name="committeeReview" value="notPassed" onclick="togglePassedDate(false)">
<label for="notPassed">未通過</label>
</div>
<br>
<div>
<label for="noSupportProof"> 未獲補助證明檔案繳交處:</label>
<input type="file" id="noSupportProof" name="noSupportProof" accept=".pdf, .doc, .docx, .jpg, .jpeg, .png">
</div>
<br>
<div>
</div>
</div>
<div>
<p>
說明:<br>
一、依據「國立暨南國際大學資訊管理學系獎助學金作業要點」辦理。<br>
二、申辦流程:由學生詳填本申請書並檢附相關證明文件,逕送系辦審查資料是否齊全,提交學生事務委員會審核後,由系辦通知申請學生核定結果(獎學金將逕行撥入申請學生帳戶)。<br>
三、獲得本系獎助學金補助者須提供申請事項之詳細資訊,供系上公告與相關宣傳使用。若後續有召開分享會等相關需要,獲補助者需配合辦理。
</p>
</div>
<br>
<input type="submit" value="提交申請">
</div>
<form id="scholarshipForm" method="post" enctype="multipart/form-data">
<!-- 若表單須通過http post方式提交至伺服器並且包括文件上傳需使用(from)這段程式碼-->
</form>
<div id="submittedData" style="display: none;">
<!-- -->
</div>
</form>
<script>
document.getElementById('scholarshipForm').onsubmit = function(event) {
event.preventDefault(); // Prevent the default form submission behavior
// Collect form data
var formData = new FormData(this);
// Convert form data to readable text format
var formContent = '';
for (var pair of formData.entries()) {
formContent += pair[0] + ': ' + pair[1] + '<br>';
}
// Open a new window to display the form content
var newWindow = window.open();
newWindow.document.write('<h1>國立暨南國際大學資管系獎學金申請內容</h1>' + formContent);
newWindow.document.close();
// Reset the form fields
this.reset();
};
</script>
</body>
</html>

View File

@ -1,13 +1,13 @@
// require module
const jwt = require('jsonwebtoken');
const db = require("mariadb");
const db = require("mysql");
// create pool
const pool = db.createPool({
connectionLimit : 500,
host : 'localhost',
user : 'test',
password : '123',
user : 'root',
password : '',
database : 'scholarship'
});

133
utilities/utilities_main.js Normal file
View File

@ -0,0 +1,133 @@
// require module
const jwt = require('jsonwebtoken');
const db = require("mysql");
// create pool
const pool = db.createPool({
connectionLimit : 500,
host : 'localhost',
user : 'user',
password : '',
database : 'scholarship'
});
// global variable
const jwt_key = "goodjwtkey";
module.exports = {
// shared variable
jwt_key,
// shared function
signJwtToken: function(data) {
try {
const result = jwt.sign({ data, exp: Math.floor(Date.now() / 1000) + (60 * 15) }, jwt_key);
return result;
}
catch (e) {
console.log(e);
}
},
authenToken: function(token) {
return new Promise((resolve, reject) => {
try {
const data = jwt.verify(token, jwt_key).data;
if (data.uid) {
resolve(true);
} else {
resolve(false);
}
} catch (error) {
console.error(error);
resolve(false);
}
});
},
loginAuthentication: function(account, password) {
return new Promise((resolve, reject) => { // 包裝成 Promise
const spawn = require("child_process").spawn;
const pythonScript = path.join(__dirname, 'catch.py'); // path/to/catch.py
const pythonProcess = spawn('python', [pythonScript, account, password]);
//console.log(`account: ${account}`);
//console.log(`password: ${password}`);
pythonProcess.stdout.on('data', (data) => {
data = data.toString().slice(0, -1); // remove the last char
if (data === 'login falied') {
resolve(false); // 登入失敗,解析 Promise 為 True
} else {
resolve(data.toString().trim()); // 登入成功
}
});
pythonProcess.stderr.on('data', (data) => {
console.error(`stderr: ${data.toString()}`);
});
pythonProcess.on('exit', (code) => {
//console.log(`child process exited with code ${code}`);
if (code !== 0) {
reject(new Error(`child process exited with code ${code}`)); // 非 0 退出代碼表示錯誤
}
});
pythonProcess.on('error', (err) => {
console.error(err);
reject(err); // 子進程啟動失敗
});
});
},
// get parent absolute path
getParentPath : function(dir) {
try {
n_dir = "";
dir = dir.split("");
// determine the type of slash, which will be different between windows and linux
if (dir.includes("/")) {
slash_type = "/";
}
else {
slash_type = "\\";
}
// pop the last one directory
while (dir.pop() != "\\") {
// pass
}
// restructure the full path
for (let i = 0;i < dir.length;i++) {
n_dir += dir[i];
}
return n_dir;
}
catch(e) {
console.log(e);
}
},
// return connection of db
getDBConnection : async function() {
try {
const conn = await pool.getConnection();
return conn;
}
catch(e) {
console.error("error getting db connection : ", e);
return null;
}
},
// close connection of db
closeDBConnection : function(conn) {
try {
conn.release();
}
catch(e) {
console.error("error closing db connection : ", e);
}
}
}

View File

@ -1,3 +0,0 @@
<h1>Todo</h1>
<h2><%= todo %></h2>

View File

@ -1,165 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link href="/css/main.css" rel="stylesheet">
<script src="/js/main.js"></script>
<meta charset="utf-8">
<title>國立暨南國際大學資管系獎學金申請表</title>
</head>
<body>
<h1 align="center">國立暨南國際大學資管系獎學金申請表</h1>
<form id="scholarshipForm" method="post" enctype="multipart/form-data">
<fieldset>
<div>
<label>申請日期:</label>
<input type="date" id="application_date" name="application_date" required>
</div>
<div>
<label>申請學生:</label>
<input type="text" id="student_name" name="student_name" required>
</div>
<div>
<label>學號:</label>
<input type="text" id="student_number" name="student_number" required>
</div>
<div>
<label for="department_and_grade">系所別(年級):</label>
<select id="department_and_grade" name="department_and_grade" required>
<option value="">請選擇年級</option>
<% ['大一', '大二', '大三', '大四', '碩一', '碩二', '碩三', '碩四'].forEach(function(grade) { %>
<option value="<%= grade %>"><%= grade %></option>
<% }); %>
</select>
</div>
<div>
<label for="advisor_name">導師:</label>
<select id="advisor_name" name="advisor_name" required>
<option value="">請選擇導師</option>
<% ['姜美玲', '戴榮賦', '陳彥錚', '黃俊哲', '白炳豐', '簡宏宇', '游子宜', '余菁蓉', '王育民', '洪嘉良', '陳小芬', '陳建宏', '鄭育評'].forEach(function(advisor) { %>
<option value="<%= advisor %>"><%= advisor %></option>
<% }); %>
</select>
</div>
<br>
<hr>
<h2>申請項目及說明</h2>
<div>
<input type="checkbox" id="competitionAward" name="applicationItem" value="competitionAward">
<label for="competitionAward">參加校內、外(含國內、國際性)資管領域相關專業或學術性重要比賽得獎者</label>
</div>
<div>
<input type="checkbox" id="internationalConference" name="applicationItem" value="internationalConference">
<label for="internationalConference">參加國際性學術研討會或國際性會議並以外文發表論文者(不含摘要及海報論文)</label>
</div>
<blockquote>
<div>
<input type="checkbox" id="internalSupportApplied" name="supportApplied" value="internalSupportApplied">
<label for="internalSupportApplied">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnit" name="internalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="internalSupportAmount" name="internalSupportAmount">
</div>
<div>
<input type="checkbox" id="externalSupportApplied" name="supportApplied" value="externalSupportApplied">
<label for="externalSupportApplied">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnit" name="externalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="externalSupportAmount" name="externalSupportAmount">
</div>
<div>
<input type="checkbox" id="internalSupportAppliedNotGranted" name="supportApplied" value="internalSupportAppliedNotGranted">
<label for="internalSupportAppliedNotGranted">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnitNotGranted" name="internalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="externalSupportAppliedNotGranted" name="supportApplied" value="externalSupportAppliedNotGranted">
<label for="externalSupportAppliedNotGranted">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnitNotGranted" name="externalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="noSupportApplied" name="supportApplied" value="noSupportApplied">
<label for="noSupportApplied">未向校內外單位申請補助</label>
</div>
</blockquote>
<div>
<input type="checkbox" id="promoteDepartment" name="applicationItem" value="promoteDepartment">
<label for="promoteDepartment">促進本系招生、聲譽提升、協助教學或行政工作等有具體事蹟者</label>
</div>
<div>
<input type="checkbox" id="masterThesisInEnglish" name="applicationItem" value="masterThesisInEnglish">
<label for="masterThesisInEnglish">碩士畢業生學位口試以英文發表者</label>
</div>
<div>
<input type="checkbox" id="bestPaperAward" name="applicationItem" value="bestPaperAward">
<label for="bestPaperAward">參加資管領域相關學術研討會並榮獲最佳論文獎</label>
</div>
<div>
<input type="checkbox" id="nationalScienceCouncilAward" name="applicationItem" value="nationalScienceCouncilAward">
<label for="nationalScienceCouncilAward">獲得「國科會大專學生研究計畫獎勵」者</label>
</div>
<div>
<input type="checkbox" id="internationalExchangeStudent" name="applicationItem" value="internationalExchangeStudent">
<label for="internationalExchangeStudent">學生申請國際交換生</label>
</div>
<blockquote>
<div>
<input type="checkbox" id="internalSupportApplied" name="supportApplied" value="internalSupportApplied">
<label for="internalSupportApplied">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnit" name="internalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="internalSupportAmount" name="internalSupportAmount">
</div>
<div>
<input type="checkbox" id="externalSupportApplied" name="supportApplied" value="externalSupportApplied">
<label for="externalSupportApplied">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnit" name="externalSupportUnit">
<label>已獲補助額度NT$</label>
<input type="number" id="externalSupportAmount" name="externalSupportAmount">
</div>
<div>
<input type="checkbox" id="internalSupportAppliedNotGranted" name="supportApplied" value="internalSupportAppliedNotGranted">
<label for="internalSupportAppliedNotGranted">已向校內申請補助,申請單位:</label>
<input type="text" id="internalSupportUnitNotGranted" name="internalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="externalSupportAppliedNotGranted" name="supportApplied" value="externalSupportAppliedNotGranted">
<label for="externalSupportAppliedNotGranted">已向校外申請補助,申請單位:</label>
<input type="text" id="externalSupportUnitNotGranted" name="externalSupportUnitNotGranted">
<label>但未獲補助(若勾選此,請檢附未獲補助證明)</label>
</div>
<div>
<input type="checkbox" id="noSupportApplied" name="supportApplied" value="noSupportApplied">
<label for="noSupportApplied">未向校內外單位申請補助</label>
</div>
</blockquote>
<div>
<input type="checkbox" id="promoteInternationalVisibility" name="applicationItem" value="promoteInternationalVisibility">
<label for="promoteInternationalVisibility">其他具體可促進本系國際化或提昇國際能見度之具體事證</label>
</div>
<div>
<label for="applicationContent">申請內容:</label>
<textarea id="applicationContent" name="applicationContent" rows="4" cols="50"></textarea>
</div>
<div>
<label for="documentUpload">申請文件上傳:</label>
<input type="file" id="documentUpload" name="documentUpload">
</div>
<br>
<hr>
<div>
<label>學生簽名:</label>
<input type="text" id="studentSignature" name="studentSignature" required>
</div>
<div>
<label>導師簽名:</label>
<input type="text" id="advisorSignature" name="advisorSignature" required>
</div>
<br>
<input type="submit" value="提交申請">
</fieldset>
</form>
</body>
</html>