Leave.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\admin\controller\qingdongams\attendance;
  3. use addons\qingdongams\model\Staff;
  4. use app\common\controller\Backend;
  5. use addons\qingdongams\model\Leave as leaveModel;
  6. /**
  7. * 请假记录
  8. */
  9. class Leave extends Backend {
  10. public function _initialize() {
  11. parent::_initialize();
  12. $this->model = new leaveModel();
  13. }
  14. /**
  15. * 请假记录
  16. */
  17. public function index() {
  18. $this->request->filter(['strip_tags']);
  19. if ($this->request->isAjax()) {
  20. //0:全部 1:我的 2:下属的
  21. $type = input('type',0);
  22. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  23. switch($type){
  24. case 1:
  25. $staff = Staff::info();
  26. $wheres['create_staff_id'] = $staff->id;
  27. break;
  28. case 2:
  29. $wheres['create_staff_id'] = array('in',Staff::getLowerStaffId());
  30. break;
  31. default:
  32. $wheres['create_staff_id'] = array('in',Staff::getMyStaffIds());
  33. break;
  34. }
  35. $list = $this->model->where($where)->where($wheres)->with(['createStaff'])->order($sort, $order)->paginate($limit);
  36. $row = $list->items();
  37. $result = array("total" => $list->total(), "rows" => $row);
  38. return json($result);
  39. }
  40. return $this->view->fetch();
  41. }
  42. }