Appointment.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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 datalist_proprietor(){//业主预约现场列表
  56. if (request()->isAjax()) {
  57. $param = get_params();
  58. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  59. $list = $this->model->where("project_id",$project_id)->paginate(9999, false, ['query' => $param])
  60. ->each(function ($item) {
  61. if($item->sponsor_unit==get_login_admin("unit_name")){//发起人等于登录人
  62. $item->operate = false;
  63. }else{
  64. $item->operate = true;
  65. }
  66. });;
  67. return table_assign(0, '', $list);
  68. }else{
  69. return view();
  70. }
  71. }
  72. public function add(){//财政局
  73. if (request()->isAjax()) {
  74. $param = get_params();
  75. $handle = $this->Pushmessage->handleParam($param);
  76. $param = $handle['param'];
  77. $result = $this->model->add($param);
  78. if($result){
  79. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  80. $people_company = [
  81. $people["review_head"],
  82. $people["operate_head"],
  83. ];
  84. for($i = 0; $i < count($people_company); $i++){
  85. if($people_company[$i] == NULL){
  86. unset($people_company[$i]);
  87. }
  88. }
  89. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], $people_company);
  90. add_project_log('预约现场', $param['project_id'], '预约现场');
  91. return to_assign(0, "添加成功!!");
  92. }
  93. }else{
  94. $param = get_params();
  95. $id = isset($param['project_id']) ? $param['project_id'] : 0;
  96. $sent_review_unit=$this->costProjecModel->where("id","$id")->value("sent_review_unit");//业主单位
  97. //$sent_review_unit_name=$this->costProjecModel->where("id","$id")->value("sent_review_unit_name");//业主单位id
  98. //找到和送审单位一样的所有人
  99. $person=Db::name("admin")->where("unit_name","$sent_review_unit")->where("status",">",0)->field(["id", "nickname"])->select()->toArray();
  100. $person = array_values($person);//返回数组所有值,索引从0
  101. View::assign('person', $person);
  102. View::assign('project_id', $id);
  103. return view();
  104. }
  105. }
  106. public function add_company(){
  107. if (request()->isAjax()) {
  108. $param = get_params();
  109. $handle = $this->Pushmessage->handleParam($param);
  110. $param = $handle['param'];
  111. $result = $this->model->add($param);
  112. if($result){
  113. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  114. $people_company = [
  115. $people["review_head"],
  116. $people["operate_head"],
  117. ];
  118. for($i = 0; $i < count($people_company); $i++){
  119. if($people_company[$i] == NULL){
  120. unset($people_company[$i]);
  121. }
  122. }
  123. // halt($people);
  124. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], $people_company);
  125. add_project_log('预约现场', $param['project_id'], '预约现场');
  126. return to_assign(0, "添加成功!!");
  127. }
  128. }else{
  129. $param = get_params();
  130. $id = isset($param['project_id']) ? $param['project_id'] : 0;
  131. $sent_review_head_name=$this->costProjecModel->where("id","$id")->value("sent_review_head_name");
  132. View::assign('sent_review_head_name', $sent_review_head_name);
  133. View::assign('project_id', $id);
  134. return view();
  135. }
  136. }
  137. public function agree(){
  138. if (request()->isAjax()) {
  139. $param = get_params();
  140. $handle = $this->Pushmessage->handleParam($param);
  141. $param = $handle['param'];
  142. $result = $this->model->agree($param);
  143. if($result){
  144. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  145. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]);
  146. add_project_log('通过预约现场申请', $param['project_id'], get_login_admin("nickname").'通过预约现场申请');
  147. return to_assign(0, "操作成功");
  148. }
  149. return to_assign(1, "操作失败");
  150. }
  151. }
  152. public function disagree(){
  153. if (request()->isAjax()) {
  154. $param = get_params();
  155. $handle = $this->Pushmessage->handleParam($param);
  156. $param = $handle['param'];
  157. $result = $this->model->disagree($param);
  158. if($result){
  159. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  160. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]);
  161. add_project_log('拒绝预约现场申请', $param['project_id'], get_login_admin("nickname").'拒绝预约现场申请');
  162. return to_assign(0, "操作成功");
  163. }
  164. return to_assign(1, "操作失败");
  165. }
  166. }
  167. public function agree_company(){
  168. if (request()->isAjax()) {
  169. $param = get_params();
  170. $handle = $this->Pushmessage->handleParam($param);
  171. $param = $handle['param'];
  172. $result = $this->model->agree($param);
  173. if($result){
  174. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  175. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]);
  176. add_project_log('通过预约现场申请', $param['project_id'], get_login_admin("nickname").'通过预约现场申请');
  177. return to_assign(0, "操作成功");
  178. }
  179. return to_assign(1, "操作失败");
  180. }
  181. }
  182. public function disagree_company(){
  183. if (request()->isAjax()) {
  184. $param = get_params();
  185. $handle = $this->Pushmessage->handleParam($param);
  186. $param = $handle['param'];
  187. $result = $this->model->disagree($param);
  188. if($result){
  189. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  190. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]);
  191. add_project_log('拒绝预约现场申请', $param['project_id'], get_login_admin("nickname").'拒绝预约现场申请');
  192. return to_assign(0, "操作成功");
  193. }
  194. return to_assign(1, "操作失败");
  195. }
  196. }
  197. public function agree_proprietor(){
  198. if (request()->isAjax()) {
  199. $param = get_params();
  200. $handle = $this->Pushmessage->handleParam($param);
  201. $param = $handle['param'];
  202. $result = $this->model->agree($param);
  203. if($result){
  204. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  205. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]);
  206. add_project_log('通过预约现场申请', $param['project_id'], get_login_admin("nickname").'通过预约现场申请');
  207. return to_assign(0, "操作成功");
  208. }
  209. return to_assign(1, "操作失败");
  210. }
  211. }
  212. public function disagree_proprietor(){
  213. if (request()->isAjax()) {
  214. $param = get_params();
  215. $handle = $this->Pushmessage->handleParam($param);
  216. $param = $handle['param'];
  217. $result = $this->model->disagree($param);
  218. if($result){
  219. $people = $this->costProjecModel->where("id",$param["project_id"])->field("entrust_maker,review_head,operate_head")->find();
  220. if($people!=null)$this->Pushmessage->pushMessage($param["project_id"], (array)$people['entrust_maker'], [$people["review_head"],$people["operate_head"]]);
  221. add_project_log('拒绝预约现场申请', $param['project_id'], get_login_admin("nickname").'拒绝预约现场申请');
  222. return to_assign(0, "操作成功");
  223. }
  224. return to_assign(1, "操作失败");
  225. }
  226. }
  227. }