代码拉取完成,页面将自动刷新
<?php
include_once('config/config.php');
$LoginAuth = checkAuth();
$size = 2;
$page = 1;
if ($_GET) {
$deleteid = trim($_GET['deleteid']) ?? '';
$page = $_GET['page'] ?? 1;
$size = $_GET['size'] ?? 2;
if ($deleteid) {
$res = del('person', "`id` = '$deleteid'");
if ($res['code'] === 0) {
showMsg($res['msg']);
} else {
showMsg($res['msg'], 'psList.php');
}
}
}
$start = ($page - 1) * $size;
$countsql = "select count(*) from `pre_person`";
$count = find($countsql);
// $sql = "select * from `pre_department` limit $start,$size";
$sql = "select `p`.*,`j`.name as job,`d`.name as department,`r`.province as r1, `r`.city as r2,`r`.district as r3 from `pre_person` as `p` left join `pre_job` as `j` on `p`.jobid = `j`.id left join `pre_department` as `d` on `p`.depid = `d`.id left join `pre_region` as `r` on `r`.parentpath rlike `p`.district order by id desc limit $start,$size";
$data = all($sql);
// pre($sql);
$ShowPage = showPage($page,$count['count(*)'],$size,3);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- 引入样式 -->
<?php include_once('common/meta.php'); ?>
</head>
<body>
<!-- 引入头部 -->
<?php include_once('common/header.php'); ?>
<!-- 引入菜单栏 -->
<?php include_once('common/menu.php'); ?>
<div class="content">
<div class="header">
<h1 class="page-title">员工列表</h1>
</div>
<ul class="breadcrumb">
<li><a href="index.php">Home</a> <span class="divider">/</span></li>
<li class="active">员工列表</li>
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="btn-toolbar">
<button class="btn btn-primary" onClick="location='psAdd.php'"><i class="icon-plus"></i>添加员工</button>
</div>
<div class="well">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>姓名</th>
<th>头像</th>
<th>手机号</th>
<th>邮箱</th>
<th>性别</th>
<th>职位</th>
<th>部门</th>
<th>省</th>
<th>市</th>
<th>区</th>
<th>详细地址</th>
<th>入职时间</th>
<th style="width: 26px;"></th>
</tr>
</thead>
<tbody>
<?php foreach ($data as $item) { ?>
<tr>
<td><?php echo $item['id']; ?></td>
<td><?php echo $item['name']; ?></td>
<td>
<a href="<?php echo @is_file(ltrim($item['avatar'],'/')) ? $item['avatar'] : '/assets/images/avatar.png';?>" target="_blank">
<img src="<?php echo @is_file(ltrim($item['avatar'],'/')) ? $item['avatar'] : '/assets/images/avatar.png';?>" width="35" alt="">
</a>
</td>
<td><?php echo $item['mobile']; ?></td>
<td><?php echo $item['email']; ?></td>
<td>
<?php
switch($item['sex'])
{
case 0:
echo '保密';
break;
case 1:
echo '男';
break;
case 2:
echo '女';
break;
}
?>
</td>
<td><?php echo $item['job']; ?></td>
<td><?php echo $item['department']; ?></td>
<td><?php echo $item['r1']; ?></td>
<td><?php echo $item['r2']; ?></td>
<td><?php echo $item['r3']; ?></td>
<td><?php echo $item['address']; ?></td>
<td>
<?php echo date('Y-m-d',$item['createtime']); ?>
</td>
<td>
<a href="psEdit.php?id=<?php echo $item['id']; ?>"><i class="icon-pencil"></i></a>
<a onclick="del(<?php echo $item['id']; ?>)"><i class="icon-remove"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php echo $ShowPage; ?>
<!-- 引入底部 -->
<?php include_once('common/footer.php'); ?>
</div>
</div>
</div>
</body>
</html>
<!-- 引入js -->
<?php include_once('common/script.php'); ?>
<script>
function del(id) {
let a = confirm('确认删除该条记录?');
if (a) {
location.href = 'psList.php?deleteid=' + id;
}
}
</script>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。