【php开源代码栏目提醒】:网学会员鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“AdminEmployee.php”一文,供大家参考学习
<?php
require_once("common/common.php");
require_once("common/page.php");
require_once("Employee.php");
//**********************************************************
class CThisPage extends CPhpPage
{
public $m_employees;
public $m_employee;
public $m_ids;
public function __construct()
{
parent::__construct(__FILE__);
$this->Dispatch();
}
public function OnLoad($para)
{
parent::setPageTitle('员工管理');
if($this->IsPostBack()) {
$this->m_ids = $_POST['ids'];
$this->m_employee = new Employee();
$this->m_employee->m_name = trim($_POST['name']);
$this->m_employee->m_education = trim($_POST['education']);
$this->m_employee->m_borntime = trim($_POST['borntime']);
$this->m_employee->m_email = trim($_POST['email']);
$this->m_employee->m_phone = trim($_POST['phone']);
$this->m_employee->m_duty = trim($_POST['duty']);
}
return true;
}
public function OnFinalize()
{
Employee::getAll($this->m_employees);
}
public function btnToAdd_click($para = null)
{
if(!$this->validate()) return;
$this->m_employee = new Employee();
$this->setPageAction('ADD');
}
public function btnAdd_click($para = null)
{
if(!$this->validate()) return;
if(!$this->m_employee->add()) {
$this->setError('添加失败');
}
}
public function btnDelete_click($para = null)
{
if(!$this->validate()) return;
Employee::deleteById($this->m_ids);
}
public function linkToEdit_click($para = null)
{
if(!$this->validate() || empty($para)) return;
$this->m_employee = Employee::getById($para);
$this->setPageAction('EDIT');
}
public function btnEdit_click($para = null)
{
if(!$this->validate() || empty($para)) return;
if(!$this->m_employee->edit($para)) {
$this->setError('修改失败');
}
}
// 服务器端数据验证函数
public function validate()
{
// ... 实现略
return true;
}
}
$page = new CThisPage();
require_once('common/header.inc.php');
?>
<form name='frmSubmit' method='post' action='AdminEmployee.php'>
<?$page->vsLocate();?>
<script language="javascript">
<!--
function doAddCheck(){
if(document.frmSubmit.name.value==""){
alert('请输入!');
return false;
}
if(document.frmSubmit.borntime.value==""){
alert('请输入出生日期!');
return false;
}
if(document.frmSubmit.email.value==""){
alert('请输入Email!');
return false;
}
if(document.frmSubmit.phone.value==""){
alert('请输入电话!');
return false;
}
// 使用正则表达式验证出生日期的格式
var pattern = /^((19)|(20))\d{2}-((0[1-9])|(1[1-2]))-((0[1-9])|([1-2]\d)|(3[0-1]))$/;
if (! pattern.test(document.frmSubmit.borntime.value) ) {
alert('出生日期填写不正确!');
return false;
}
// 使用正则表达式验证Email的格式
var pattern = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if (! pattern.test(document.frmSubmit.email.value) ) {
alert('Email填写不正确!');
return false;
}
// 使用正则表达式验证电话号码的格式
var pattern = /^[\d, -]{7,}$/;
if (! pattern.test(document.frmSubmit.phone.value) ) {
alert('电话填写不正确!');
return false;
}
return true;
}
-->
</script>
<table border='1' cellpadding='3' cellspacing='0' width='100%' bordercolor='skyblue' style='border-collapse:collapse'>
<tr class='caption_bg'><th></th><th></th><th>学历</th><th>出生日期</th><th>Email</th><th>电话</th><th>职务</th><th>操作</th></tr>
<?php
for($i = 0; $i < count($page->m_employees); ++$i) {
$employee = $page->m_employees[$i];
$color = $i % 2 ? '#eeeeee' : 'ffffff';
echo "<tr bgcolor='$color'>";
echo "<td><input type='checkbox' id='ids<?echo $i;?>' name='ids[]' value='{$employee->m_id}'/></td>";
echo "<td>{$employee->m_name}</td>";
echo "<td>{$employee->m_education}</td>";
echo "<td>" . reformat_date_ymd($employee->m_borntime) . "</td>";
echo "<td>{$employee->m_email}</td>";
echo "<td>{$employee->m_phone}</td>";
echo "<td>{$employee->m_duty}</td>\n";
echo "<td><a href=\"javascript:VsEvent('linkToEdit_click({$employee->m_id})')\">编辑</a></td></tr>\n";
}
?>
</table>
<br />
<div id='to_add' class='<?echo ($page->isOk() && $page->getPageAction() == 'SHOW')?'assistBar':'hidden';?>'>
<a class='link_btn' href="javascript:VsEvent('btnToAdd_click()');">添加</a>
<a class='link_btn' href="javascript:VsEvent('btnDelete_click()')">删除</a>
</div>
<div id='frmAdd' <?if($page->isOk() && $page->getPageAction() == 'SHOW') echo "class='hidden'";?> >
<table border='0' cellpadding='5' cellspacing='0' width='420