提交测试

dev
曾超新 5 years ago
parent 208268d159
commit 32ddd11a67
  1. 55
      common/models/NetworkPhoneAssignT.php
  2. 55
      common/models/NetworkPhoneSubT.php
  3. 93
      common/models/NetworkPhoneT.php
  4. 60
      frontend/controllers/PersonnelController.php
  5. 257
      frontend/views/personnel/pay-list.php

@ -0,0 +1,55 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "network_phone_assign_t".
*
* @property int $id
* @property int $user_id
* @property string $created_at
* @property string $updated_at
* @property int $phone
*/
class NetworkPhoneAssignT extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'network_phone_assign_t';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['user_id', 'phone'], 'integer'],
[['created_at', 'updated_at'], 'safe'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
'phone' => 'Phone',
];
}
public function getUser()
{
return $this->hasOne(UserT::className(),['id'=>'user_id']);
}
}

@ -0,0 +1,55 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "network_phone_assign_t".
*
* @property int $id
* @property int $user_id
* @property string $created_at
* @property string $updated_at
* @property int $phone
*/
class NetworkPhoneSubT extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'network_phone_sub_t';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['assign_id', 'phone'], 'integer'],
[['created_at', 'updated_at'], 'safe'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
'phone' => 'Phone',
];
}
public function getUser()
{
return $this->hasOne(UserT::className(),['id'=>'user_id']);
}
}

@ -0,0 +1,93 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "network_phone_t".
*
* @property int $id
* @property string $corp_key
* @property int $ts
* @property string $sign
* @property string $recorder_id
* @property string $caller
* @property string $called
* @property string $caller_show
* @property string $called_show
* @property string $begin_time
* @property string $connect_time
* @property string $alerting_time
* @property string $release_time
* @property int $call_duration
* @property int $bill_duration
* @property string $call_result
* @property string $record_file_url
* @property string $call_cost
* @property string $caller_area
* @property string $called_area
* @property string $extend
*/
class NetworkPhoneT extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'network_phone_t';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id'], 'required'],
[['id', 'ts', 'call_duration', 'bill_duration'], 'integer'],
[['corp_key'], 'string', 'max' => 225],
[['sign', 'begin_time', 'connect_time', 'alerting_time', 'release_time', 'call_result', 'record_file_url'], 'string', 'max' => 255],
[['recorder_id'], 'string', 'max' => 128],
[['caller', 'called', 'caller_show', 'called_show', 'caller_area', 'called_area'], 'string', 'max' => 32],
[['call_cost', 'extend'], 'string', 'max' => 10],
[['id'], 'unique'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'corp_key' => 'Corp Key',
'ts' => 'Ts',
'sign' => 'Sign',
'recorder_id' => 'Recorder ID',
'caller' => 'Caller',
'called' => 'Called',
'caller_show' => 'Caller Show',
'called_show' => 'Called Show',
'begin_time' => 'Begin Time',
'connect_time' => 'Connect Time',
'alerting_time' => 'Alerting Time',
'release_time' => 'Release Time',
'call_duration' => 'Call Duration',
'bill_duration' => 'Bill Duration',
'call_result' => 'Call Result',
'record_file_url' => 'Record File Url',
'call_cost' => 'Call Cost',
'caller_area' => 'Caller Area',
'called_area' => 'Called Area',
'extend' => 'Extend',
];
}
public function getUser()
{
return $this->hasOne(UserT::className(),['id'=>'user_id']);
}
}

