PHP开发好的人力资源管理功能,人事行政部门可以轻松管理、人员招聘、简历管理、offer管理、人员面试等等日常工作,帮助企业提升工作效率
// 员工提醒 (转正之前一周显示提醒)
public function remind()
{
$sdate = date('Y-m-d');
$edate = date('Y-m-d', strtotime('+1 week', strtotime(date('Y-m-d'))));
// echo $date;exit;
$data = model('Offer')->alias('o')
->join('hrm_option ho', 'ho.id=o.classId')
->field('o.*,ho.op_txt as classId_txt')
->where('o.zzzr','>=', $sdate)
->where('o.zzzr','<=', $edate)
->where('o.check_status', 2)
->order('o.zzzr asc')
->select();
return resultArray(['data' => $data]);
}
//用户信息导出
public function excelExport()
{
$param = $this->param;
$userInfo = $this->userInfo;
$param['user_id'] = $userInfo['id'];
$action_name = '导出';
// $action_name = '导出全部';
// if ($param['customer_id']) {
// $param['customer_id'] = ['condition' => 'in', 'value' => $param['customer_id'], 'form_type' => 'text', 'name' => ''];
// $action_name = '导出选中';
// }
$excelModel = new \app\admin\model\Excel();
// 导出的字段列表
$fieldModel = new \app\admin\model\Field();
$field_list = $param['fieldList'];
// 文件名
$file_name = 'offer_' . date('Ymd');
$model = model('Offer');
$temp_file = $param['temp_file'];
unset($param['temp_file']);
$page = $param['page'] ?: 1;
unset($param['page']);
unset($param['export_queue_index']);
RecordActionLog($userInfo['id'], 'hrm_offer', 'excelexport', $action_name, '', '', '导出offer');
return $excelModel->batchExportCsv($file_name, $temp_file, $field_list, $page, function ($page, $limit) use ($model, $param, $field_list) {
$param['page'] = $page;
$param['limit'] = $limit;
$data = $model->getDataList($param);
$data['list'] = $model->exportHandle($data['list'], $field_list, 'hrm_offer');
return $data;
});
}
namespace app\hrm\model;
use app\admin\controller\ApiCommon;
use app\admin\model\User;
use app\admin\traits\FieldVerificationTrait;
use think\Db;
use app\admin\model\Common;
use think\response\Json;
class Miansjl extends Common
{
use FieldVerificationTrait;
protected $name = 'hrm_miansjl';
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $autoWriteTimestamp = true;
}
public function getDataList($request)
{
# 格式化参数
$request = $this->fmtRequest( $request );
$requestMap = $request['map'] ? : [];
# 普通筛选
$searchMap = [];
if(isset($request['khmcId']) && $request['khmcId']){ //客户名称
$searchMap['bring.khmcId'] = ['=', $request['khmcId']];
}
if(isset($request['zprq']) && $request['zprq'] && isset($request['zprq2']) && $request['zprq2']){ //发布日期
$searchMap['bring.create_time'] = [ ['>=',$request['zprq']], ['<=',$request['zprq2']], 'and'];
}else if(isset($request['zprq']) && $request['zprq']){
$searchMap['bring.create_time'] = ['>=',$request['zprq']];
}else if(isset($request['zprq2']) && $request['zprq2']){
$searchMap['bring.create_time'] = ['<=',$request['zprq2']];
}
if(isset($request['zpzw']) && $request['zpzw']){ //招聘职位
$searchMap['bring.zpzw'] = ['like', '%'.$request['zpzw'].'%'];
}
if(isset($request['chengs']) && $request['chengs']){ //城市
$searchMap['bring.chengs'] = ['like', '%'.$request['chengs'].'%'];
}
if(isset($request['zpzyId']) && $request['zpzyId']){ //招聘专员
$searchMap['bring.zpzyId'] = ['=', $request['zpzyId']];
}
if(isset($request['is_zt']) && $request['is_zt']){ //状态
$searchMap['bring.is_zt'] = ['=', $request['is_zt']-1];
}
if(isset($requestMap['is_zt']) && $requestMap['is_zt']){ //状态
$searchMap['bring.is_zt'] = ['=', $requestMap['is_zt']];
}
if(isset($requestMap['ids']) && $requestMap['ids']){
$searchMap['bring.id'] = ['in', $requestMap['ids']];
}
if(isset($requestMap['khmcId']) && $requestMap['khmcId']){ //客户名称
$searchMap['bring.khmcId'] = ['=', $requestMap['khmcId']];
}
if(isset($requestMap['postName']) && $requestMap['postName']){ //招聘职位
$searchMap['bring.zpzw'] = ['like', '%'.$requestMap['postName'].'%'];
}
# 排序
// if ($order_type && $order_field && $order_field != 'owner_user_structure_name') {
// $order = $fieldModel->getOrderByFormtype('crm_customer','customer',$order_field,$order_type);
// } else {
$order = 'bring.update_time desc';
// }
$list = db('hrm_bring')->alias('bring')
->where($map)
->where($searchMap)
->limit($request['offset'], $request['length'])
// ->field($indexField)
->orderRaw($order)
->select();
$totalRow = db('hrm_bring')->alias('bring')
->where($map)
->where($searchMap)
->count();
foreach($list as $key=>$row){
$list[$key]['create_time_txt'] = date('Y-m-d H:i:s', $row['create_time']);
$khmcId_name = db('crm_customer')->where(['customer_id' => $row['khmcId']])->value('name');
$khmcId_info = [
'customer_id' => $row['khmcId'],
'name' => $khmcId_name,
];
$list[$key]['khmcId_name'] = $khmcId_name;
// $list[$key]['khmcId'] = $khmcId_info;
if(!$row['jjcdId']) $list[$key]['jjcdId'] = '';
$zpzyId_name = db('admin_user')->where(['id' => $row['zpzyId']])->value('realname');
$list[$key]['zpzyId_name'] = $zpzyId_name;
$nUserId_name = db('admin_user')->where(['id' => $row['nUserId']])->value('realname');
$list[$key]['nUserId_name'] = $nUserId_name;
// 招聘人数(需求人数)
$rs = intval($row['rs']);
if($rs>0){
// 入职人数
$list[$key]['sjmzrs'] = Resume::alias('resume')
->join('(select msztId,nParentId,msrqsjian,create_time from 5kcrm_hrm_miansjl where id in (select max(id) from 5kcrm_hrm_miansjl group by nParentId)) ms', 'ms.nParentId=resume.id', 'left')
->where('resume.bring_id', $row['id'])
->where('ms.msztId','142')
->where('ms.msrqsjian','<=',strtotime($row['qwmzsj'].' 23:59:59'))
->count();
// 满足率计算= 入职人数/需求人数 (只计算在新增需求--期望满足时间期内)
$list[$key]['xqmzl'] = round($list[$key]['sjmzrs'] / $rs * 100, 2);
$mslist_temp = Resume::alias('resume')
->join('(select msztId,nParentId,msrqsjian,create_time from 5kcrm_hrm_miansjl where id in (select max(id) from 5kcrm_hrm_miansjl group by nParentId)) ms', 'ms.nParentId=resume.id', 'left')
->where('resume.bring_id', $row['id'])
->where('ms.msztId','142')
->order('ms.msrqsjian asc')
->limit($rs)
->select();
$list[$key]['sjmzsj'] = isset($mslist_temp[$rs-1]['msrqsjian'])?date('Y-m-d', $mslist_temp[$rs-1]['msrqsjian']):'';
}else{
$list[$key]['xqmzl'] = 0;
$list[$key]['sjmzsj'] = '';
}
$list[$key]['check_status_info'] = $this->statusArr[$row['check_status']];
$list[$key]['create_user_id_info'] = isset($row['create_user_id']) ? $userModel->getUserById($row['create_user_id']) : [];
}
$data = [];
$data['list'] = $list ? : [];
$data['totalRow'] = $totalRow ? : 0;
return $data;
}