forked from dengqiuhua/duty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetail.php
184 lines (164 loc) · 5.53 KB
/
detail.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
header("content-Type: text/html; charset=utf-8");
require("config.php");
function data($db,$date,$number=''){
if($date){
$time_s=strtotime("$date 00:00:00");
$time_e=strtotime("$date 23:59:59");
$where=" and deadline>$time_s AND deadline<$time_e AND number='$number'" ;
}else{
//个人全部
$where=" AND number='$number'" ;
}
$sql="SELECT * FROM duty WHERE 1=1 $where order by deadline asc";
$query = $db->query($sql);
return $query->fetchAll(PDO::FETCH_ASSOC);
}
//当前用户
function get_username($db,$number){
$sql="SELECT name FROM duty_user WHERE number='$number' LIMIT 1;";
$res=$db->query($sql);
return $res->fetchColumn();
}
//--------------------------------------------------
//工号
$num=$_REQUEST['number'];
//姓名:
$username=get_username($db,$num);
//week
$strweek = array('日' , '一', '二', '三', '四', '五', '六' );
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title><?=$username;?>-duty</title>
<meta name="description" content="">
<meta name="author" content="邓秋华">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
<link rel="shortcut icon" href="style/images/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="style/css/bootstrap.css" />
<script type="text/javascript" src="style/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="style/js/bootstrap.js"></script>
</head>
<body>
<div>
<?php
$nav=5;
require("header.php");
?>
<div class="container">
<div class="row">
<div class="well">
<div>
<div class="pagination">
<ul>
<?php
//当前日期
$page=$_REQUEST && isset($_REQUEST['p'])?$_REQUEST['p']:0;
$strPage="<li class='".($page==0?'active':'')."'><a href='?p=0&number=$num'>全部</a></li>";
//分页
$strPage.="<li><a href='?p=".($page-1)."&number=$num'><<</a></li>";
for ($i=1; $i < 31; $i++) {
$class=$i==$page?'active':'';
$strPage.="<li class='$class'><a href='?p=$i&number=$num'>$i</a></li>";
}
$strPage.="<li><a href='?p=".($page+1)."&number=$num'>>></a></li>";
echo $strPage;
?>
</ul>
</div>
</div>
</div>
</div>
<div class="row">
<div class="span8">
<div class="well">
<section id="data_all">
<table class="table table-striped table-hover" style="width:100%;" cellspacing="0">
<tr>
<th>部门</th>
<th>姓名</th>
<th>编号</th>
<th>打卡时间</th>
<th>星期</th>
</tr>
<?php
//当天
if($page&&$page!=0){
$current_day="$year-$month-$page";
$current_week=date('w',strtotime($current_day));//当周
//当天打卡记录
$data=data($db,$current_day,$num);
}else{
//当天打卡记录
$data=data($db,"",$num);
$current_day = "本月";
$current_week= "";
}
@mysql_close($db);
if ($data) {
foreach($data as $key=>$value){
$strDate=date('Y-m-d H:i:s',$value['deadline']);
$current_week=date('w',strtotime($strDate));//当周
?>
<tr>
<td><?=$value['department'];?></td>
<td><?=$value['name'];?></a></td>
<td><?=$value['number'];?></td>
<td><?=$strDate;?></td>
<td><?=$strweek[$current_week];?></td>
</tr>
<?php
}
}else{
echo "<tr><td colspan='5'>无记录</td></tr>";
}
?>
</table>
</section>
</div>
</div>
<div class="span4">
<div class="well">
<p>
姓名:<?=$username;?>
</p>
<p>
日期:<?=$current_day;?>
</p>
<p>
星期:<?=$current_week==0?7:$current_week;;?>
</p>
<p>
<a href="user.php">查看其员工</a>
</p>
</div>
<div>
<form class="form-horizontal" action="?act=chk" method="get" onsubmit="return validate();">
<label class="" for="number">编号</label>
<input type="text" name="number" id="number" value="<?=$_REQUEST && $_REQUEST['number']?$_REQUEST['number']:'';?>" placeholder="number">
<div class="control-group">
<div class="controls">
<input type="hidden" name="p" value="<?=$page; ?>"/>
<button type="submit" class="btn">查询</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<footer style="text-align: center;">
<p>
© Copyright by monica
</p>
</footer>
</div>
</body>
</html>