/** * 部门负责人指派内部人员任务 */ public function accept() { $data['noset']['task_id'] = $this->isP('task_id', '请选择任务'); $task = \Model\Content::findContent('task', $data['noset']['task_id'], 'task_id'); if (empty($task) || $task['task_delete'] == '1') { $this->error('任务不存在'); } $label = new \Expand\Label(); if (!in_array($_SESSION['team']['user_id'], explode(',', $label->findDepartment('department', 'department_id', $task['task_department_id'])['department_header']))) { $this->error('您不是部门负责人,不能进行指派'); } $data['task_user_id'] = $this->isP('task_user_id', '请选择指派的人'); $this->db()->transaction(); $setAccept = $this->db('task')->where('task_id = :task_id')->update($data); if (empty($setAccept)) { $this->db()->rollBack(); $this->error('设置指派失败'); } $addNotice = \Model\Notice::addNotice($data['task_user_id'], $data['noset']['task_id'], '1', $task['task_mail']); if (empty($addNotice)) { $this->db()->rollBack(); $this->error('生成新任务通知出错'); } $this->db()->commit(); $this->success('设置指派成功!', $this->url('Team-Task-view', array('id' => $data['noset']['task_id']))); }
/** * 提取报表 */ public function extract() { $head = explode(',', \Model\Content::findContent('department', $_SESSION['team']['user_department_id'], 'department_id')['department_header']); if (!in_array($_SESSION['team']['user_id'], $head) && ACTION == 'extract') { $this->error('您不是部门负责人,无权访问'); } $condition = "r.report_date BETWEEN :begin AND :end "; $param = array(); //allExtract将移除此限制 if (ACTION == 'extract') { $condition .= " AND r.department_id = :department_id"; $param['department_id'] = $_SESSION['team']['user_department_id']; } if (!empty($_GET['begin']) && !empty($_GET['end'])) { $param['begin'] = $_GET['begin']; $param['end'] = $_GET['end']; } else { $param['begin'] = date('Y-m-d'); $param['end'] = date('Y-m-d'); } if (!empty($_GET['user'])) { $condition .= " AND r.user_id = :user_id"; $param['user_id'] = $this->g('user'); } $result = $this->db('report AS r ')->join("{$this->prefix}report_content AS rc ON rc.report_id = r.report_id")->where($condition)->order('report_date DESC')->select($param); //是否导出excel if (!empty($_GET['excel'])) { $label = new \Expand\Label(); $excelTitle = array('日期/用户', '报表内容'); foreach ($result as $key => $value) { $list[$value['report_date']][$value['report_date']] = $value['report_date']; $list[$value['report_date'] . $value['user_id']][$value['user_id']] = $label->findUser('user', 'user_id', $value['user_id'])['user_name']; $list[$value['report_date'] . $value['user_id']][] = strip_tags(htmlspecialchars_decode($value['report_content'])); } $excel = new \Expand\Excel\Excel(); $excel->export(date('YmdHis') . '提取报表', $excelTitle, $list); } else { foreach ($result as $key => $value) { $list[$value['report_date']][$value['user_id']][] = $value; } } $this->assign('list', $list); $userList = \Model\Content::listContent('user'); $this->assign('user', $userList); $this->assign('begin', $param['begin']); $this->assign('end', $param['end']); $this->assign('title', '提取报表'); $this->layout('Report_extract'); }