webページを作って出退勤を記録したい
Discussion
Closed
解決したいこと
webページにbuttonをつけて出勤、退勤を記録
buttonを押したら.txtの作成して出勤時間をtext内に記載(SQL命令文)
連番で保存
欲を言えば実際に出勤かの確認もできたらなと思います。
(別ページに日付、時間、社員番号を保存しといて検索で該当なら実行、なければerrorなど)
web作成は初めてです。
よろしくお願いいたします。
該当するソースコード
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"><!-- 文字化け防止 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>勤怠管理</title>
<style>
h1 {
font-weight: normal;
padding-bottom: 10px;
text-align: center;
position: relative;
margin: 0 0 30px 0;
letter-spacing: 5px;
}
input[id="gcTextBox"]{
font-size: 150%;
}
input[id="button1"]{
font-size: 150%;
text-align: center;
background-color: #FFCC00;
}
input[id="button2"]{
font-size: 150%;
text-align: center;
background-color: #3399FF;
}
input[id="button3"]{
font-size: 150%;
text-align: center;
background-color: #FF99CC;
}
p {
font-weight: normal;
padding-bottom: 10px;
text-align: center;
position: relative;
margin: 0 0 30px 0;
font-size: 150%;
}
span {
font-weight: normal;
text-align: center;
}
</style>
</head>
<body>
<span id="text"></span>
<script type="text/javascript">
document.getElementById("text").innerHTML = showTime();
function showTime() {
var now = new Date();
var nowyear = now.getFullYear();
var nowmonthly = now.getMonth()+1;
var nowday = now.getDate();
var nowhour = now.getHours();
var nowminutes = now.getMinutes();
var nowseconds = now.getSeconds();
var text = nowyear + "/" + nowmonthly + "/" + nowday + " " + nowhour + ":" + nowminutes + ":" + nowseconds;
var now2 = now;
now2.setHours(now2.getHours() + 2);//+2時間
var nowyear2 = now2.getFullYear();
var nowmonthly2 = now2.getMonth()+1;
var nowday2 = now2.getDate();
var nowhour2 = now2.getHours();
var nowminutes2 = now2.getMinutes();
var nowseconds2 = now2.getSeconds();
var text2 = nowyear2 + "/" + nowmonthly2 + "/" + nowday2 + " " + nowhour2 + ":" + nowminutes2 + ":" + nowseconds2;
var now1 = now;
now1.setHours(now1.getHours() - 1);//-1時間
var nowyear1 = now1.getFullYear();
var nowmonthly1 = now1.getMonth()+1;
var nowday1 = now1.getDate();
var nowhour1 = now1.getHours();
var nowminutes1 = now1.getMinutes();
var nowseconds1 = now1.getSeconds();
var text1 = nowyear1 + "/" + nowmonthly1 + "/" + nowday1 + " " + nowhour1 + ":" + nowminutes1 + ":" + nowseconds1;
return text;
}
</script>
<h1>勤怠管理</h1><!-- 見出し -->
<form id="testform">
<p>社員番号:<input id="gcTextBox" size="8" maxlength="8" inputmode="numeric" font-size="150%" style="width: 180px; height: 50px;" placeholder="00000000" ></textarea ></p>
</form>
<script>
gcTextBox1 = new GC.InputMan.GcTextBox(document.getElementById('gcTextBox'), {
});
//保存したいフォーム要素を引数に指定します
fp = new GC.InputMan.GcFormPersistence(document.getElementById('testform'));
//persistメソッドを実行します
fp.persist();
</script>
<script language="javascript" type="text/javascript">
function OnButtonClick(){
file=$1
if [[ -e ${file} ]]; then
maxnumber=$(find . -mindepth 1 -maxdepth 1 -printf "%f\n" \
| grep -e "^${file}\$" -e "^${file}_[0-9][0-9]*\$" \
| sed "s/^${file}_\\{0,1\\}//" \
| sed 's/^$/0/' \
| sort -rn \
| head -n 1 ) ;
file+="_$((maxnumber+1))"
fi
touch C:/Users/user/Desktop/${file}.txt
if id="button2" ;then
ttt="UPDATE KNTRNP SET KNUKTM ='"+ text +"' Where KNUKTM Is Null And KNUBTM >= '"+ text +"' And KNUBTM <= '"+ text2 +"' And KNSYCD = '"+ gcTextBox1 +"' ;"
fi
if id="button1" ;then
ttt="UPDATE KNTRNP SET KNJKTM ='"+ text +"' Where KNJKTM Is Null And KNJHTM >= '"+ text +"' And KNJHTM <= '"+ text2 +"' And KNSYCD = '"+ gcTextBox1 +"' ;"
fi
if id="button3" ;then
ttt="UPDATE KNTRNP SET KNSKTM ='"+ text +"' Where KNSKTM Is Null And KNSBTM >= '"+ text1 +"' And KNSBTM <= '"+ text +"' And KNSYCD = '"+ gcTextBox1 +"' ;"
fi
echo {ttt} > ${file}.txt
}
</script>
<p><input type="button" value="出発" id="button1" style="width: 200px; height: 50px;" onclik="OnButtonClick();"/></p>
<p><input type="button" value="出勤" id="button2" style="width: 200px; height: 50px;" onclik="OnButtonClick();"/></p><br />
<br />
<p><input type="button" value="退勤" id="button3" style="width: 200px; height: 50px;" onclik="OnButtonClick();"/></p>
</body>
</html>