-
Notifications
You must be signed in to change notification settings - Fork 5
/
setting.php
149 lines (134 loc) · 4.69 KB
/
setting.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?
require(__DIR__.'/lib/utilities.php');
check_auth();
$rs = db()->query('SELECT `schedule` FROM `user` WHERE `id`=:uid', $_SESSION['uid']);
?>
<!DOCTYPE html>
<html>
<head>
<title>設定</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="css/main.css">
<style>
h1 {
margin-top: 2.5rem;
}
#set_schedule {
margin-top: 1rem;
margin-bottom: 1rem;
font-size: 4rem;
}
.application_form {
margin-top: 0rem;
}
@media screen and (max-width: 600px) {
#set_schedule {
font-size: 2rem;
}
}
</style>
</head>
<body>
<?php include 'nav.php'; ?>
<h1>打卡排程</h1>
<button id="set_schedule" class="clock_in_button btn btn-secondary" schedule="0">排程關閉</button>
<br><span id="schedule_span" class="tiny_info">若開啟排程, 系統將會為您自動打卡.<br>目前為關閉狀態.</span>
<h1 style="margin-top: 3.5rem;">修改Email</h1>
<div class="application_form">
<label>請輸入密碼</label>
<input id="pwd" type="password" class="form-control">
<label>請輸入新的Email</label>
<input id="new_email" type="email" class="form-control">
<div class="application_form_action">
<button id="edit_user_info" class="application_form_submit clock_in_button btn btn-primary">修改</button>
</div>
</div>
<h1 style="margin-top: 4rem;">修改密碼</h1>
<div class="application_form">
<label>請輸入密碼</label>
<input id="old_pwd" type="password" class="form-control">
<label>請輸入新密碼</label>
<input id="new_pwd" type="password" class="form-control">
<label>再輸入一次新密碼</label>
<input id="new_pwd_confirm" type="password" class="form-control">
<div class="application_form_action">
<button id="edit_user_pwd" class="application_form_submit clock_in_button btn btn-primary">修改</button>
</div>
</div>
<?php include 'nav_mobile.php'; ?>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="js/bootbox.min.js"></script>
<script src="js/utilities.js"></script>
<script>
var schedule = <?=json_encode($rs->schedule)?>;
if (schedule==1) {
scheduleOn();
}
//------------------------------------------------------------------------------
function scheduleOn(){
$('#set_schedule').attr('schedule', '1');
$('#set_schedule').removeClass('btn-secondary').addClass('btn-info').text('排程開啟');
$('#schedule_span').html('若開啟排程, 系統將會為您自動打卡.<br>目前為開啟狀態.');
}
function scheduleOff(){
$('#set_schedule').attr('schedule', '0');
$('#set_schedule').removeClass('btn-info').addClass('btn-secondary').text('排程關閉');
$('#schedule_span').html('若開啟排程, 系統將會為您自動打卡.<br>目前為關閉狀態.');
}
$('#set_schedule').on('click', function(){
var schedule = parseInt($(this).attr('schedule'));
if (schedule==0){
schedule = 1;
ajax('action/action_user.php', {
action: 'set_schedule',
schedule: schedule,
}, function(){
bootbox.alert('排程開啟');
scheduleOn();
});
} else if (schedule==1){
schedule = 0;
ajax('action/action_user.php', {
action: 'set_schedule',
schedule: schedule,
}, function(){
bootbox.alert('排程關閉');
scheduleOff();
});
}
return;
});
$('#edit_user_info').on('click', function(){
ajax('action/action_user.php', {
action: 'update',
password: $('#pwd').val(),
email: $('#new_email').val()
}, function(){
bootbox.alert('修改完成.');
});
});
$('#edit_user_pwd').on('click', function(){
if ($('#new_pwd').val()!=$('#new_pwd_confirm').val()){
$('#old_pwd').val('');
$('#new_pwd').val('');
$('#new_pwd_confirm').val('');
bootbox.alert('請重新輸入密碼');
return;
}
ajax('action/action_user.php', {
action: 'change_pwd',
password: $('#old_pwd').val(),
new_password: $('#new_pwd').val()
}, function(){
bootbox.alert('修改完成, 請重新登入.', function(){
window.location = 'index.php';
});
});
});
</script>
</body>
</html>