@ -15,6 +15,8 @@ use yii\web\UploadedFile;
class PersonnelController extends \frontend\controllers\UserBaseController
{
public $my = null;
public $enableCsrfValidation = false;
public $layout = 'blue-main';
public function init()
{
@ -38,52 +40,60 @@ class PersonnelController extends \frontend\controllers\UserBaseController
*/
public function actionPayList()
{
$pay_date = date('Y-m');
$group_items = GroupT::getTree();
return $this->render('pay-list',[
'group_items' => $group_items,
'pay_date' => $pay_date
]);
}
public function actionPayListJson()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$username = $request->get('username');
$name = $request->get('name');
$pay_date = $request->get('pay_date',date('Y-m'));
$group_id = $request->get('group_id',0);
$page = $request->get('page',1);
$is_leave = $request->get('is_leave');
$offset = $request->get('offset',0);
$limit = $request->get('limit', 10);
$query = UserT::find()
->where('group_id>0 and is_delete=0');
if($username != '') {
$query = $query->andWhere('username like "'.$username.'"');
$query->andWhere('username like "'.$username.'"');
}
if($name != '') {
$query = $query->andWhere('name like "'.$name.'"');
$query->andWhere('name like "'.$name.'"');
}
if($is_leave != ''){
$query = $query->andWhere(['is_leave' => $is_leave]);
if($is_leave == 'true'){
$query->andWhere(['is_leave' => 1]);
}
if($group_id > 0) {
$query = $query->andWhere('group_id='.$group_id);
$query->andWhere('group_id='.$group_id);
}
$query = $query->orderBy('username ASC,id ASC');
$query->orderBy('username ASC,id ASC');
$total = $query->count();
$pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]);
$pagination->setPage($page-1);
$query = $query->offset($pagination->offset)->limit($pagination->limit);
$query = $query->offset($offset)->limit($limit);
$items = $query->all();
$page_info = MyLib::getPageInfo($pagination);
$group_items = GroupT::getTree();
$data = [];
$data['total'] = $total;
$data['rows'] = [];
foreach($items as $item) {
$row = $item->toArray();
$row['pay_date'] = $pay_date;
$row['group_path'] = $item->group ? $item->group->getPath():'';
$pay = $item->getPay($pay_date);
$row['real_pay'] = $pay ? $pay->real_pay : '0.00';
$row['is_leave'] = $item->is_leave == 1 ? '已离职':'';
$data['rows'][] = $row;
}
return $this->render('pay-list',[
'group_items' => $group_items,
'items' => $items,
'page_info' => $page_info,
'page' => $page,
'username' => $username,
'name' => $name,
'pay_date' => $pay_date,
'group_id' => $group_id,
'is_leave' => $is_leave
]);
return $data;
}
/**

@ -1,164 +1,139 @@
<?php
use \common\libs\MyLib;
?>
<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">
//编辑
function edit(id) {
var params = $('#searchForm').serialize();
window.location.href = '/personnel/pay-info?id=' + id + '&pay_date=<?=$pay_date?>' + '&back_params=' + encodeURIComponent(params);
}
$(function(){
$("#search-btn").click(function(){
$('#page').val(0);
var params = $('#searchForm').serialize();
window.location.href = "/personnel/pay-list?" + params;
});
$("#searchForm").submit(function(){
$("#search-btn").click();
return false;
});
});
<?php $this->beginBlock('header_css'); ?>
<link href="/assets/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<?php $this->endBlock(); ?>
</script>
<!--<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">-->
<!-- <form id="theFrm">-->
<!-- <tr>-->
<!-- <td align="center" width="100" height="25" class="bg_tr">日期</td>-->
<!-- <td class="td_bg">-->
<!-- <input type="text" name="time" onclick="WdatePicker({dateFmt:'yyyy-MM'})" />-->
<!-- </td>-->
<!-- <td height="25" class="td_bg">-->
<!-- <input type="text" name="urlfile" id="urlfile" style="width: 300px;">-->
<!-- <input id="fileupload" type="file" name="file">-->
<!-- </td>-->
<!-- </tr>-->
<!-- <tr>-->
<!-- <td height="22" colspan="3" align="center" class="td_bg">-->
<!-- <input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/>-->
<!-- &nbsp;&nbsp;-->
<!-- <input type="button" class="ACT_btn" name="Submit3" value=" 刷新 " onclick="window.location.reload();">-->
<!-- </td>-->
<!-- </tr>-->
<!-- </form>-->
<!--</table>-->
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<form id="searchForm">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<tr>
<td class="td_bg">
工号:<input name="username" type="text" value="<?=$username?>">
真实姓名:<input name="name" type="text" value="<?=$name?>">
工资月份:<input name="pay_date" id="pay_date" class="Wdate" type="text" value="<?=$pay_date?>" onClick="WdatePicker({dateFmt:'yyyy-MM'})">
是否离职:<select name="is_leave">
<div class="wrapper wrapper-content animated fadeInRight">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>工资管理</h5>
<div class="ibox-tools">
<a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="$('#listTable').bootstrapTable('refresh');">
<i class="fa fa-refresh"></i> 刷新
</a>
</div>
</div>
<div class="ibox-content">
<form role="form" class="form-horizontal" onsubmit="return search();">
<div class="form-group">
<label class="col-sm-1 control-label">工号</label>
<div class="col-sm-2">
<input type="text" name="username" id="username" class="form-control">
</div>
<label class="col-sm-1 control-label">真实姓名</label>
<div class="col-sm-2">
<input type="text" name="name" id="name" class="form-control">
</div>
<label class="col-sm-1 control-label">工资月份</label>
<div class="col-sm-2">
<div class="input-group date">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input type="text" name="pay_date" id="pay_date" class="form-control" autocomplete="off" value="<?=$pay_date?>">
</div>
</div>
<div class="col-sm-2">
<div class="checkbox checkbox-inline">
<input type="checkbox" id="is_leave" name="is_leave" value="1">
<label for="is_leave"> 是否离职 </label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">分组</label>
<div class="col-sm-2">
<select name="group_id" id="group_id" class="form-control">
<option value="">全部</option>
<option value="1" <?= $is_leave == '1' ? 'selected' : ''?>></option>
<option value="0" <?= $is_leave == '0' ? 'selected' : ''?>></option>
</select>
分组:<select name="group_id">
<option value="0">全部</option>
<?php
foreach($group_items as $group) {
echo '<option value="'.$group->id.'"';
if($group->id == $group_id)
echo ' selected ';
echo '>'.$group->name.'</option>';
foreach($group_items as $item) {
echo '<option value="'.$item->id.'">'.$item->name.'</option>';
}
?>
</select>
<input type="submit" class="act_btn" id="search-btn" name="search-btn" value="搜索">
</td>
</tr>
</div>
<div class="col-sm-3">
<button type="submit" class="btn btn-primary">搜索</button>
</div>
</div>
</form>
</table>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<div class="row">
<div class="col-md-12">
<table id="listTable">
<thead>
<tr>
<td width="100" align="center" align="center" class="bg_tr">工号</td>
<td align="center" class="bg_tr">真实姓名</td>
<td width="100" align="center" class="bg_tr">工资月份</td>
<td align="center" class="bg_tr">所属岗位</td>
<td width="60" align="center" class="bg_tr">角色</td>
<td align="left" class="bg_tr">提成公式</td>
<td width="60" align="center" class="bg_tr">工资</td>
<td width="60" align="center" class="bg_tr">是否离职</td>
<td width="30" align="center" class="bg_tr">操作</td>
</tr>
<form id="delFrm">
<?php
foreach($items as $index => $item) {
$pay_info = $item->getPay($pay_date);
$real_pay = 0;
if($pay_info)
$real_pay = $pay_info->real_pay;
?>
<tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
<td align="left" class="td_bg" nowrap ><?=$item->username?></td>
<td class="td_bg" nowrap><?=$item->name?></td>
<td class="td_bg" nowrap><?=$pay_date?></td>
<td align="left" class="td_bg" nowrap><?=$item->group?$item->group->getPath():''?></td>
<td class="td_bg" nowrap><?=$item->role?$item->role->name:''?></td>
<td align="left" class="td_bg" nowrap><?=$pay_info?$pay_info->formulae:''?></td>
<td align="center" class="td_bg" nowrap data="<?=$item->id?>">
<?=number_format($real_pay,2)?>
</td>
<td align="center" class="td_bg" nowrap><?=$item->is_leave?'是':''?></td>
<td align="center" class="td_bg" nowrap>
[<a href="javascript:void(0);" onclick="edit(<?=$item->id?>)">维护</a>]
</td>
<th data-field="state" data-checkbox="true"></th>
<th width="50" data-field="id">ID</th>
<th data-field="username">工号</th>
<th data-field="name">真实姓名</th>
<th data-field="pay_date">工资月份</th>
<th data-field="group_path">所属岗位</th>
<th data-field="real_pay">工资</th>
<th data-field="is_leave">是否离职</th>
<th data-formatter="opFormatter">操作</th>
</tr>
<?php
}
?>
</form>
<tr >
<td height="25" colspan="11" align="center" class="td_bg"><?=$page_info?></td>
</tr>
</table>
<script type="text/javascript" language="javascript" src="/js/common2.js"></script>
<script type="text/javascript" language="javascript" src="/js/fileupload/js/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" language="javascript" src="/js/fileupload/js/jquery.iframe-transport.js"></script>
<script type="text/javascript" language="javascript" src="/js/fileupload/js/jquery.fileupload.js"></script>
<script type="text/javascript">
//上传文件
$('#fileupload').fileupload({
url: '/personnel/upload',
dataType: 'json',
done: function (e, data) {
var file_info = data.result.files[0];
$('#urlfile').val(file_info.url);
$('#submit-btn').removeAttr('disabled');
}
});
</thead>
</table>
</div>
</div>
</div>
</div>
</div>
//提交
$('#submit-btn').click(function(){
if(confirm('是否确认提交?')){
var file_path = $('#urlfile').val();
var time = $("input[name='time']").val();
if(file_path == ''){
alert('请先选择文件!');
return;
<?php $this->beginBlock('footer_js'); ?>
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script>
var o = {};
function opFormatter(value, row, index) {
var opStr = [];
opStr.push('<a href="javascript:void(0);" onclick="edit(' + row.id + ')">');
opStr.push('<i class="fa fa-edit" title="维护"></i>');
opStr.push('</a>');
return opStr.join(' ');
}
if(time == ''){
alert('请选择时间!');
return;
function edit(id) {
var title = '编辑工资';
layer_show(title, '/personnel/pay-info?id=' + id);
}
var params = $('#theFrm').serialize();
function refreshList() {
$('#listTable').bootstrapTable('refresh');
}
$.post('/personnel/import', params, function(obj){
alert(obj.msg);
function search() {
$('.input-group.date').datepicker({
minViewMode: 1,
keyboardNavigation: false,
forceParse: false,
autoclose: true,
todayHighlight: true,
format: "yyyy-mm"
});
$('#listTable').bootstrapTable('destroy');
$('#listTable').bootstrapTable({
url: "/personnel/pay-list-json",
pagination: true,
sidePagination: 'server',
multipleSelectRow: true,
queryParams: function(params) {
o['username'] = $('#username').val();
o['name'] = $('#name').val();
o['pay_date'] = $('#pay_date').val();
o['is_leave'] = $('#is_leave').prop("checked");
o['group_id'] = $('#group_id').val();
o['limit'] = params['limit'];
o['offset'] = params['offset'];
return o;
}
});
return false;
}
mySearch('username', 'search-btn');
mySearch('name', 'search-btn');
$(function() {
search();
});
</script>
<?php $this->endBlock(); ?>

Loading…
Cancel
Save