You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
simple-yewu/frontend/views/user/edit.php

408 lines
23 KiB

<?php
use \common\libs\MyLib;
?>
<link href="/css/tabs.css" rel="stylesheet" type="text/css">
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/datepicker/WdatePicker.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript" src="/js/common2.js"></script>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<tr>
<td height="22" colspan="2" class="td_bg">
<form id="theFrm">
<input type="hidden" name="id" value="<?=$info->id?>">
<table width="100%" align="center" height="120" border="0" cellpadding="0" cellspacing="0" id="mainTable">
<tr>
<td height="120" valign="top" class="td_bg">
<!--员工信息-->
<table>
<tbody>
<tr>
<TD height="30" align="center" class=tab-on id=navcell onclick=open_up(1) name="navcell">▼员工信息</TD>
</tr>
</tbody>
</table>
<TABLE id=tb1 cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb">
<tr>
<td width="100" height="25" class="bg_tr">工号</td>
<td height="25" class="td_bg"><?php
if($info->id == 1) {
echo $info->username;
} else {
echo '<input name="username" type="text" value="'.$info->username.'" style="width:300px;"/>';
}
?></td>
<td width="100" height="25" class="bg_tr">登录密码</td>
<td height="25" class="td_bg"><input name="password" type="text" value="" style="width:300px;"/></td>
</tr>
<tr>
<td width="100" height="25" class="bg_tr">姓名</td>
<td height="25" class="td_bg"><input name="name" type="text" value="<?=$info->name?>" style="width:300px;"/></td>
<td width="100" height="25" class="bg_tr">联系电话</td>
<td height="25" class="td_bg"><input name="phone" type="text" value="<?=$info->phone?>" style="width:300px;"/></td>
</tr>
<tr>
<td width="100" height="25" class="bg_tr">电话分机</td>
<td height="25" class="td_bg">
<input name="ext_phone" type="text" value="<?=$info->ext_phone?>" style="width:300px;"/>
</td>
<td width="100" height="25" class="bg_tr">电话服务器</td>
<td height="25" class="td_bg">
<select name="phone_server_id" style="width:200px;">
<option value="0">&nbsp;</option>
<?php
foreach($phone_server_items as $phone_server) {
echo '<option value="'.$phone_server->id.'"';
if($phone_server->id == $info->phone_server_id)
echo ' selected ';
echo '>'.$phone_server->name.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td width="100" height="25" class="bg_tr">所属公司</td>
<td height="25" class="td_bg">
<select name="company_id" id="company_id" style="width:200px;">
<option value="0">&nbsp;</option>
<?php
foreach($company_items as $company) {
echo '<option value="'.$company->id.'"';
if($company->id == $info->company_id)
echo ' selected ';
echo '>'.$company->name.'</option>';
}
?>
</select>
</td>
<td width="100" height="25" class="bg_tr">所属部门</td>
<td height="25" class="td_bg">
<select name="department_id" id="department_id" style="width:200px;">
<option value="0">&nbsp;</option>
<?php
foreach($department_items as $department) {
echo '<option value="'.$department->id.'"';
if($department->id == $info->department_id)
echo ' selected ';
echo '>'.$department->name.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td width="100" height="25" class="bg_tr">所属岗位</td>
<td height="25" class="td_bg">
<select name="group_id" style="width:200px;">
<option value="0">&nbsp;</option>
<?php
foreach($group_items as $group) {
echo '<option value="'.$group->id.'"';
if($group->id == $info->group_id)
echo ' selected ';
echo '>'.$group->name.'</option>';
}
?>
</select>
</td>
<td width="100" height="25" class="bg_tr">允许登录</td>
<td height="25" class="td_bg">
<label>
<input name="is_login" type="checkbox" value="1" <?=$info->is_login==1?'checked':''?>/>是
</label>
</td>
</tr>
<tr>
<td width="100" height="25" class="bg_tr">角色</td>
<td height="25" class="td_bg">
<select name="role_id" style="width:200px;">
<?php
foreach($role_items as $role) {
echo '<option value="'.$role->id.'"';
if($role->id == $info->role_id)
echo ' selected ';
echo '>'.$role->name.'</option>';
}
?>
</select>
</td>
<td width="100" height="25" class="bg_tr">允许外网登陆</td>
<td height="25" class="td_bg">
<label>
<input name="is_outer" type="checkbox" value="1" <?= $info->is_outer==1?'checked':'' ?> />是
</label>
</td>
</tr>
<tr>
<td width="100" height="25" class="bg_tr">业务分组</td>
<td height="25" class="td_bg">
<select name="business_group_id">
<option value="0">请选择</option>
<?php
foreach ($business_group as $index => $item){
echo '<option value="'.$item->id.'"';
echo $item->id == $info->business_group_id ? 'selected' : '';
echo '>'.$item->name.'</option>';
}
?>
</select>
</td>
<td width="100" height="25" class="bg_tr">是否离职</td>
<td height="25" class="td_bg">
<label>
<input name="is_leave" type="checkbox" value="1" <?= $info->is_leave==1?'checked':'' ?> />是
</label>
</td>
</tr>
<tr>
<td width="100" height="25" class="bg_tr"></td>
<td height="25" class="td_bg"></td>
<td width="100" height="25" class="bg_tr">是否送单</td>
<td height="25" class="td_bg">
<label>
<input name="is_send" type="checkbox" value="1" <?= $info->is_send==1?'checked':'' ?> />是
</label>
</td>
</tr>
</table>
<!--薪酬信息-->
<table>
<tbody>
<tr>
<TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(2) name="navcell">▲薪酬信息</TD>
</tr>
</tbody>
</table>
<TABLE id=tb2 cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
<tr>
<td width="100" height="25" class="bg_tr">入职日期</td>
<td width="200" height="25" class="td_bg">
<input class="act_date" name="enter_date" type="text" value="<?=$info->enter_date?>" style="width:120px;" onclick="WdatePicker()"/>
</td>
<td width="100" height="25" class="bg_tr">转正时间</td>
<td height="25" class="td_bg">
<input name="job_date" type="text" value="<?=$info->job_date?>" style="width:120px;" onclick="WdatePicker()"/>
</td>
</tr>
<tr>
<td width="100" height="25" class="bg_tr">调整工资</td>
<td height="25" class="td_bg"><input name="ext_pay" type="text" value="<?=$info->ext_pay?>" style="width:120px;"/>元</td>
<td width="100" height="25" class="bg_tr">总工资</td>
<td height="25" class="td_bg"><span id="total_pay">0.00</span>元</td>
</tr>
<tr>
<td width="100" height="25" class="bg_tr">试用工资(%)</td>
<td height="25" class="td_bg">
<input name="try_rate" type="text" value="<?=$info->try_rate?>" style="width:120px;"/>%
</td>
<td width="100" height="25" class="bg_tr">试用工资</td>
<td height="25" class="td_bg">
<input name="try_pay" type="text" value="<?=$info->try_pay?>" style="width:120px;"/>元
</td>
</tr>
<tr>
<td width="100" height="25" class="bg_tr">工作制</td>
<td height="25" class="td_bg">
<select name="worktype_id">
<option value="0">请选择</option>
<?php
foreach($worktypes as $worktype) {
echo '<option value="'.$worktype->id.'"';
if($info->worktype_id == $worktype->id)
echo ' selected ';
echo '>'.$worktype->name.'</option>';
}
?>
</select>
</td>
<td width="100" height="25" class="bg_tr">是否双休</td>
<td height="25" class="td_bg">
<label>
<input type="checkbox" name="is_double" value="1" <?=$info->is_double == 1 ? 'checked' : ''?> />是
</label>
</td>
</tr>
</table>
<!--权限分配-->
<table>
<tbody>
<tr>
<TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(3) name="navcell">▲权限分配</TD>
</tr>
</tbody>
</table>
<TABLE id=tb3 cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
<tr>
<td width="100" height="25" class="bg_tr">权限</td>
<td height="25" class="bg_tr">一级菜单(二级菜单)</td>
</tr>
<?php
foreach($permissions as $permission) {
$parent_menus = $permission->getMenus()
->where('parent_id=0')
->all();
?>
<tr>
<td width="100" height="25" class="bg_tr">
<?php
echo '<label>';
echo '<input class="checkbox" type="checkbox" name="permissions[]" value="'.$permission->id.'"';
if($info->getPermissions()->where('id='.$permission->id)->count() > 0)
echo ' checked ';
echo '>'.$permission->name;
echo '</label>';
?>
</td>
<td height="25" class="td_bg">
<?php
foreach ($parent_menus as $parent_menu) {
echo '<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" id="mainTable">';
echo '<tr>';
echo '<td width="100" height="25" class="bg_tr">';
echo '<label>';
echo '<input class="checkbox" type="checkbox" name="menus[]" value="'.$parent_menu->id.'"';
if($info->getMenus()->where('id='.$parent_menu->id)->count() > 0)
echo ' checked ';
echo '>' . $parent_menu->name;
echo '</label>';
echo '</td>';
echo '<td height="25" class="td_bg">';
$child_menus = $permission->getMenus()
->where('parent_id=' . $parent_menu->id)
->all();
foreach ($child_menus as $child_menu) {
echo '<label>';
echo '<input class="checkbox" type="checkbox" name="menus[]" value="'.$child_menu->id.'"';
if($info->getMenus()->where('id='.$child_menu->id)->count() > 0)
echo ' checked ';
echo '>' . $child_menu->name;
echo '</label>';
}
echo '</td>';
echo '</tr>';
echo '</table>';
}
?>
</td>
</tr>
<?php
}
?>
</table>
</td>
</table>
</form>
</td>
</tr>
<tr>
<td height="22" align="center" class="td_bg">
<input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/>
&nbsp;&nbsp;
<input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 ">
</td>
</tr>
</table>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
//点击折叠页面
function switchCell(n){
var obj = $('#tb'+n);
var title = obj.prev().find('td').html();
obj.toggle();
if(obj.is(":hidden"))
obj.prev().find('td').html(title.replace(/▼/, "▲"));
else
obj.prev().find('td').html(title.replace(/▲/, "▼"));
}
//点击效果
$('input[name="permissions[]"]').change(function(){
var b = $(this).parent().parent().next().find('input');
//获取状态
var st = $(this).attr('checked');
if(st == 'checked'){
b.attr('checked',true);
}else{
b.attr('checked',false);
}
});
$('input[name="menus[]"]').change(function(){
//获取一级菜单
var top = $(this).parents().eq(5).prev().find('input');
//判断当前是几级菜单
var who = $(this).parents().eq(1).nextAll().length;
//当前的状态
var st = $(this).attr('checked');
//三级菜单
if(who == '0'){
var _prev = $(this).parent().parent().prev().find('input');
if(st == 'checked'){
top.attr('checked',true);
_prev.attr('checked',true);
}else{
var _list = $(this).parent().parent().children().find('input');
for(var i = 0; i < _list.length; i++){
if(_list.eq(i).attr('checked') == 'checked'){
return;
}
}
//判断是否有其他的二级菜单
// top.attr('checked',false);
// _prev.attr('checked',false);
}
}else{
var _next = $(this).parent().parent().next().find('input');
if(st == 'checked') {
top.attr('checked', true);
_next.attr('checked', true);
}else{
// top.attr('checked',false);
_next.attr('checked',false);
}
}
});
//提交按钮
$("#submit-btn").click(function(){
if(confirm('是否确认提交?')) {
var params = $("#theFrm").serialize();
$.post('/user/save',params,function(obj){
alert(obj.msg);
if(obj.success) {
$('#back-btn').click();
}
},'json');
}
});
//返回按钮
$('#back-btn').click(function(){
window.location.href='/user/index?<?=$back_params?>';
});
//公司选择
$('#company_id').change(function(){
var company_id = $(this).val();
$('#department_id').html('<option value="0">---请选择---</option>');
if(company_id > 0) {
$.get('/company/departments',{company_id:company_id},function(obj){
if(obj.success) {
$('#department_id').html(obj.html);
}
},'json');
}
});
</script>