123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <?php
- namespace app\admin\controller\project;
- use app\admin\BaseController;
- use app\admin\model\CostProject as CostProjectModel;
- use app\admin\validate\project\CostProjectValidate;
- use think\exception\ValidateException;
- use think\facade\Db;
- use think\facade\Session;
- use think\facade\View;
- use think\App;
- use app\admin\controller\field\Fieldcompany;
- use app\admin\controller\Pushmessage;
- class AuditCompany extends BaseController
- {
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->Field = new Fieldcompany($this->app);
- $this->model = new CostProjectModel();
- $this->uid = get_login_admin('id');
-
- $this->Pushmessage = new Pushmessage();
- }
- public function datalist()
- {
- if (request()->isAjax()) {
- $param = get_params();
-
- $where3 = [];
- if (!empty($param['keywords'])) {
- $keyword = $param['keywords'];
- $where3[] = ['project_num|project_name|entrust_unit_name', 'like', '%' . $keyword . '%'];
- }
- //财政局立项
- $where = [
- ["cp_cost_project.delete_time", "=", 0],
- ["project_status", "=", 3],
- ["review_unit", "=", get_login_admin('unit_name')]
- ];
- //业主立项
- $where2 = [
- ["cp_cost_project.delete_time", "=", 0],
- ["project_status", "=", 0],
- ["proprietor_status", "=", 2],
- ["review_unit", "=", get_login_admin('unit_name')]
- ];
- $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- $list = $this->model->where($where3)->where(function ($query) use ($where,$where2) {
- // 第一组条件(entrust_maker)
- $query->where(function ($q1) use ($where) {
- $q1->where($where);
- });
- // 使用 OR 连接第二组条件(entrust_approver)
- $query->whereOr(function ($q2) use ($where2) {
- $q2->where($where2);
- });
- })
- ->order($order)->paginate($rows, false, ['query' => $param])
- ->each(function ($item) {
- $item->entrust_unit_name = Db::name('department')->where(['id' => $item->entrust_unit])->value('title');
- $entrust_head_id = Db::name('department')->where(['id' => $item->entrust_unit])->value('leader_id');
- if (!($item->entrust_head)) {
- $item->entrust_head = Db::name('admin')->where("id", $entrust_head_id)->value("nickname");
- }
- if (!($item->entrust_head_phone)) {
- $item->entrust_head_phone = Db::name('admin')->where("id", $entrust_head_id)->value("mobile");
- }
- //作业人
- $item->operate_name = Db::name("admin")->where("id", $item->operate_head)->value("nickname");
- $operate_team_names = null;
- $operate_team_names_ids = explode(",", $item->operate_team);
- for ($i = 0; $i < count($operate_team_names_ids); $i++) {
- $name = Db::name("admin")->where("id", $operate_team_names_ids[$i])->value("nickname");
- if (!($i == 0)) {
- $name = "," . $name;
- }
- $operate_team_names = $operate_team_names . $name;
- }
- $item->operate_team_names = $operate_team_names;
- });
-
- return table_assign(0, '', $list);
- } else {
- return view();
- }
- }
- public function iframe(){
- return view();
- }
- /**
- *
- * 接收
- */
- public function receive()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
-
- $status = Db::name("cost_project")->where("id", $param["id"])->field("project_status")->select();
- if (0 <= $status[0]["project_status"] && $status[0]["project_status"] < 4 && $param["id"]) {
- $param = array_merge($param, ["project_status" => 4]);
-
- $param["project_receive_time"] = time();
- $entrust_maker = Db::name("cost_project")->where("id", $param["id"])->field("project_status")->value("entrust_maker");
- if(empty($handle['financial'])){
- $handle['financial'] = (array)$entrust_maker;
- }else{
- $handle['financial'] = array_merge($handle['financial'],(array)$entrust_maker);
- }
- // $this->Pushmessage->pushMessage($param["id"], $handle['financial'], $handle['company']);
- $this->model->editCostProject($param);
-
- add_project_log('接收项目', $param['id'], '接收项目');
- } else {
- return to_assign(0, "已审核,无法删除");
- }
- }
- public function project_log($project_id)
- {
- // $project_id = 24;
- $login_admin = get_login_admin();
- $where = array();
- if ($login_admin['user_type'] == 2) {
- $where = [
- ['project_status', '>=', 3],
- ['unit_name', '=', $login_admin['unit_name']],
- ];
- } else {
- if ($login_admin['permission'] != 1) {
- $where = [
- ['unit_name', '=', $login_admin['unit_name']],
- ];
- }
- }
- // dump($where);
- $project_log = Db::name('ProjectLog')->where($where)->where('project_id', $project_id)->order('create_time', 'desc')->select()->toArray();
- foreach ($project_log as $key => $value) {
- $project_log[$key]['create_time'] = date("Y-m-d H:i:s", $value['create_time']);
- }
- // dump($project_log);
- // View::assign('project_log', $project_log);
- // return View();
- return $project_log;
- }
- /**
- * 查看信息
- */
- public function read()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = $this->model->getCostProjectById($id);
- $comment = Db::name("project_comment")->where("project_id", $id)->order('create_time', 'desc')->select();
- $file_array = Db::name('ProjectFile')
- ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
- ->alias('mf')
- ->join('File f', 'mf.file_id = f.id', 'LEFT')
- ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
- ->order('mf.create_time desc')
- ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
- ->select()->toArray();
- $report = Db::name("project_report")->where([["project_id", "=", $id], ["r.status", "=", 1]])->alias("r")->join("admin a", "r.maker_id = a.id")->field("r.*,a.nickname")->select();
- // halt($comment);
- $project_log = self::project_log($id);
- View::assign('project_log', $project_log);
- // halt($project_log);
- // 根据用户id 查询其能显示的字段
- $field = $this->Field->get_field_rules_new($this->uid);
- // dump($field);
- if (!empty($detail)) {
- View::assign('project_id', $id);
- View::assign('comment', $comment);
- View::assign('field', $field);
- View::assign('detail', $detail);
- View::assign('file_array', $file_array);
- View::assign('report', $report);
- View::assign('project_five', self::getProjectFive());
- return view();
- } else {
- throw new \think\exception\HttpException(404, '找不到页面');
- }
- }
- public function getProjectFive()
- {
- $where = [
- ['name', '=', '作业日志-财政局'],
- ['name', '=', '工作记录-财政局'],
- ['name', '=', '项目报告-财政局'],
- ['name', '=', '项目人员-财政局'],
- ['name', '=', '项目动态-财政局'],
- ];
- $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
- $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
- $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
- $login_rules = explode(',', $login_rules);
- $rules_id = array();
- foreach ($list as $key => $value) {
- if ($value['name'] == "作业日志-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_comments'] = 1;
- } else {
- $rules_id['project_comments'] = 0;
- }
- } else if ($value['name'] == "工作记录-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_record'] = 1;
- } else {
- $rules_id['project_record'] = 0;
- }
- } else if ($value['name'] == "项目报告-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_report'] = 1;
- } else {
- $rules_id['project_report'] = 0;
- }
- } else if ($value['name'] == "项目人员-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_user'] = 1;
- } else {
- $rules_id['project_user'] = 0;
- }
- } else if ($value['name'] == "项目动态-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_log'] = 1;
- } else {
- $rules_id['project_log'] = 0;
- }
- }
- }
- return $rules_id;
- }
- }
|