model = new AppointmentModel(); $this->costProjecModel = new CostProject(); $this->Pushmessage = new Pushmessage(); } public function datalist(){ if (request()->isAjax()) { $param = get_params(); $project_id = isset($param['project_id']) ? $param['project_id'] : 0; $list = $this->model->where("project_id",$project_id)->paginate(9999, false, ['query' => $param]) ->each(function ($item) { if($item->sponsor_unit==get_login_admin("unit_name")){ $item->operate = false; }else{ $item->operate = true; } });; return table_assign(0, '', $list); }else{ return view(); } } public function datalist_company(){ if (request()->isAjax()) { $param = get_params(); $project_id = isset($param['project_id']) ? $param['project_id'] : 0; $list = $this->model->where("project_id",$project_id)->paginate(9999, false, ['query' => $param]) ->each(function ($item) { if($item->sponsor_unit==get_login_admin("unit_name")){ $item->operate = false; }else{ $item->operate = true; } });; return table_assign(0, '', $list); }else{ return view(); } } public function add(){ if (request()->isAjax()) { $param = get_params(); $handle = $this->Pushmessage->handleParam($param); $param = $handle['param']; $result = $this->model->add($param); if($result){ $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find(); $people_company = [ $people["review_head"], $people["operate_head"], ]; for($i = 0; $i < count($people_company); $i++){ if($people_company[$i] == NULL){ unset($people_company[$i]); } } if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], $people_company); add_project_log('预约现场', $param['project_id'], '预约现场'); return to_assign(0, "添加成功!!"); } }else{ $param = get_params(); $id = isset($param['project_id']) ? $param['project_id'] : 0; View::assign('project_id', $id); return view(); } } public function add_company(){ if (request()->isAjax()) { $param = get_params(); $handle = $this->Pushmessage->handleParam($param); $param = $handle['param']; $result = $this->model->add($param); if($result){ $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find(); $people_company = [ $people["review_head"], $people["operate_head"], ]; for($i = 0; $i < count($people_company); $i++){ if($people_company[$i] == NULL){ unset($people_company[$i]); } } // halt($people); if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], $people_company); add_project_log('预约现场', $param['project_id'], '预约现场'); return to_assign(0, "添加成功!!"); } }else{ $param = get_params(); $id = isset($param['project_id']) ? $param['project_id'] : 0; View::assign('project_id', $id); return view(); } } public function agree(){ if (request()->isAjax()) { $param = get_params(); $handle = $this->Pushmessage->handleParam($param); $param = $handle['param']; $result = $this->model->agree($param); if($result){ $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find(); if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]); add_project_log('通过预约现场申请', $param['project_id'], get_login_admin("nickname").'通过预约现场申请'); return to_assign(0, "操作成功"); } return to_assign(1, "操作失败"); } } public function disagree(){ if (request()->isAjax()) { $param = get_params(); $handle = $this->Pushmessage->handleParam($param); $param = $handle['param']; $result = $this->model->disagree($param); if($result){ $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find(); if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]); add_project_log('拒绝预约现场申请', $param['project_id'], get_login_admin("nickname").'拒绝预约现场申请'); return to_assign(0, "操作成功"); } return to_assign(1, "操作失败"); } } public function agree_company(){ if (request()->isAjax()) { $param = get_params(); $handle = $this->Pushmessage->handleParam($param); $param = $handle['param']; $result = $this->model->agree($param); if($result){ $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find(); if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]); add_project_log('通过预约现场申请', $param['project_id'], get_login_admin("nickname").'通过预约现场申请'); return to_assign(0, "操作成功"); } return to_assign(1, "操作失败"); } } public function disagree_company(){ if (request()->isAjax()) { $param = get_params(); $handle = $this->Pushmessage->handleParam($param); $param = $handle['param']; $result = $this->model->disagree($param); if($result){ $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find(); if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]); add_project_log('拒绝预约现场申请', $param['project_id'], get_login_admin("nickname").'拒绝预约现场申请'); return to_assign(0, "操作成功"); } return to_assign(1, "操作失败"); } } }