20,359
社区成员
发帖
与我相关
我的任务
分享
<?php
require_once ('../core/fun.class.php');
$fun=new fun();
$users=$fun->SelectAdmin();
$userkq=$fun->SelectUserkq();
foreach ($users as $item) {
$item['kqh'] = $fun->query('select * from userkq where agonghao=?', [$item['gonghao']]);
$newUsers[] = $item;
}
$ausers=$newUsers;
$ret=$fun->query('select * from userkq ',[]);
$arr=[];
foreach ($ret as $k=>$v){
$arr[$v['agonghao']][]=$v['kqday'];
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>用户信息</title>
<?php include ('inde.php');?>
</head>
<body>
<div class="table">
<div class="m-right">
<div class="xqbottom" >
</div>
<div class="userkqchuang">
</div>
<h3>开发科(<?php echo date("Y-m");?>)</h3><h4><?php $days = date("t"); ?></h4>
<table class="user_table" id="userkq_user" style="margin-bottom: 10px;" onmouseover="cells_color()" onmouseout="cells_color()">
<tr>
<th style="width: 30px;">ID</th>
<th class="userkq_bt">选择</th>
<th class="userkq_bt">姓名</th>
<th class="userkq_bt">工码</th>
<th class="userkq_bt">出勤</th>
<th class="userkq_bt">调休</th>
<th class="userkq_bt">加班</th>
<th class="userkq_bt">旷工</th>
<th class="userkq_bt">夜班</th>
<th class="userkq_bt">病假</th>
<th class="userkq_bt">事假</th>
<th class="userkq_bt">婚假</th>
<th class="userkq_bt">产假</th>
<th class="userkq_bt">丧假</th>
<th class="userkq_bt">工伤</th>
<th class="userkq_bt">探亲</th>
<th class="userkq_bt">可用调休</th>
<?php for($i=1;$i<=$days;$i++){
if($i==1){echo "<th class=\"userkq_bt\">姓名</th>";}
if($i==10){echo "<th class=\"userkq_bt\">姓名</th>";}
if($i==20){echo "<th class=\"userkq_bt\">姓名</th>";}
echo "<th class=\"userkq_btt\">".$i."</th>";
}?>
</tr>
<tr >
<?php foreach ($ausers as $key=>$item){ ?>
<td><?php echo $item['id'] ;?></td>
<td ><input type="checkbox" name="rem" value="<?php echo $item['id'];?>"></td>
<td><?php echo $item['username'];?></td>
<td><?php echo $item['gonghao'];?></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<?php for($i=1;$i<=($days);$i++){
if($i==1){echo "<td class=\"userkq_bt\">".$item['username']."</td>";}
if($i==10){echo "<td class=\"userkq_bt\">".$item['username']."</td>";}
if($i==20){echo "<td class=\"userkq_bt\">".$item['username']."</td>";}
$tt = $fun->query('select * from userkq where agonghao=?', [$item['gonghao']]);
if($tt){
foreach ($item['kqh'] as $k=>$v){
if($v['kqday']==$i){
echo "<td ondblclick=\"openXiangqingkq($i,$key)\">".$v['userkqh'].mb_substr($v['userkqfujia'],0,1).$v['userkqfujiah']."</td>";
//错误的算法 $array[]=$v['userkqh'];
// 在上面echo $sum $sum=array_sum($array);
}
}
//
if(!in_array($i,$arr[$item['gonghao']])){
echo "<td ondblclick=\"openXiangqingkq($i,$key)\"></td>";
}
}else{
echo "<td ondblclick=\"openXiangqingkq($i,$key)\"></td>";
}
}
}?>
</tr>
<?php }?>
</table>
<div class="userkq_button">
<input type="button" id="userkqbutton" onclick="saveUserkqup()" value="提交"><input type="checkbox" value="">全选
</div>
</div>
</div>
</body>
</html>
<?php for($i=1;$i<=($days);$i++){
if($i==1){echo "<td class=\"userkq_bt\">".$item['username']."</td>";}
if($i==10){echo "<td class=\"userkq_bt\">".$item['username']."</td>";}
if($i==20){echo "<td class=\"userkq_bt\">".$item['username']."</td>";}
$tt = $fun->query('select * from userkq where agonghao=?', [$item['gonghao']]);
//按照工号查询表
if($tt){
foreach ($item['kqh'] as $k=>$v){
if($v['kqday']==$i){
//$i与$key是横坐标,纵坐标,双击触发事件,可以输入考勤时间,是否加班,加班多久。IF是判断字段天数与横坐标是否相同,相同输出,考勤时间。
echo "<td ondblclick=\"openXiangqingkq($i,$key)\">".$v['userkqh'].mb_substr($v['userkqfujia'],0,1).$v['userkqfujiah']."</td>";
//之前我在这里用了一个$sum+=$v['userkqh'];然后在上面出勤<td>中打印$sum.结果是累加的。48,96,1XX,1XX遍历打印出来。
}
}
//
if(!in_array($i,$arr[$item['gonghao']])){
echo "<td ondblclick=\"openXiangqingkq($i,$key)\"></td>";
}
}else{
echo "<td ondblclick=\"openXiangqingkq($i,$key)\"></td>";
}
}?>