Examine.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. namespace app\admin\controller\qingdong\examine;
  3. use addons\qingdong\model\Staff;
  4. use app\admin\controller\qingdong\Base;
  5. use app\common\controller\Backend;
  6. use addons\qingdong\model\ExamineRecord;
  7. use addons\qingdong\model\FormApproval;
  8. use think\DB;
  9. /**
  10. * 审核信息
  11. */
  12. class Examine extends Base {
  13. public function _initialize() {
  14. parent::_initialize();
  15. $this->model = new ExamineRecord();
  16. }
  17. /**
  18. * 审核合同
  19. */
  20. public function index() {
  21. $this->request->filter(['strip_tags']);
  22. if ($this->request->isAjax()) {
  23. $this->relationSearch = true;
  24. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  25. $status = input('status',0);
  26. $wheres['check_staff_id'] = $this->_staff->id;
  27. $wheres['relation_type'] = 'contract';
  28. if($status == 1){
  29. $wheres['status'] = array('in','1,2');
  30. }else{
  31. $wheres['status']=0;
  32. }
  33. $list = $this->model->where($where)->where($wheres)->with([
  34. 'checkStaff',
  35. 'contract' => ['ownerStaff']
  36. ])->order($sort, $order)->paginate($limit);
  37. $row = $list->items();
  38. $result = array("total" => $list->total(), "rows" => $row);
  39. return json($result);
  40. }
  41. return $this->view->fetch();
  42. }
  43. /**
  44. * 审核费用
  45. */
  46. public function consume() {
  47. $this->request->filter(['strip_tags']);
  48. if ($this->request->isAjax()) {
  49. $this->relationSearch = true;
  50. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  51. $status = input('status',0);
  52. $wheres['check_staff_id'] = $this->_staff->id;
  53. $wheres['relation_type'] = 'consume';
  54. if($status == 1){
  55. $wheres['status'] = array('in','1,2');
  56. }else{
  57. $wheres['status']=0;
  58. }
  59. $list = $this->model->where($where)->where($wheres)->with(['checkStaff','consume'=>['staff']])->order($sort, $order)->paginate($limit);
  60. $row = $list->items();
  61. $result = array("total" => $list->total(), "rows" => $row);
  62. return json($result);
  63. }
  64. return $this->view->fetch();
  65. }
  66. /**
  67. * 审核回款
  68. */
  69. public function receivables() {
  70. $this->request->filter(['strip_tags']);
  71. $receivables_id = input('receivables_id','','trim');
  72. if ($this->request->isAjax()) {
  73. $this->relationSearch = true;
  74. $status = input('status',0);
  75. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  76. $wheres['check_staff_id'] = $this->_staff->id;
  77. $wheres['relation_type'] = 'receivables';
  78. if($status == 1){
  79. $wheres['status'] = array('in','1,2');
  80. }else{
  81. $wheres['status']=0;
  82. }
  83. if(isset($receivables_id) && $receivables_id){
  84. $wheres['relation_id'] = $receivables_id;
  85. $wheres['status'] = array('neq',0);
  86. }
  87. $list = $this->model->where($where)->where($wheres)
  88. ->with(['checkStaff','receivables'=>['createStaff']])->order($sort, $order)->paginate($limit);
  89. $row = $list->items();
  90. $result = array("total" => $list->total(), "rows" => $row);
  91. return json($result);
  92. }
  93. return $this->view->fetch();
  94. }
  95. /**
  96. * 审核业绩目标
  97. */
  98. public function achievement() {
  99. $this->request->filter(['strip_tags']);
  100. if ($this->request->isAjax()) {
  101. $this->relationSearch = true;
  102. $status = input('status',0);
  103. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  104. $wheres['check_staff_id'] = $this->_staff->id;
  105. $wheres['relation_type'] = ExamineRecord::ACHIEVEMENT_TYPE;
  106. if($status == 1){
  107. $wheres['status'] = array('in','1,2');
  108. }else{
  109. $wheres['status']=0;
  110. }
  111. $list = $this->model->where($where)->where($wheres)->with(['checkStaff','achievement'=>['createStaff']])->order($sort, $order)->paginate($limit);
  112. $row = $list->items();
  113. $result = array("total" => $list->total(), "rows" => $row);
  114. return json($result);
  115. }
  116. return $this->view->fetch();
  117. }
  118. /**
  119. * 审核办公审批
  120. */
  121. public function work() {
  122. $this->request->filter(['strip_tags']);
  123. if ($this->request->isAjax()) {
  124. $this->relationSearch = true;
  125. $status = input('status',0);
  126. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  127. $wheres['check_staff_id'] = $this->_staff->id;
  128. $wheres['relation_type'] = 'approval';
  129. if($status == 1){
  130. $wheres['status'] = array('in','1,2');
  131. }else{
  132. $wheres['status']=0;
  133. }
  134. $list = $this->model->where($where)->where($wheres)
  135. ->with(['checkStaff','approval'=>['createStaff']])->order($sort, $order)->paginate($limit);
  136. foreach($list as $k=>$v){
  137. $list[$k]['approval_name'] = FormApproval::where(array('id'=>$v['approval']['formapproval_id']))->value('name');
  138. }
  139. $row = $list->items();
  140. $result = array("total" => $list->total(), "rows" => $row);
  141. return json($result);
  142. }
  143. return $this->view->fetch();
  144. }
  145. }