Appointment.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?php
  2. namespace app\admin\controller\project;
  3. use app\admin\BaseController;
  4. use app\admin\model\Appointment as AppointmentModel;
  5. use app\admin\model\CostProject;
  6. use app\admin\controller\Pushmessage;
  7. use think\exception\ValidateException;
  8. use think\facade\Db;
  9. use think\facade\View;
  10. use think\App;
  11. class Appointment extends BaseController{
  12. /**
  13. * 构造函数
  14. */
  15. public function __construct(App $app)
  16. {
  17. $this->model = new AppointmentModel();
  18. $this->costProjecModel = new CostProject();
  19. $this->Pushmessage = new Pushmessage();
  20. }
  21. public function datalist(){
  22. if (request()->isAjax()) {
  23. $param = get_params();
  24. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  25. $list = $this->model->where("project_id",$project_id)->paginate(9999, false, ['query' => $param])
  26. ->each(function ($item) {
  27. if($item->sponsor_unit==get_login_admin("unit_name")){
  28. $item->operate = false;
  29. }else{
  30. $item->operate = true;
  31. }
  32. });;
  33. return table_assign(0, '', $list);
  34. }else{
  35. return view();
  36. }
  37. }
  38. public function datalist_company(){
  39. if (request()->isAjax()) {
  40. $param = get_params();
  41. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  42. $list = $this->model->where("project_id",$project_id)->paginate(9999, false, ['query' => $param])
  43. ->each(function ($item) {
  44. if($item->sponsor_unit==get_login_admin("unit_name")){
  45. $item->operate = false;
  46. }else{
  47. $item->operate = true;
  48. }
  49. });;
  50. return table_assign(0, '', $list);
  51. }else{
  52. return view();
  53. }
  54. }
  55. public function add(){
  56. if (request()->isAjax()) {
  57. $param = get_params();
  58. $handle = $this->Pushmessage->handleParam($param);
  59. $param = $handle['param'];
  60. $result = $this->model->add($param);
  61. if($result){
  62. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  63. $people_company = [
  64. $people["review_head"],
  65. $people["operate_head"],
  66. ];
  67. for($i = 0; $i < count($people_company); $i++){
  68. if($people_company[$i] == NULL){
  69. unset($people_company[$i]);
  70. }
  71. }
  72. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], $people_company);
  73. add_project_log('预约现场', $param['project_id'], '预约现场');
  74. return to_assign(0, "添加成功!!");
  75. }
  76. }else{
  77. $param = get_params();
  78. $id = isset($param['project_id']) ? $param['project_id'] : 0;
  79. View::assign('project_id', $id);
  80. return view();
  81. }
  82. }
  83. public function add_company(){
  84. if (request()->isAjax()) {
  85. $param = get_params();
  86. $handle = $this->Pushmessage->handleParam($param);
  87. $param = $handle['param'];
  88. $result = $this->model->add($param);
  89. if($result){
  90. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  91. $people_company = [
  92. $people["review_head"],
  93. $people["operate_head"],
  94. ];
  95. for($i = 0; $i < count($people_company); $i++){
  96. if($people_company[$i] == NULL){
  97. unset($people_company[$i]);
  98. }
  99. }
  100. // halt($people);
  101. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], $people_company);
  102. add_project_log('预约现场', $param['project_id'], '预约现场');
  103. return to_assign(0, "添加成功!!");
  104. }
  105. }else{
  106. $param = get_params();
  107. $id = isset($param['project_id']) ? $param['project_id'] : 0;
  108. View::assign('project_id', $id);
  109. return view();
  110. }
  111. }
  112. public function agree(){
  113. if (request()->isAjax()) {
  114. $param = get_params();
  115. $handle = $this->Pushmessage->handleParam($param);
  116. $param = $handle['param'];
  117. $result = $this->model->agree($param);
  118. if($result){
  119. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  120. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]);
  121. add_project_log('通过预约现场申请', $param['project_id'], get_login_admin("nickname").'通过预约现场申请');
  122. return to_assign(0, "操作成功");
  123. }
  124. return to_assign(1, "操作失败");
  125. }
  126. }
  127. public function disagree(){
  128. if (request()->isAjax()) {
  129. $param = get_params();
  130. $handle = $this->Pushmessage->handleParam($param);
  131. $param = $handle['param'];
  132. $result = $this->model->disagree($param);
  133. if($result){
  134. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  135. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]);
  136. add_project_log('拒绝预约现场申请', $param['project_id'], get_login_admin("nickname").'拒绝预约现场申请');
  137. return to_assign(0, "操作成功");
  138. }
  139. return to_assign(1, "操作失败");
  140. }
  141. }
  142. public function agree_company(){
  143. if (request()->isAjax()) {
  144. $param = get_params();
  145. $handle = $this->Pushmessage->handleParam($param);
  146. $param = $handle['param'];
  147. $result = $this->model->agree($param);
  148. if($result){
  149. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  150. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]);
  151. add_project_log('通过预约现场申请', $param['project_id'], get_login_admin("nickname").'通过预约现场申请');
  152. return to_assign(0, "操作成功");
  153. }
  154. return to_assign(1, "操作失败");
  155. }
  156. }
  157. public function disagree_company(){
  158. if (request()->isAjax()) {
  159. $param = get_params();
  160. $handle = $this->Pushmessage->handleParam($param);
  161. $param = $handle['param'];
  162. $result = $this->model->disagree($param);
  163. if($result){
  164. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  165. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]);
  166. add_project_log('拒绝预约现场申请', $param['project_id'], get_login_admin("nickname").'拒绝预约现场申请');
  167. return to_assign(0, "操作成功");
  168. }
  169. return to_assign(1, "操作失败");
  170. }
  171. }
  172. }