123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- <?php
- namespace app\admin\controller\project;
- use app\admin\BaseController;
- use app\admin\model\Appointment as AppointmentModel;
- use app\admin\model\CostProject;
- use app\admin\controller\Pushmessage;
- use think\exception\ValidateException;
- use think\facade\Db;
- use think\facade\View;
- use think\App;
- class Appointment extends BaseController{
-
-
- /**
- * 构造函数
- */
- public function __construct(App $app)
- {
- $this->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, "操作失败");
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
|