oa.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. public function getList($type = 'trip', $year = '', $month = '', $account = '', $dept = '', $orderBy = 'id_desc')
  3. {
  4. $date = '';
  5. $length = 0;
  6. $position = 0;
  7. if($year)
  8. {
  9. $position = 1;
  10. $length = 4;
  11. $date = $year;
  12. if($month)
  13. {
  14. $length = 7;
  15. $date = "$year-$month";
  16. }
  17. }
  18. elseif($month)
  19. {
  20. $date = $month;
  21. $position = 6;
  22. $length = 2;
  23. }
  24. return $this->dao->select('t1.*, t2.realname, t2.dept')
  25. ->from(TABLE_TRIP)->alias('t1')
  26. ->leftJoin(TABLE_USER)->alias('t2')->on("t1.createdBy=t2.account")
  27. ->where(1)
  28. ->beginIF($type != '')->andWhere('t1.type')->eq($type)->fi()
  29. ->beginIf($date)
  30. ->andWhere("SUBSTRING(t1.`begin`, $position, $length)", true)->eq($date)
  31. ->orWhere("SUBSTRING(t1.`end`, $position, $length)")->eq($date)
  32. ->markRight(1)
  33. ->fi()
  34. ->beginIF($account != '')->andWhere('t1.createdBy')->eq($account)->fi()
  35. ->beginIF($dept != '')->andWhere('t2.dept')->in($dept)->fi()
  36. ->orderBy("t2.dept,t1.{$orderBy}")
  37. ->fetchAll();
  38. }